80 likes | 480 Views
HW4: Buffer Manager . Instructors: Winston Hsu, Hao-Hua Chu Fall 2009. Architecture of a DBMS. Query. Query Optimization and Execution. Relation Operators. File and Access Methods. Buffer Management. Disk Space Management. DB. Buffer Manager. Simple Buffer Manager Structure
E N D
HW4: Buffer Manager Instructors: Winston Hsu, Hao-Hua Chu Fall 2009
Architecture of a DBMS Query Query Optimization and Execution Relation Operators File and Access Methods Buffer Management Disk Space Management DB
Buffer Manager • Simple Buffer Manager Structure • Pages in the buffer pool is not ordered in any way • Hash table to figure out what frame a given disk page occupies • Love/Hate buffer replace algorithm • Operations • bring a disk page into the buffer pool and pin it • unpin a page in the buffer pool • allocate/de-allocate pages on disk • flush/flush all buffer page(s) into the disk page
Buffer Manager Memory Structure Buffer Page Description FrameDesc pageNodirtyFlagpin_count numbuf Buffer Pool Page Buffer Hash Table pageNo frameNo *next …… HTSIZE ……
Love/Hate Replacement • upper level user hints the buffer manager that the page is loved or hated. • Replace hated pages first, then loved pages. • MRU list for the hated pages, LRU list for the loved pages • “ Love conquers hate “
Functions (in buf.h and buf.C) • BufMgr • Initializes buffer manager: create buffer pool, buffer pool description, hash table….etc. • Malloc, calloc….. • pinPage, unpinPage, newPage, freePage, flushPage, flushAllPages • Use Minibase API • Your own functions (if needed) • For hash table and replacement policy
Minibase APIs • Page • Status MINIBASE_DB->read_page(PageIdpageno, Page* pageptr) • Status MINIBASE_DB->write_page(PageIdpageno, Page* pageptr) • Status MINIBASE_DB->allocate_page(PageId& start_page_num, intrun_size=1) • Status MINIBASE_DB->deallocate_page(PageIdstart_page_num, intrun_size=1) • Errors handling status = MINIBASE_DB->write_page(pageid, &bufPool[i]); if (status != OK) { // status: OK or FAIL // your own error message }
Get Started • Read the PDF for detail description. • Group assignment (at most 2 people/group) • Download BufMgr for source code. • Read README.first before you strat. • Post your questions on ptt.cc/ CSIE_DBMS. • Minibase homepage and Google