Example #1
0
const Status HeapFile::getRecord(const RID &  rid, Record & rec)
{	
	Status status;

	// If record is not on the currently pinned page
	if (rid.pageNo != curPageNo) {
		// Unpin current page
		status = unPinPage(filePtr, curPageNo, curDirtyFlag);
		if (status != OK) return status;
		
		// Cleanup curPage vars
		curDirtyFlag = false;

		// Read the required page
		status = bufMgr->readPage(filePtr, rid.pageNo, curPage);
		if (status != OK) returns status;

		// Pin the reqired page
		curPageNo = rid.pageNo;
	}   

	// Get record
	status = curPage->getRecord(rid, rec);
	if (status != OK) return status;

	// Set current record id
	curRec = rid;

	return status;
}
Example #2
0
int squash(Buffer * buf) {
   int num;
   for (num = 0; num < buf->nBufferBlocks; num++) {
      if (buf->pin[num] == 1) {
         unPinPage(buf, buf->pages[num].address);
      }
      if (buf->dirty[num] == 1) {
         flushPage(buf, buf->pages[num].address);
      }
   }

   free(buf->database);
   free(buf->pages);
   free(buf->cache);
   free(buf->buffer_timestamp);
   free(buf->cache_timestamp);
   free(buf->pin);
   free(buf->dirty);
   free(buf->volatileFDs);
   free(buf->persistentFDs);
   free(buf);

   return tfs_unmount();
}