In the previous lab, you created the Java representation of a Tuple
. Now we move up a level of granularity and implement the Java representation of a page. Your main task will be to implement the SlottedPage
class.
This assumes you already have your files from Lab 1 in a directory named colgatedb
that contains subfolders lib
and src
. In the example below, these files are in the Desktop folder.
This also assumes you have IntelliJ set up. Here is a step-by-step walkthrough of setting up IntelliJ
Before you continue, be sure to save a copy of lab1. (There is a chance that a small mistake in the process of opening lab2 could cause you to overwrite some files for lab1.)
Download the starter files. Please be sure to save as a .zip file and do not open it (yet). Save the .zip file in the same folder that contains cologatedb
. In this example, that’s the Desktop folder
Unzip the lab files.
$ cd /Users/username/Desktop # or wherever your files are located
$ ls # colgatedb should be in this folder!
colgatedb/ lab1.zip lab2.zip
$ ls colgatedb/ # colgatedb should contain lib/ and src/ subfolders!
lib/ src/
$ unzip lab2.zip
If the above does not work, you can simply open the lab2.zip file and manually drag the files into the appropriate folders in colgatedb/src/main/java/
and colgatedb/src/test/java/
. Make sure your folder structure matches the Java package names. For example, SlottedPage.java
is in the package colgatedb.page
so it should live in the folder colgatedb/src/main/java/colgatedb/page/
.
You can gain access to this room during open lab hours. However, you are strongly encouraged to save a copy of your work on your Colgate network drive, Google Drive, Dropbox, etc. so you can easily access it from elsewhere.
In this lab, you will implement the in-memory Java representation of a page of data. Recall that a page is an important concept in the database architecture: it represents the minimal unit of data that is read from disk into memory and written back out to disk. A significant fraction of the ColgateDB architecture centers around manipulating pages. Thus, it is essential that you implement this well! You’ll notice many of the methods include all sorts of error checking and exception throwing. This is to help the “future you” when you are coding more complex components of ColgateDB that rely on your page implementation.
The main task is to implement the methods of the SlottedPage
class. This page stores a collection of fixed-length tuples. Tuples are stored in slots. The basic architecture is similar to the organization described in the Ch. 9.6.1 of the Cow book. An important detail: this lab is focused exclusively with the Java class representation of the data. The following lab will address the problem of representing a page as a sequence of bytes and translating between the byte representation and the Java class representation. Therefore, during this lab you will not see much discussion of byte-level format details (such as what is described in Figure 9.6 of the book.) We’ll get to that next week.
You are expected to modify these files:
SimplePageId.java
RecordId.java
SlottedPage.java
You are expected to read, use, but not modify the remaining files.
Before implementing SlottedPage
itself, you are asked to implement two other classes RecordId
and SimplePageId
. Recall that all tuples are assigned record ids and all pages must have page ids. These identifiers allow other parts of the DBMS to unambiguously locate particular pages and records.
Task 1 Implement the methods in SimplePageId
. After you implement these methods, you should be able to pass the unit tests in SimplePageIdTest
.
Task 2 Implement the methods in RecordId
. After you implement these methods, you should be able to pass the unit tests in RecordIdTest
.
Task 3 Implement the methods in SlottedPage
. After you implement these methods, you should be able to pass the unit tests in SlottedPageTest
. Note: you are asked to implement an iterator over the tuples in the page. You may find it helpful to browse the IteratorExample
in the tutorials
package.
The milestone for this lab will be to complete the above tasks and pass the tests described above.
In addition, following this lab, there will be a code review. Please use these code quality criteria as a guideline.
Upload your files to Gradescope.