BadgerDB
|
00001 00008 #include <memory> 00009 #include <iostream> 00010 #include "buffer.h" 00011 #include "exceptions/buffer_exceeded_exception.h" 00012 #include "exceptions/page_not_pinned_exception.h" 00013 #include "exceptions/page_pinned_exception.h" 00014 #include "exceptions/bad_buffer_exception.h" 00015 #include "exceptions/hash_not_found_exception.h" 00016 00017 namespace badgerdb { 00018 00019 BufMgr::BufMgr(std::uint32_t bufs) 00020 : numBufs(bufs) { 00021 bufDescTable = new BufDesc[bufs]; 00022 00023 for (FrameId i = 0; i < bufs; i++) 00024 { 00025 bufDescTable[i].frameNo = i; 00026 bufDescTable[i].valid = false; 00027 } 00028 00029 bufPool = new Page[bufs]; 00030 00031 int htsize = ((((int) (bufs * 1.2))*2)/2)+1; 00032 hashTable = new BufHashTbl (htsize); // allocate the buffer hash table 00033 00034 clockHand = bufs - 1; 00035 } 00036 00037 00038 BufMgr::~BufMgr() { 00039 } 00040 00041 void BufMgr::advanceClock() 00042 { 00043 00044 } 00045 00046 void BufMgr::allocBuf(FrameId & frame) 00047 { 00048 } 00049 00050 00051 void BufMgr::readPage(File* file, const PageId pageNo, Page*& page) 00052 { 00053 } 00054 00055 00056 void BufMgr::unPinPage(File* file, const PageId pageNo, const bool dirty) 00057 { 00058 } 00059 00060 void BufMgr::flushFile(const File* file) 00061 { 00062 } 00063 00064 void BufMgr::allocPage(File* file, PageId &pageNo, Page*& page) 00065 { 00066 } 00067 00068 void BufMgr::printSelf(void) 00069 { 00070 BufDesc* tmpbuf; 00071 int validFrames = 0; 00072 00073 for (std::uint32_t i = 0; i < numBufs; i++) 00074 { 00075 tmpbuf = &(bufDescTable[i]); 00076 std::cout << "FrameNo:" << i << " "; 00077 tmpbuf->Print(); 00078 00079 if (tmpbuf->valid == true) 00080 validFrames++; 00081 } 00082 00083 std::cout << "Total Number of Valid Frames:" << validFrames << "\n"; 00084 } 00085 00086 }