src/main/java/edu/berkeley/cs186/databasedirectory, while the tests are located in the
src/test/java/edu/berkeley/cs186/databasedirectory. The following is a brief overview of each of the major sections of the codebase.
clidirectory contains all the logic for the database's command line interface. Running the main method of
CommandLineInterface.javawill 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.
cli/parsercontains a lot of scary looking code! Don't be intimidated, this is all automatically generated automatically from the file
RookieParser.jjtin 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).
commondirectory contains bits of useful code and general interfaces that are not limited to any one part of the codebase.
concurrencydirectory contains a skeleton for adding multigranularity locking to the database. You will be implementing this in Project 4.
databoxdirectory contains classes which represents values stored in a database, as well as their types. The various
DataBoxclasses represent values of certain types, whereas the
Typeclass represents types used in the database.
indexdirectory contains a skeleton for implementing B+ tree indices. You will be implementing this in Project 2.
memorydirectory contains classes for managing the loading of data into and out of memory (in other words, buffer management).
BufferFrameclass represents a single buffer frame (page in the buffer pool) and supports pinning/unpinning and reading/writing to the buffer frame. All reads and writes require the frame be pinned (which is often done via the
requireValidFramemethod, which reloads data from disk if necessary, and then returns a pinned frame for the page).
BufferManagerinterface is the public interface for the buffer manager of our DBMS.
BufferManagerImplclass implements a buffer manager using a write-back buffer cache with configurable eviction policy. It is responsible for fetching pages (via the disk space manager) into buffer frames, and returns Page objects to allow for manipulation of data in memory.
Pageclass represents a single page. When data in the page is accessed or modified, it delegates reads/writes to the underlying buffer frame containing the page.
EvictionPolicyinterface defines a few methods that determine how the buffer manager evicts pages from memory when necessary. Implementations of these include the
LRUEvictionPolicy(for LRU) and
iodirectory contains classes for managing data on-disk (in other words, disk space management).
DiskSpaceManagerinterface is the public interface for the disk space manager of our DBMS.
DiskSpaceMangerImplclass is the implementation of the disk space manager, which maps groups of pages (partitions) to OS-level files, assigns each page a virtual page number, and loads/writes these pages from/to disk.
querydirectory contains classes for managing and manipulating queries.
QueryPlanclass represents a plan for executing a query (which we will be covering in more detail later in the semester). It currently executes the query as given (runs things in logical order, and performs joins in the order given), but you will be implementing a query optimizer in Project 3 to run the query in a more efficient manner.
recoverydirectory contains a skeleton for implementing database recovery a la ARIES. You will be implementing this in Project 5.
tabledirectory contains classes representing entire tables and records.
Tableclass is, as the name suggests, a table in our database. See the comments at the top of this class for information on how table data is layed out on pages.
Schemaclass represents the schema of a table (a list of column names and their types).
Recordclass represents a record of a table (a single row). Records are made up of multiple DataBoxes (one for each column of the table it belongs to).
RecordIdclass identifies a single record in a table.
HeapFileinterface is the interface for a heap file that the
Tableclass uses to find pages to write data to.
PageDirectoryclass is an implementation of
HeapFilethat uses a page directory.
table/statsdirectory contains classes for keeping track of statistics of a table. These are used to compare the costs of different query plans, when you implement query optimization in Project 4.
Transactioninterface is the public interface of a transaction - it contains methods that users of the database use to query and manipulate data.
AbstractTransactionabstract class, and fully implemented in the
TransactionContextinterface is the internal interface of a transaction - it contains methods tied to the current transaction that internal methods (such as a table record fetch) may utilize.
Database.Transactioncall (and available through the static
getCurrentTransactionmethod) and unset at the end of the call.
AbstractTransactionContextabstract class, and fully implemented in the
Databaseclass represents the entire database. It is the public interface of our database - users of our database can use it like a Java library.
Database#beginTransaction, then call some of
Transaction's numerous methods to perform selects, inserts, and updates.