{"id":15351344,"url":"https://github.com/tangsiyang2001/rookiedb","last_synced_at":"2025-03-27T19:20:08.693Z","repository":{"id":127685109,"uuid":"544456890","full_name":"TangSiyang2001/RookieDB","owner":"TangSiyang2001","description":"A personal implementation of Berkley's CS186.","archived":false,"fork":false,"pushed_at":"2023-05-01T12:40:53.000Z","size":705,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-01T22:13:45.285Z","etag":null,"topics":["bplus-tree","currency","database","dms","java","query-optimization","recovery"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TangSiyang2001.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-02T14:28:24.000Z","updated_at":"2023-07-18T12:59:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"a1778424-00b5-44aa-8bef-3094ee5a000c","html_url":"https://github.com/TangSiyang2001/RookieDB","commit_stats":{"total_commits":30,"total_committers":3,"mean_commits":10.0,"dds":0.4666666666666667,"last_synced_commit":"9f8761b65e55ad8e30da9d0ea1448ac6e95dbc4f"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TangSiyang2001%2FRookieDB","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TangSiyang2001%2FRookieDB/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TangSiyang2001%2FRookieDB/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TangSiyang2001%2FRookieDB/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TangSiyang2001","download_url":"https://codeload.github.com/TangSiyang2001/RookieDB/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245907556,"owners_count":20691956,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bplus-tree","currency","database","dms","java","query-optimization","recovery"],"created_at":"2024-10-01T12:03:40.958Z","updated_at":"2025-03-27T19:20:08.238Z","avatar_url":"https://github.com/TangSiyang2001.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RookieDB\n\n![The official unofficial mascot of the class projects](images/derpydb-small.jpg)\n\nThis repo contains a bare-bones database implementation, which supports\nexecuting simple transactions in series. In the assignments of\nthis class, you will be adding support for\nB+ tree indices, efficient join algorithms, query optimization, multigranularity\nlocking to support concurrent execution of transactions, and database recovery.\n\nSpecs for each of the projects will be released throughout the semester at here: [https://cs186.gitbook.io/project/](https://cs186.gitbook.io/project/)\n\n## Overview\n\nIn this document, we explain\n\n- how to fetch the released code\n- how to fetch any updates to the released code\n- how to setup a local development environment\n- how to run tests using IntelliJ\n- how to submit your code to turn in assignments\n- the general architecture of the released code\n\n## Fetching the released code\n\nFor each project, we will provide a GitHub Classroom link. Follow the\nlink to create a GitHub repository with the starter code for the project you are\nworking on. Use `git clone` to get a local copy of the newly\ncreated repository.\n\n## Fetching any updates to the released code\n\nIn a perfect world, we would never have to update the released code because\nit would be perfectly free of bugs. Unfortunately, bugs do surface from time to\ntime, and you may have to fetch updates. We will provide further instructions\nvia a post on Piazza whenever fetching updates is necessary.\n\n## Setting up your local development environment\n\nYou are free to use any text editor or IDE to complete the assignments, but **we\nwill build and test your code in a docker container with Maven**.\n\nWe recommend setting up a local development environment by installing Java\n8 locally (the version our Docker container runs) and using an IDE such as\nIntelliJ.\n\n[Java 8 downloads](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html)\n\nIf you have another version of Java installed, it's probably fine to use it, as\nlong as you do not use any features not in Java 8. You should run tests\nsomewhat frequently inside the container to make sure that your code works with\nour setup.\n\nTo import the project into IntelliJ, make sure that you import as a Maven\nproject (select the pom.xml file when importing). Make sure that you can compile\nyour code and run tests (it's ok if there are a lot of failed tests - you\nhaven't begun implementing anything yet!). You should also make sure that you\ncan run the debugger and step through code.\n\n## Running tests in IntelliJ\n\nIf you are using IntelliJ, and wish to run the tests for a given assignment\nfollow the instructions in the following document:\n\n[IntelliJ setup](intellij-test-setup.md)\n\n## Submitting assignments\n\nTo submit a project, navigate to the cloned repo, and use\n`git push` to push all of your changes to the remote GitHub repository created\nby GitHub Classroom. Then, go to Gradescope class and click on the\nproject to which you want to submit your code. Select GitHub for the submission\nmethod (if it hasn't been selected already), and select the repository and branch\nwith the code you want to upload and submit. If you have not done this before,\nthen you will have to link your GitHub account to Gradescope using the \"Connect\nto GitHub\" button. If you are unable to find the appropriate repository, then you\nmight need to go to https://github.com/settings/applications, click Gradescope,\nand grant access to the `berkeley-cs186-student` organization.\n\nNote that you are only allowed to modify certain files for each assignment, and\nchanges to other files you are not allowed to modify will be discarded when we\nrun tests.\n\n## The code\n\nAs you will be working with this codebase for the rest of the semester, it is a good idea to get familiar with it. The code is located in the `src/main/java/edu/berkeley/cs186/database` directory, while the tests are located in the `src/test/java/edu/berkeley/cs186/database directory`. The following is a brief overview of each of the major sections of the codebase.\n\n### cli\n\nThe cli directory contains all the logic for the database's command line interface. Running the main method of CommandLineInterface.java will create an instance of the database and create a simple text interface that you can send and review the results of queries in. **The inner workings of this section are beyond the scope of the class** (although you're free to look around), you'll just need to know how to run the Command Line Interface.\n\n#### cli/parser\n\nThe subdirectory cli/parser contains a lot of scary looking code! Don't be intimidated, this is all generated automatically from the file RookieParser.jjt in the root directory of the repo. The code here handles the logic to convert from user inputted queries (strings) into a tree of nodes representing the query (parse tree).\n\n#### cli/visitor\n\nThe subdirectory cli/visitor contains classes that help traverse the trees created from the parser and create objects that the database can work with directly.\n\n### common\n\nThe `common` directory contains bits of useful code and general interfaces that\nare not limited to any one part of the codebase.\n\n### concurrency\n\nThe `concurrency` directory contains a skeleton for adding multigranularity\nlocking to the database. You will be implementing this in Project 4.\n\n### databox\n\nOur database has, like most DBMS's, a type system distinct from that of the\nprogramming language used to implement the DBMS. (Our DBMS doesn't quite provide\nSQL types either, but it's modeled on a simplified version of SQL types).\n\nThe `databox` directory contains classes which represents values stored in\na database, as well as their types. The various `DataBox` classes represent\nvalues of certain types, whereas the `Type` class represents types used in the\ndatabase.\n\nAn example:\n```java\nDataBox x = new IntDataBox(42); // The integer value '42'.\nType t = Type.intType();        // The type 'int'.\nType xsType = x.type();         // Get x's type, which is Type.intType().\nint y = x.getInt();             // Get x's value: 42.\nString s = x.getString();       // An exception is thrown, since x is not a string.\n```\n\n### index\n\nThe `index` directory contains a skeleton for implementing B+ tree indices. You\nwill be implementing this in Project 2.\n\n### memory\n\nThe `memory` directory contains classes for managing the loading of data\ninto and out of memory (in other words, buffer management).\n\nThe `BufferFrame` class represents a single buffer frame (page in the buffer\npool) and supports pinning/unpinning and reading/writing to the buffer frame.\nAll reads and writes require the frame be pinned (which is often done via the\n`requireValidFrame` method, which reloads data from disk if necessary, and then\nreturns a pinned frame for the page).\n\nThe `BufferManager` interface is the public interface for the buffer manager of\nour DBMS.\n\nThe `BufferManagerImpl` class implements a buffer manager using\na write-back buffer cache with configurable eviction policy. It is responsible\nfor fetching pages (via the disk space manager) into buffer frames, and returns\nPage objects to allow for manipulation of data in memory.\n\nThe `Page` class represents a single page. When data in the page is accessed or\nmodified, it delegates reads/writes to the underlying buffer frame containing\nthe page.\n\nThe `EvictionPolicy` interface defines a few methods that determine how the\nbuffer manager evicts pages from memory when necessary. Implementations of these\ninclude the `LRUEvictionPolicy` (for LRU) and `ClockEvictionPolicy` (for clock).\n\n### io\n\nThe `io` directory contains classes for managing data on-disk (in other words,\ndisk space management).\n\nThe `DiskSpaceManager` interface is the public interface for the disk space\nmanager of our DBMS.\n\nThe `DiskSpaceMangerImpl` class is the implementation of the disk space\nmanager, which maps groups of pages (partitions) to OS-level files, assigns\neach page a virtual page number, and loads/writes these pages from/to disk.\n\n### query\n\nThe `query` directory contains classes for managing and manipulating queries.\n\nThe various operator classes are query operators (pieces of a query), some of\nwhich you will be implementing in Project 3.\n\nThe `QueryPlan` class represents a plan for executing a query (which we will be\ncovering in more detail later in the semester). It currently executes the query\nas given (runs things in logical order, and performs joins in the order given),\nbut you will be implementing\na query optimizer in Project 3 to run the query in a more efficient manner.\n\n### recovery\n\nThe `recovery` directory contains a skeleton for implementing database recovery\na la ARIES. You will be implementing this in Project 5.\n\n### table\n\nThe `table` directory contains classes representing entire tables and records.\n\nThe `Table` class is, as the name suggests, a table in our database. See the\ncomments at the top of this class for information on how table data is layed out\non pages.\n\nThe `Schema` class represents the _schema_ of a table (a list of column names\nand their types).\n\nThe `Record` class represents a record of a table (a single row). Records are\nmade up of multiple DataBoxes (one for each column of the table it belongs to).\n\nThe `RecordId` class identifies a single record in a table.\n\n\nThe `PageDirectory` class is an implementation of a heap file that uses a page directory.\n\n#### table/stats\n\nThe `table/stats` directory contains classes for keeping track of statistics of\na table. These are used to compare the costs of different query plans, when you\nimplement query optimization in Project 4.\n\n### Transaction.java\n\nThe `Transaction` interface is the _public_ interface of a transaction - it\ncontains methods that users of the database use to query and manipulate data.\n\nThis interface is partially implemented by the `AbstractTransaction` abstract\nclass, and fully implemented in the `Database.Transaction` inner class.\n\n### TransactionContext.java\n\nThe `TransactionContext` interface is the _internal_ interface of a transaction -\nit contains methods tied to the current transaction that internal methods\n(such as a table record fetch) may utilize.\n\nThe current running transaction's transaction context is set at the beginning\nof a `Database.Transaction` call (and available through the static\n`getCurrentTransaction` method) and unset at the end of the call.\n\nThis interface is partially implemented by the `AbstractTransactionContext` abstract\nclass, and fully implemented in the `Database.TransactionContext` inner class.\n\n### Database.java\n\nThe `Database` class represents the entire database. It is the public interface\nof our database - users of our database can use it like a Java library.\n\nAll work is done in transactions, so to use the database, a user would start\na transaction with `Database#beginTransaction`, then call some of\n`Transaction`'s numerous methods to perform selects, inserts, and updates.\n\nFor example:\n```java\nDatabase db = new Database(\"database-dir\");\n\ntry (Transaction t1 = db.beginTransaction()) {\n    Schema s = new Schema()\n            .add(\"id\", Type.intType())\n            .add(\"firstName\", Type.stringType(10))\n            .add(\"lastName\", Type.stringType(10));\n\n    t1.createTable(s, \"table1\");\n\n    t1.insert(\"table1\", 1, \"Jane\", \"Doe\");\n    t1.insert(\"table1\", 2, \"John\", \"Doe\");\n\n    t1.commit();\n}\n\ntry (Transaction t2 = db.beginTransaction()) {\n    // .query(\"table1\") is how you run \"SELECT * FROM table1\"\n    Iterator\u003cRecord\u003e iter = t2.query(\"table1\").execute();\n\n    System.out.println(iter.next()); // prints [1, John, Doe]\n    System.out.println(iter.next()); // prints [2, Jane, Doe]\n\n    t2.commit();\n}\n\ndb.close();\n```\n\nMore complex queries can be found in\n[`src/test/java/edu/berkeley/cs186/database/TestDatabase.java`](src/test/java/edu/berkeley/cs186/database/TestDatabase.java).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftangsiyang2001%2Frookiedb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftangsiyang2001%2Frookiedb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftangsiyang2001%2Frookiedb/lists"}