当前位置: 首页>>代码示例>>C++>>正文


C++ pinPage函数代码示例

本文整理汇总了C++中pinPage函数的典型用法代码示例。如果您正苦于以下问题:C++ pinPage函数的具体用法?C++ pinPage怎么用?C++ pinPage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了pinPage函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: testReadPage

void
testReadPage ()
{
  BM_BufferPool *bm = MAKE_POOL();
  BM_PageHandle *h = MAKE_PAGE_HANDLE();
  testName = "Reading a page";

  CHECK(createPageFile("testbuffer.bin"));
  CHECK(initBufferPool(bm, "testbuffer.bin", 3, RS_FIFO, NULL));
  
  CHECK(pinPage(bm, h, 0));
  CHECK(pinPage(bm, h, 0));

  CHECK(markDirty(bm, h));

  CHECK(unpinPage(bm,h));
  CHECK(unpinPage(bm,h));

  CHECK(forcePage(bm, h));

  CHECK(shutdownBufferPool(bm));
  CHECK(destroyPageFile("testbuffer.bin"));

  free(bm);
  free(h);

  TEST_DONE();
}
开发者ID:adityashirodkar,项目名称:Advanced-Database-Organization,代码行数:28,代码来源:test_assign2_1.c

示例2: initBufferPool

recordTableInfo *initBufferManagerForRecDetails(char *name,
		struct BM_BufferPool *bManager, struct BM_PageHandle *pageHandle) {
	recordTableInfo *recordTable = NULL;
	initBufferPool(bManager, name, 3, RS_FIFO, NULL);
	if(pinPage(bManager, pageHandle, 0)==RC_OK)
	recordTable = TranslateStringRecordTabDetails(pageHandle->data);
	if (PAGE_SIZE > recordTable->sizeOfSchema)
		pinPage(bManager, pageHandle, 1);
	return recordTable;
}
开发者ID:smritiraj22,项目名称:ADO-Spring-2016,代码行数:10,代码来源:init_record_mgr.c

示例3: deleteRecord

// Simply marks tombstones, doesn't physically delete or allow for records to overwrite
RC deleteRecord(RM_TableData *rel, RID id) {
	RM_TableMgmtData *tableMgmtData = rel->mgmtData;
	RM_Page *page;

	RC pinPageResult;
	if (pinPageResult = pinPage(&tableMgmtData->bufferPool, &tableMgmtData->pageHandle, id.page) != RC_OK) {
		return pinPageResult;
	}

	page = (RM_Page*)tableMgmtData->pageHandle.data;
	char *slotOffset = ((char*)&page->data) + (id.slot*getRecordSize(rel->schema));


	// Update tombstone
	*(char*)slotOffset = -1;

	RC markDirtyResult;
	if (markDirtyResult = markDirty(&tableMgmtData->bufferPool, &tableMgmtData->pageHandle) != RC_OK) {
		return markDirtyResult;
	}

	RC unpinPageResult;
	if (unpinPageResult = unpinPage(&tableMgmtData->bufferPool, &tableMgmtData->pageHandle) != RC_OK) {
		return unpinPageResult;
	}

	tableMgmtData->numTuples--;

	return RC_OK;
}
开发者ID:jesikitty,项目名称:graduate-coursework,代码行数:31,代码来源:record_mgr.c

示例4: updateRecord

RC updateRecord(RM_TableData *rel, Record *record) {
	RID *rid = &record->id;
	RM_TableMgmtData *tableMgmtData = rel->mgmtData;
	RM_Page *page;

	//  Check to see if feasible record
	if (rid->page == NO_PAGE || rid->slot == NO_SLOT) {
		return RC_RM_NO_RECORD;
	}

	RC pinPageResult;
	if (pinPageResult = pinPage(&tableMgmtData->bufferPool, &tableMgmtData->pageHandle, rid->page) != RC_OK) {
		return pinPageResult;
	}
	page = (RM_Page*)tableMgmtData->pageHandle.data;

	char *slotOffset = ((char*)&page->data) + (rid->slot * getRecordSize(rel->schema));


	int recordSize = getRecordSize(rel->schema);
	memcpy(slotOffset + 1, record->data, recordSize);

	RC markDirtyResult;
	if (markDirtyResult = markDirty(&tableMgmtData->bufferPool, &tableMgmtData->pageHandle) != RC_OK) {
		return markDirtyResult;
	}

	RC unpinPageResult;
	if (unpinPageResult = unpinPage(&tableMgmtData->bufferPool, &tableMgmtData->pageHandle) != RC_OK) {
		return unpinPageResult;
	}

	return RC_OK;
}
开发者ID:jesikitty,项目名称:graduate-coursework,代码行数:34,代码来源:record_mgr.c

