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


C++ BitMap::GetNextBit方法代码示例

本文整理汇总了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;
}
开发者ID:VincentX2016,项目名称:NaiveSQL,代码行数:89,代码来源:RM_FileScan.cpp


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