Fennel: /home/pub/open/dev/fennel/lucidera/bitmap/LbmSegmentReader.cpp Source File (original) (raw)

00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 #include "fennel/common/CommonPreamble.h" 00023 #include "fennel/exec/ExecStreamBufAccessor.h" 00024 #include "fennel/lucidera/bitmap/LbmSegmentReader.h" 00025 00026 FENNEL_BEGIN_CPPFILE("$Id: //open/dev/fennel/lucidera/bitmap/LbmSegmentReader.cpp#11 $"); 00027 00028 void LbmSegmentReader::init( 00029 SharedExecStreamBufAccessor &pInAccessorInit, 00030 TupleData &bitmapSegTuple) 00031 { 00032 init(pInAccessorInit, bitmapSegTuple, false, NULL); 00033 } 00034 00035 void LbmSegmentReader::init( 00036 SharedExecStreamBufAccessor &pInAccessorInit, 00037 TupleData &bitmapSegTuple, 00038 bool setBitmapInit, 00039 boost::dynamic_bitset<> *pBitmapInit) 00040 { 00041 LbmSegmentReaderBase::init( 00042 pInAccessorInit, 00043 bitmapSegTuple, 00044 setBitmapInit, 00045 pBitmapInit); 00046 initCommon(); 00047 } 00048 00049 void LbmSegmentReader::init( 00050 SharedLbmTupleReader &pTupleReaderInit, 00051 TupleData &bitmapSegTuple) 00052 { 00053 init(pTupleReaderInit, bitmapSegTuple, false, NULL); 00054 } 00055 00056 void LbmSegmentReader::init( 00057 SharedLbmTupleReader &pTupleReaderInit, 00058 TupleData &bitmapSegTuple, 00059 bool setBitmapInit, 00060 boost::dynamic_bitset<> *pBitmapInit) 00061 { 00062 LbmSegmentReaderBase::init( 00063 pTupleReaderInit, 00064 bitmapSegTuple, 00065 setBitmapInit, 00066 pBitmapInit); 00067 initCommon(); 00068 } 00069 00070 void LbmSegmentReader::initCommon() 00071 { 00072 firstReadDone = false; 00073 } 00074 00075 ExecStreamResult LbmSegmentReader::readSegment() 00076 { 00077 ExecStreamResult rc = readBitmapSegTuple(); 00078 if (rc != EXECRC_YIELD) { 00079 return rc; 00080 } 00081 00082 if (pSegDescStart) { 00083
00084
00085
00086 byteSegLen = 0; 00087 return advanceToByte(byteSegOffset); 00088 } 00089 00090 return EXECRC_YIELD; 00091 } 00092 00093 ExecStreamResult LbmSegmentReader::advanceToByte(LbmByteNumber byteNum) 00094 { 00095
00096 while (byteSegOffset + byteSegLen <= byteNum) { 00097
00098 if (pSegDescStart >= pSegDescEnd) { 00099 ExecStreamResult rc = readSegment(); 00100 if (rc != EXECRC_YIELD) { 00101 return rc; 00102 } 00103 firstReadDone = true; 00104 continue; 00105 } 00106 00107
00108 advanceSegment(); 00109 } 00110 00111
00112
00113 if (byteNum > byteSegOffset) { 00114 uint delta = opaqueToInt(byteNum - byteSegOffset); 00115 byteSegLen -= delta; 00116 pSegStart -= delta; 00117 byteSegOffset += delta; 00118 } 00119 00120 return EXECRC_YIELD; 00121 } 00122 00123 ExecStreamResult LbmSegmentReader::advanceToRid(LcsRid rid) 00124 { 00125 return advanceToByte(ridToByteNumber(rid)); 00126 } 00127 00128 void LbmSegmentReader::readCurrentByteSegment( 00129 LcsRid &startRid, PBuffer &byteSeg, uint &len) 00130 { 00131 assert(firstReadDone); 00132 startRid = byteNumberToRid(byteSegOffset); 00133 byteSeg = pSegStart; 00134 len = byteSegLen; 00135
00136
00137 assert(*byteSeg != 0); 00138 assert(len > 0); 00139 } 00140 00141 FENNEL_END_CPPFILE("$Id: //open/dev/fennel/lucidera/bitmap/LbmSegmentReader.cpp#11 $"); 00142 00143