CS 564 - Assignment 1 FAQ


Note:

Please use the lab supported make in: /s/std/bin/make, rather than the version mentioned in the handout. The makefile is only a skeleton which you have to modify to suit your particular implementation. (You have to setup the dependencies in the Makefile)

Your heapfile should reject insertion of a record that cannot fit on a page.

Web pages you should read on heap files: page 1, 2.


What does the function bool HFPage::empty(void); return?

What does the function int HFPage::available_space(void); return?

Using DB::get_file_entry(), how do I know whether the file exists or not?

Do we have to pin and unpin pages - or does the buffer Mgr do it?

If the page becomes empty does the buffer manager automatically free it?

Why is a struct Headerpage provided?

Does the buffer manager maintain a dirty bit for a page?

What are the operations on a heap file?

What do I have to do in this assignment?

Is free space management explained some where?

What exactly is a scan iterator?

How do I register a file name with the DB class?

How do I get a new page from the buffer manager?

How do I insert a record on a page?

What are the private data members in the Class Heapfile?

What is the difference between the destructor and deleteFile in class HeapFile?

Does the method insertRecord in class HFPage set the RID (record id) or is that done in class HeapFile?

If deleteRecord in HFPage fails will it return a status value of FAIL or RECNOTFOUND?


What does the function bool HFPage::empty(void); return?

It returns true if the HFPage is empty, and false otherwise.
What does the function int HFPage::available_space(void); return?

It returns the size of the largest record which can be added to the page.
What is enum{TEMP, ORDINARY} FileType for?

Using DB::get_file_entry(), how do I know whether the file exists or not?

Here is how you find out if a file exists or not...
status = db->get_file_entry(name, headerPageNo);
if (status != OK)
        // file doesn't exist. First create it.
else
        // Open existing file
Do we have to pin and unpin pages, or does the buffer Mgr do it?

You have to pin a page before you read it.
If the page becomes empty does the BR automatically do the freeing?

The buffer manager does not know anything about records on a page.
Why is a struct Headerpage provided?

The struct header page is to be modified by you to reflect information that you want to store on the header page. The struct can then be dumped (copied) on to a page to store the information. When you open a heapfile, you just fill in the members of this structure initially, so that you don't have to decode this information from the header page repeatedly.
Does the buffer manager maintain a dirty bit for a page?

Dirty flags are maintained by you. You pass in TRUE or FALSE (defined in ~cs564-1/assigns95/include/da_types.h) depending on whether the page is dirty or not.
What are the operations on a heap file?

A heap file is an unordered set of records. The following operations are supported:
  1. Heap files can be created and destroyed.
  2. Existing heapfiles can be opened and closed.
  3. Records can be inserted and deleted.
  4. Each record is uniquely identified by a record id (rid). A specific record can be retrieved by using the record id.
What do I have to do?

There are two main pieces of code to be written:
  1. The free space manager. You must deal with free space intelligently, using a directory based structure (recommended) to identify pages with room for records. Then, these free spaces in pages should be utilized when insertions are performed.
  2. Implement the class scan which performs a scan on the heap file.
Is free space management explained some where?

Yes, look in Chapter 3 of the book (available in DoIT)

What exactly is a scan iterator?

A scan iterator supports a simple get_next() interface. Successive calls to the get_next() function returns successive elements in the heap file. You have to maintain state information in the scan class in order to achieve this effect.
What kind of implementation is recommended?

We recommend using the doubly linked list implementation for free space management, since there is support for it in the hfpage class. However, you are welcome to try the directory based implementation.
How do I register a file name with the DB class?

        status = db->add_file_entry(name, headerPageNo);
How do I get a new page from the buffer manager?

        status = bm->newPage(headerPageNo, pagePtr);
How do I insert a record on a page?

        status   = bm->pinPage(lastPageNo, pgptr);
        lastPage = (HFPage *) pgptr;
        status   = lastPage->insertRecord(recPtr, recLen, rid);
What are the private data members in the Class Heapfile?

The private data members in the heapfile are part of your implementation. The above were remanents of a previous implementation. They have been taken out now.
What is the difference between the destructor and deleteFile in class HeapFile?

deleteFile - Wipes out the heapfile from the database permanently. The earlier version of heapfile had an implementation for temporary heap files. The destructor would basically call deleteFile to delete the temporary file. The destructor should also unpin the header page.
Does the method insertRecord in class HFPage set the RID (record id) or is that done in class HeapFile?

It is passed by reference into insertRecord(), and insertRecord() modifies the rid.
If deleteRecord in HFPage fails will it return a status value of FAIL or RECNOTFOUND?

Neither. If it fails, it returns - DBMGR (of type Status)

Back to the cs564 home page