示例5: addFreeSlot

void addFreeSlot(RM_TableMgmtData *tableMgmtData, RM_Page *page, int pageNum) {
	// Am I the free slot?
	if (tableMgmtData->nextFreeSlot < 1) {
		page->next = page->prev = pageNum;
		tableMgmtData->nextFreeSlot = pageNum;
	}
	// Add the slot to the list
	else {
		BM_PageHandle pageHandle;
		RM_Page *firstPage;

		RC pinPageResult;
		if (pinPageResult = pinPage(&tableMgmtData->bufferPool, &pageHandle, tableMgmtData->nextFreeSlot) != RC_OK) {
			return;
		}
		firstPage = (RM_Page*)pageHandle.data;

		RC markDirtyResult;
		if (markDirtyResult = markDirty(&tableMgmtData->bufferPool, &pageHandle) != RC_OK) {
			return;
		}
		firstPage->prev = pageNum;

		RC unpinPageResult;
		if (unpinPageResult = unpinPage(&tableMgmtData->bufferPool, &pageHandle) != RC_OK) {
			return;
		}

		page->next = tableMgmtData->nextFreeSlot;
		tableMgmtData->nextFreeSlot = pageNum;
		page->prev = 0;
	}
}
开发者ID:jesikitty,项目名称:graduate-coursework,代码行数:33,代码来源:record_mgr.c

示例6: setPageInfo

RC setPageInfo(BTreeHandle *tree, int value, PageNumber pageNum, int pos) {
	BM_PageHandle *page = (BM_PageHandle *) malloc(sizeof(BM_PageHandle));
	RC rc;

	// pin page 0, page 0 is the information page of b+ tree
	rc = -99;
	rc = pinPage(BM, page, pageNum);

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

	// set the first # of page value
	int *ip = (int *) page->data;
	ip[pos] = value;

	// unpin page 0
	rc = -99;
	rc = unpinPage(BM, page);

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

	free(page);

	return RC_OK;
}
开发者ID:jeffjiezhou,项目名称:Advanced-Database-Organization,代码行数:28,代码来源:btree_mgr.c

示例7: getPageInfo

RC getPageInfo(BTreeHandle *tree, PageNumber pageNum, int pos, int *result) {
	BM_PageHandle *page = (BM_PageHandle *) malloc(sizeof(BM_PageHandle));
	RC rc;

	// pin page 0, page 0 is the information page of b+ tree
	rc = -99;
	rc = pinPage(BM, page, pageNum);

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

	// get the first # of page 0, is # of nodes
	int *ip = (int *) page->data;
	*result = ip[pos];

	// unpin page 0
	rc = -99;
	rc = unpinPage(BM, page);

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

	free(page);

	return RC_OK;
}
开发者ID:jeffjiezhou,项目名称:Advanced-Database-Organization,代码行数:28,代码来源:btree_mgr.c

示例8: checkDummyPages

void 
checkDummyPages(BM_BufferPool *bm, int num)
{
  int i;
  BM_PageHandle *h = MAKE_PAGE_HANDLE();
  char *expected = malloc(sizeof(char) * 512);

  CHECK(initBufferPool(bm, "testbuffer.bin", 3, RS_FIFO, NULL));

  for (i = 0; i < num; i++)
    {
      CHECK(pinPage(bm, h, i));

      sprintf(expected, "%s-%i", "Page", h->pageNum);

      ASSERT_EQUALS_STRING(expected, h->data, "reading back dummy page content");
	 
      CHECK(unpinPage(bm,h));
    }

  CHECK(shutdownBufferPool(bm));

  free(expected);
  free(h);
}
开发者ID:dipentrivedi,项目名称:Database-Management-System,代码行数:25,代码来源:test_assign2_1.c

