本文整理汇总了C++中BitMap::GetNextBit方法的典型用法代码示例。如果您正苦于以下问题:C++ BitMap::GetNextBit方法的具体用法?C++ BitMap::GetNextBit怎么用?C++ BitMap::GetNextBit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitMap
的用法示例。
在下文中一共展示了BitMap::GetNextBit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetNextRec
RC RM_FileScan::GetNextRec(RM_Record &rec) {
if (!bInScan)
return RM_ERR_NOTINSCAN;
RC rc;
RID rid;
RM_Record tmpRec;
while (1) {
//std::cout <<"start next : "<< nowPage <<" "<<nowSlot<<"\n";
if (bNextPage) {
//std::cout << "before next page:" << nowPage<<"\n";
if (PF_ERR_EOF == fileHandle.pfh.GetNextPage(nowPage, nowPH)) {
bInScan = false;
return RM_ERR_EOF;
}
if (rc = nowPH.GetPageNum(nowPage))
return rc;
//std::cout << "after next page:" << nowPage<<"\n";
bNextPage = false;
nowSlot = -1;
continue;
}
char *pData;
if (rc = nowPH.GetData(pData))
return rc;
BitMap bitmap;
if (rc = fileHandle.GetBitMapFromData(pData, bitmap))
return rc;
//bitmap.print();
int nextBit;
if (RM_ENDOFPAGE == bitmap.GetNextBit(nowSlot, nextBit)) {
if (rc = fileHandle.pfh.UnpinPage(nowPage))
return rc;
bNextPage = true;
continue;
}
//std::cout << "nextbit: " << nextBit <<"\n";
nowSlot = nextBit;
RID rid;
rid.SetPageNum(nowPage);
rid.SetSlotNum(nowSlot);
// std::cout << "find slot: pageNum:"<<nowPage<<" slotNum:"<<nowSlot<<"\n";
//std::cout << "recordSize:" << fileHandle.header.recordSize<<"\n";
//std::cout << "firstFree :" << fileHandle.header.firstFree <<"\n";
//std::cout << "bitmapOffset :" << fileHandle.header.bitmapOffset <<"\n";
//std::cout << "bitmapSize : " << fileHandle.header.bitmapSize <<"\n";
//std::cout << "numRecordsPerPage : " << fileHandle.header.numRecordsPerPage <<"\n";
//std::cout << "numPages : " << fileHandle.header.numPages <<"\n";
//std::cout << rid.pageNum <<" "<<rid.slotNum<<"\n";
if (rc = fileHandle.GetRecordFromData(pData, rid, tmpRec))
return rc;
//for (int i = 0; i < fileHandle.header.recordSize; i++)
// std::cout << (int)tmpRec.pData[i] <<" ";
//std::cout <<"\n";
//std::cout << "recdata: " << (int)tmpRec.pData[3]<<"\n";
//std::cout << "offset:"<<attrOffset<<" "<<" len:"<<attrLength<<" type:"<<attrType<<"\n";
//std::cout << "compop:"<<this->compOp<<"\n";
char *tmpRecData;
if (rc = tmpRec.GetData(tmpRecData))
return rc;
if (this->compOp != NO_OP) {
bool flag;
if (this->compOp != IS_OP && this->compOp != IS_NOT_OP && tmpRec.IsNull(attrNumber))
flag = false;
else
flag = (* cmp)(tmpRecData + attrOffset, this->value, attrType, attrLength);
if (flag) {
rec = tmpRec;
break;
}
} else {
rec = tmpRec;
break;
}
}
return 0;
}