This lab is about representing database tuples as in-memory Java objects. It is also a chance to dust off your Java skills.
unzip lab1.zip
Like most relational databases, ColgateDB stores data on disk. To manipulate the data, we must bring it into memory, translating bytes into Java objects. Those Java objects in turn must be capable of being translated back into bytes. We will get into this translation in great detail in a coming lab.
For this lab, we focus on the Java representation of data. Database concepts such as schema, tuples, and fields are represented as Java classes.
A Tuple
in ColgateDB is quite basic. It consists of a collection of Field
objects, one per field in the Tuple
. Field
is an interface that different data types (e.g.,integer, string) implement. Tuples also have a type (or schema), called a tuple descriptor, represented by a TupleDesc
object. This object consists of a collection of TDItem
objects, one per field in the tuple. Each TDItem
specifies the field Type
and the name of the Field
.
It is possible to create a Tuple
object by simply calling the constructor and setting each field using the setField
method. In a later lab, you will parse data on disk to create tuples.
You are expected to modify these files:
Tuple.java
TupleDesc.java
You are expected to read, use, but not modify the remaining files.
Task 1 The code that you will write in this course will make heavy use of the object-oriented language features of Java. While I hope that many of the concepts it uses were covered in earlier classes, I realize that (a) your Java knowledge may be rusty and (b) perhaps some of the concepts were not covered in detail. Therefore, in these early labs I will ask you questions to refresh or add to your Java knowledge. Please answer these questions and turn in your answers on paper, at the end of lab or at the start of the following class.
toString
method of Tuple
your code should be taking advantage of polymorphism. Briefly (1-2 sentences) explain how it does.IntField
object from bytes (well, more precisely, from a Java class that represents an input stream of bytes). What is it?StringField
object and write it out as bytes. What is it?Task 2 Implement the methods in TupleDesc
. You’ll notice that each method currently throws an UnSupportedOperationException
. You can replace this line with your code. After you implement the methods in TupleDesc
you should be able to pass the unit tests in TupleDescTest
.
Task 3 Implement the methods in Tuple
. After you implement the methods in Tuple
you should be able to pass the unit tests in TupleTest
.
If the submitted code (see instructions above) passes the TupleDescTest
and TupleTest
and you have accurately answered the questions (Task 1), then you have completed the milestone for this lab.
Upload your files to Gradescope.