示例9: createDummyPages

void 
createDummyPages(BM_BufferPool *bm, int num)
{
  int i;
  BM_PageHandle *h = MAKE_PAGE_HANDLE();

  CHECK(initBufferPool(bm, "testbuffer.bin", 3, RS_FIFO, NULL));

  for (i = 0; i < num; i++)
    {
      CHECK(pinPage(bm, h, i));
	
	  sprintf(h->data, "%s-%i", "Page", h->pageNum);

	  CHECK(markDirty(bm, h));
	
	  CHECK(unpinPage(bm,h));

    }

  CHECK(shutdownBufferPool(bm));

  free(h);

}
开发者ID:dipentrivedi,项目名称:Database-Management-System,代码行数:25,代码来源:test_assign2_1.c

示例10: getNode

/***************************************************************
 * Function Name: getNode 
 * 
 * Description:get node from tree
 *
 * Parameters:BTreeHandle *tree, int nodeNum, BT_Node **node
 *
 * Return: RC
 *
 * Author:Xincheng Yang
 *
 * History:
 *      Date            Name                        Content
 *  04/9/2016          Xincheng Yang             finish this function
***************************************************************/
RC getNode (BTreeHandle *tree, int nodeNum, BT_Node **node)
{
    BM_PageHandle *pg = (BM_PageHandle *)calloc(1, sizeof(BM_PageHandle));
    RC rv = RC_OK;
    bool isNull = false;
    int maxsize=2*(tree->n+2);
    
    if(*node == NULL){
        isNull = true;
        *node = (BT_Node *)calloc(1, sizeof(BT_Node));
    } 

    if((rv = pinPage(tree->bufferPool, pg, nodeNum)) == RC_OK){
        memcpy(&(*node)->isValid, pg->data, sizeof(int));
        if((*node)->isValid == 0){
            unpinPage(tree->bufferPool, pg);
            rv = RC_IM_NODE_NOT_EXIST;
        } else {
            memcpy(&(*node)->parent, pg->data + sizeof(int), sizeof(int));
            memcpy(&(*node)->current, pg->data + 2*sizeof(int) , sizeof(int));
            memcpy(&(*node)->size, pg->data + 3*sizeof(int), sizeof(int));
            memcpy(&(*node)->nodeType, pg->data + 4*sizeof(int), sizeof(int));
            if(isNull || (*node)->element == NULL){
                (*node)->element = (BT_Element *)malloc(sizeof(BT_Element) * maxsize);
            } 
            memcpy((*node)->element, pg->data + 5*sizeof(int), sizeof(BT_Element) * (*node)->size);
            rv = unpinPage(tree->bufferPool, pg);
        }
    }
    
    free(pg);
    return rv;
}
开发者ID:tcw007,项目名称:525-PA4,代码行数:48,代码来源:btree_mgr.c

示例11: getRecord

RC getRecord (RM_TableData *rel, RID id, Record *record){
    int offset=0;
    pinPage(bm, page, id.page);
    offset=numPageHeader+id.slot*slotSize+sizeof(RID);
    record->id=id;
    record->data=page->data+offset;
    unpinPage(bm, page);
    return RC_OK;
}
开发者ID:axieyangb,项目名称:DatabaseOrganization_c_code,代码行数:9,代码来源:record_mgr.c

示例12: removeFromMiddle

