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 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?
If deleteRecord in HFPage fails will it return a status value of FAIL or RECNOTFOUND?
It returns true if the HFPage is empty, and false otherwise.
It returns the size of the largest record which can be added to the page.
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
You have to pin a page before you read it.
The buffer manager does not know anything about records on a page.
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.
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.
A heap file is an unordered set of records. The following operations are supported:
- Heap files can be created and destroyed.
- Existing heapfiles can be opened and closed.
- Records can be inserted and deleted.
- Each record is uniquely identified by a record id (rid). A specific record can be retrieved by using the record id.
There are two main pieces of code to be written:
- 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.
- Implement the class scan which performs a scan on the heap file.
Yes, look in Chapter 3 of the book (available in DoIT)
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.
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.
status = db->add_file_entry(name, headerPageNo);
status = bm->newPage(headerPageNo, pagePtr);
status = bm->pinPage(lastPageNo, pgptr); lastPage = (HFPage *) pgptr; status = lastPage->insertRecord(recPtr, recLen, rid);
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.
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.
It is passed by reference into insertRecord(), and insertRecord() modifies the rid.
Neither. If it fails, it returns - DBMGR (of type Status)
Back to the cs564 home page