Minibase Assignment #2: Heap File Page

Assigned on Wednesday, April 17.
Due on Wednesday, May 1.


Introduction

In this assignment, you will implement the page structure for the Heap File layer. You will be given libraries for the lower layers (Buffer Manager and Disk Space Manager), and some driver routines to test the code.

Preliminary Work

Begin by reading the description of Heap Files in section 7.5.1 of the text book, and the description of page formats in section 7.6. A HeapFile is seen as a collection of records. Internally, records are stored on a collection of pages. The pages are HFPage objects.

You will be implementing the HFPage class: a slotted page class that stores variable length records. The rest of the HeapFile code will be given to you. Read the description in the text of how variable length records can be stored on a slotted page, and follow this page organization.


Getting Started

Create a directory for the assignment, and change to that directory. Copy the file /usr/local/mini_hwk/assign/HFPage/src/Makefile to your current directory. To obtain the rest of the files that you will need, type make setup. If you make the project, it should create an executable named hfpage. You will need to provide the definition of the HFPage class in the file hfpage.C.

Sample output of a correct implementation is available in sample_output.


Design Overview and Implementation Details

Take a look at the file hfpage.h. It contains the interfaces for the HFPage class. This class implements a "heap-file page" object. Note that the protected data members of the class are given to you. All you need to do is implement the public member functions. You should put all your code into the file hfpage.C.

A Note on the Slot Directory

In the description in the text, the slot directory is located at the end of the page, and grows toward the beginning. This has confused students in the past, since it means that negative offsets into the slot directory have to be used. The current definition of HFPage has the slot directory at the beginning of the page, after a few fixed member fields, and growing toward the end. This does mean, however, that you will need to write the code so the records themselves are placed beginning at the end of the page. Be very careful with your pointer arithmetic.

Also note that in order to add a record to a page, there has to be room for the record itself in the data area, and there also has to be room for a new slot for this record in the slot directory (unless there happens to be a pre-allocated slot that is empty).


Error Reporting in the Code

Please follow the Minibase Error Protocol, in the same fashion that you did for the first Minibase assignment. Note that this layer of the code is referred to in error reporting as HEAPFILE (like BUFMGR was in the last assignment).

Methods to be Implemented


Handing in Your Code

Use hsp to hand in the entire directory containing your code. Do not submit the individual files, but rather submit the directory as a whole. For example, if I am sitting in the directory above BufMgr, I would execute the following command:

hsp musicant CS395 HFPage

Good luck!