/**************************************************************************************
 * Function Name: initBufferPool
 *
 * Description:
 *		Initialize the Buffer Pool
 *
 * Parameters:
 *		BM_BufferPool *const bm: the Buffer Pool Handler that the user wants to initiate
 *		const char * const pageFileName: the name of the requested page file
 *		const int numPages: capacity of the Buffer Pool
 *		ReplacementStrategy strategy; replacement strategy
 *		void *stratData: N/A
 *
 * Return:
 *		RC: return code
 *
 * Author:
 *		Chengnan Zhao <*****@*****.**>
 *
 * History:
 *		Date        Name									Content
 *		----------  --------------------------------------	------------------------
 *		2015-03-14  Chengnan Zhao <*****@*****.**>	Initialization
 *		2015-03-20	Xin Su <*****@*****.**>				Delete the unused queue
 *															Add comments
 *															Add the judgment of the rc returned by openPageFile
 **************************************************************************************/
RC initBufferPool(BM_BufferPool * const bm, const char * const pageFileName,
		const int numPages, ReplacementStrategy strategy, void *stratData) {
	// make sure the capacity of the Buffer Pool is valid
	if (numPages <= 0) {
		return RC_INVALID_NUMPAGES;
	}

	// init F_HANDLE
	F_HANDLE = (SM_FileHandle *) malloc(sizeof(SM_FileHandle));

	// init MEM_PAGE
	MEM_PAGE = (char *) calloc(PAGE_SIZE, sizeof(char));//not malloc

	// init Storage Manager
	initStorageManager();

	// Open the file with the name of the requested page file
	RC rc = -99; // init return code
	rc = openPageFile(bm->pageFile, F_HANDLE);

	if (rc != RC_OK) {
		return rc;
	}

	// init BM_BufferPool
	bm->pageFile = pageFileName; // set the name of the requested page file
	bm->numPages = numPages; // set the capacity of the Buffer Pool
	bm->strategy = strategy; // set the replacement strategy

	// init the PageList and store the entry in bm->mgmtData
	initPageList(bm);

	return RC_OK;
}
Exemplo n.º 2
0
/* main function running all tests */
int
main (void)
{
  testName = "";
  
  initStorageManager();
  myTestAssign1();
  return 0;
}
// main method
int main(void) {
	initStorageManager();
	testName = "";

	testCreatingAndReadingDummyPages();
	testReadPage();
	// testFIFO();
	testLRU();
}
/* main function running all tests */
int main(void)
{

	testName = "";
	initStorageManager();
	testCreateOpenClose();
	testSinglePageContent();

	return 0;
}
// main method
int
main (void)
{
    initStorageManager();
    testName = "";

    testClock();
    testLFU();
    return 0;
}
Exemplo n.º 6
0
/* main function running all tests */
int
main (void)
{
  testName = "";
  
  initStorageManager();

  testMultiPageContent();

  return 0;
}
/* main function running all tests */
int main (void) {
	testName = "";

	initStorageManager();

	testReadWrite();

	testAppendEnsureCapMetaData();

	return 0;
}
Exemplo n.º 8
0
/* main function running all tests */
int
main (void)
{
  testName = "";
  
  initStorageManager();

  testWrite();
//  testSinglePageContent();

  return 0;
}
Exemplo n.º 9
0
// main method
int 
main (void) 
{
  initStorageManager();
  testName = "";

  testCreatingAndRandomReadingDummyPages();
  testCreatingAndReadingDummyPages();
  testReadPage();
  testFIFO();
  testLRU();
  /* testError(); */
}