CLASS DB
#include <db.h>
DB is the class that implements the low level database. It maintains a list of files, allocates and deallocates pages on the disk, and performs read/write to disk. There is a global variable (it's actually a macro) of type DB defined in "system_defs.h" :
MINIBASE_DB
Only methods that need to be used in implementing the buffer manager are shown here.
Methods
Status ReadPage(PageID pid, Page* pageptr)
Read the page whose page id = pid, into the memory area pointed to by pageptr.
Status WritePage(PageID pageno, Page* pageptr)
Write the page whose page id = pid, from the memory area pointed to by pageptr to disk.
Status AllocatePage(PageID& pid, int n = 1)
Allocate n pages, (n is optional and default to 1) on the disk, and set pid to the first page id of the pages allocated. The page id of the pages allocated will be pid, pid + 1, ... pid + n - 1.
Status DeallocatePage(PageID pid, int n = 1)
Deallocate n pages, (n is optional and default to 1) on the disk, starting with the page with page id = pid. All pages with page id pid, pid + 1, pud + n - 1 will be deallocate
Status AddFileEntry(const char* filename, PageID pid)
Add a fiele entry to the header page(s), where file starts with the given page.
Status DeleteFileEntry(const char* filename)
Delete the entry corresponding to a file from the header page(s).
Status GetFileEntry(const char* filename, PageID& pid)
Given the file name output page id of the first page in the file.