void removeFromMiddle(TableManager *tableManager, Pager *dp, int pageno){
        BM_PageHandle pageHandler2;
         BM_PageHandle pageHandler;
        Pager *pagerData;
        Pager *tmp_dp2;
        pinPage(&tableManager->pool, &pageHandler, (PageNumber)dp->prev);
        pinPage(&tableManager->pool, &pageHandler2, (PageNumber)dp->next);
        pagerData= (Pager*) pageHandler.data;
        tmp_dp2= (Pager*) pageHandler2.data;
        markDirty(&tableManager->pool, &pageHandler);
        markDirty(&tableManager->pool, &pageHandler2);
        pagerData->next= dp->next;
        tmp_dp2->prev= dp->prev;
        unpinPage(&tableManager->pool, &pageHandler);
        unpinPage(&tableManager->pool, &pageHandler2);
        dp->next=dp->prev= 0;

}
开发者ID:bjs007,项目名称:DataBase,代码行数:18,代码来源:scanner.c

示例13: updateRecord

RC updateRecord (RM_TableData *rel, Record *record){
    int offset=0;
    pinPage(bm, page, record->id.page);
    offset=numPageHeader+record->id.slot*slotSize;
    offset+=sizeof(RID);
    memcpy(page->data+offset,record->data, slotSize-sizeof(RID));
    markDirty(bm, page);
    unpinPage(bm, page);
    return RC_OK;
}
开发者ID:axieyangb,项目名称:DatabaseOrganization_c_code,代码行数:10,代码来源:record_mgr.c

示例14: insertLeafNode

RC insertLeafNode(BTreeHandle *tree, BT_KeyPosition *kp, Value *key, RID *rid) {
	BM_PageHandle *page = (BM_PageHandle *) malloc(sizeof(BM_PageHandle));
	RC rc;

	// get N
	int n;
	rc = -99;
	rc = getN(tree, &n);

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

	// pin the page
	rc = pinPage(BM, page, kp->nodePage);

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

	int *ip = (int *) page->data;

	// get current keys
	int currentKeys = ip[1];

	// i is the index of key and key pointer, starts from 0
	int i;
	for (i = currentKeys - 1; i > kp->keyPos - 1; i--) {
		ip[4 + i + 1] = ip[4 + i];
		ip[4 + n + 2 * (i + 1)] = ip[4 + n + 2 * i];
		ip[4 + n + 2 * (i + 1) + 1] = ip[4 + n + 2 * i + 1];
	}

	// After the for loop, the i is pointing the left of the key position
	// put the key and RID into the right slot
	ip[4 + i + 1] = key->v.intV;
	ip[4 + n + 2 * (i + 1)] = rid->page;
	ip[4 + n + 2 * (i + 1) + 1] = rid->slot;

	// increment current
	ip[1]++;

	// unpin the page
	rc = -99;
	rc = unpinPage(BM, page);

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

	free(page);

	return RC_OK;
}
开发者ID:jeffjiezhou,项目名称:Advanced-Database-Organization,代码行数:54,代码来源:btree_mgr.c

示例15: deleteOldKey

RC deleteOldKey(BTreeHandle *tree, BT_KeyPosition *kp) {
	BM_PageHandle *page = (BM_PageHandle *) malloc(sizeof(BM_PageHandle));
	RC rc;

	// get N
	int n;
	rc = -99;
	rc = getN(tree, &n);

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

	// pin the page
	rc = pinPage(BM, page, kp->nodePage);

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

	int *ip = (int *) page->data;

	// get current keys
	int currentKeys = ip[1];

	int i;
	for (i = kp->keyPos + 1; i < currentKeys; i++) {
		ip[4 + i] = ip[4 + i + 1];
		ip[4 + n + 2 * i] = ip[4 + n + 2 * (i + 1)];
		ip[4 + n + 2 * i + 1] = ip[4 + n + 2 * (i + 1) + 1];
	}

	// After the for loop, the i is pointing the currentKeys position
	// unset the key and keyPointer of currentKeys position
	ip[4 + i] = 0;
	ip[4 + n + 2 * i] = 0;
	ip[4 + n + 2 * i + 1] = 0;

	// decrement current
	ip[1]--;

	// unpin the page
	rc = -99;
	rc = unpinPage(BM, page);

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

	free(page);

	return RC_OK;
}
开发者ID:jeffjiezhou,项目名称:Advanced-Database-Organization,代码行数:53,代码来源:btree_mgr.c


注:本文中的pinPage函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。