#include <LbmSegmentReader.h>
Inheritance diagram for LbmSegmentReader:
Public Member Functions | |
void | init (SharedExecStreamBufAccessor &pInAccessorInit, TupleData &bitmapSegTupleInit) |
Initializes reader to start reading bit segments from a specified input stream. | |
void | init (SharedExecStreamBufAccessor &pInAccessorInit, TupleData &bitmapSegTupleInit, bool setBitmapInit, boost::dynamic_bitset<> *pBitmapInit) |
Initializes reader to start reading bit segments from a specified input stream, optionally keeping track of the bits read. | |
void | init (SharedLbmTupleReader &pTupleReaderInit, TupleData &bitmapSegTupleInit) |
Initializes reader to start reading bit segments from a specified tuple reader. | |
void | init (SharedLbmTupleReader &pTupleReaderInit, TupleData &bitmapSegTupleInit, bool setBitmapInit, boost::dynamic_bitset<> *pBitmapInit) |
Initializes reader to start reading bit segments from a specified tuple reader, optionally keeping track of the bits read. | |
ExecStreamResult | advanceToRid (LcsRid rid) |
Advances within a segment to at least the specified rid, reading in new segments (as needed) to satisfy the request. | |
ExecStreamResult | advanceToByte (LbmByteNumber byteNum) |
Advances within a bit segment to at least the specified byte number, reading in new segments (as needed) to satisfy the request. | |
void | readCurrentByteSegment (LcsRid &startRid, PBuffer &byteSeg, uint &len) |
Reads the current byte segment, based on current position. | |
bool | getTupleChange () |
Reports whether a new tuple was read. | |
void | resetChangeListener () |
Resets the tuple change attribute to false. | |
LcsRid | getMaxRidSet () |
Retrieves the maximum rid that has been read by this reader since it was initialized, provided the reader has been set to keep track of rids read. | |
uint | getZeroLengthByteCount (uint8_t segDescByte) |
Get the number of bytes to store the length of zero bytes. | |
LcsRid | getStartRID () |
| |
Static Public Member Functions | |
static LcsRid | roundToByteBoundary (LcsRid rid) |
Rounds a rid value down to the nearest byte boundary. | |
static bool | setSegLength (uint8_t &segDescByte, uint segLen) |
Sets the length descriptor for a new segment with zero trailing zeros. | |
static bool | adjustSegLength (uint8_t &segDescByte, uint segLen) |
Set segment length in an existing descriptor with the new segment length. | |
static uint | getSegLength (uint8_t segDescByte) |
Get the segment length encoded in SegmentDescriptor. | |
Static Public Attributes | |
static const uint | LbmOneByteSize = 8 |
One byte in the bitmap encodes 8 RIDs. | |
static const uint | LbmOneByteSizeBitShift = 3 |
static const LcsRidPrimitive | LbmOneByteSizeBitMask |
Protected Member Functions | |
ExecStreamResult | readBitmapSegTuple () |
Reads a bitmap segment tuple from the input stream and extracts the starting rid, the descriptor, and bitmap fields. | |
void | advanceSegment () |
Advances byte segment offset and segment descriptor pointers to the next segment in a bitmap segment. | |
uint | computeSpaceForZeroBytes (uint nZeroBytes) |
Computes the number of bytes required to store a specified number of zero bytes. | |
uint | computeSegLength (PBuffer segDesc) |
Computes the length of the remaining segments in the current bitmap segment, starting at the one specified by the input segment descriptor. | |
uint | computeSegDescLength (PBuffer segDesc) |
Computes the length of the remaining segment descriptors in the current bitmap segment, starting at the one specified by the input segment descriptor. | |
uint | countSegments () |
Returns the number of segments in an entry. | |
Static Protected Member Functions | |
static uint | byteArray2Value (PBuffer array, uint arraySize) |
Get value stored in a byte array. | |
static uint | value2ByteArray (uint value, PBuffer array, uint arraySize) |
Store value in a byte array. | |
static void | readSegDescAndAdvance (PBuffer &pSegDesc, uint &bmSegLen, uint &zeroBytes) |
Decodes the lengths stored in the descriptor for a segment, based on where the segment descriptor is currently pointing, and advances the segment descriptor to the next descriptor. | |
Protected Attributes | |
SharedLbmTupleReader | pTupleReader |
Input tuple reader. | |
uint | byteSegLen |
Length of the current byte segment. | |
LbmByteNumber | byteSegOffset |
Byte offset representing current position in segment. | |
TupleData * | pBitmapSegTuple |
Pointer to tuple data containing input bitmap segment. | |
uint | iSrid |
Index of the bitmap columns. | |
uint | iSegmentDesc |
uint | iSegments |
uint | zeroBytes |
Number of trailing zero bytes in the current segment. | |
uint8_t | singleton |
Used to construct singleton bitmap. | |
bool | tupleChange |
Detects when a new tuple is read. | |
LcsRid | startRID |
Starting rid in the bitmap segment (if singleton, startRID == RID column in entryTuple). | |
PBuffer | pSegDescStart |
Increment forward from pSegDescStart. | |
PBuffer | pSegDescEnd |
PBuffer | pSegStart |
Decrement backward from pSegStart. | |
PBuffer | pSegEnd |
Static Protected Attributes | |
static const uint | LbmHalfByteSize = 4 |
Use half of a byte to encode the segment length, or the zero bytes length. | |
static const uint8_t | LbmSegLengthMask = 0xf0 |
The upper 4 bits of Segment Descriptor byte is used to store the length of the corresponding segment. | |
static const uint8_t | LbmZeroLengthMask = 0x0f |
The lower 4 bits of Segment Descriptor byte is used to store the length of the "gap" following the corresponding segment(till the next segment or the next LbmEntry). | |
static const uint | LbmZeroLengthCompact = 12 |
If the length of zero bytes(a byte composed of 8 bits of 0s) is less than 12, the length can be stored within the segment descriptor. | |
static const uint | LbmZeroLengthExtended |
Additional bytes(maximumn is 3 bytes) in which the length is stored. | |
static const uint | LbmMaxSegSize = 16 |
Maximum size(in bytes) for a bitmap segment. | |
Private Member Functions | |
ExecStreamResult | readSegment () |
Reads a bitmap segment from the input stream. | |
void | initCommon () |
Common initialization method, called by all other init methods. | |
Private Attributes | |
bool | firstReadDone |
True if initial read has been done. |
Segments are positioned to a specified byte number (or rid that is converted to a byte). Only segments that contain set bit values are actually read, so the position specified is actually a lower bound. Once positioned, the current byte can be read.
Definition at line 41 of file LbmSegmentReader.h.
ExecStreamResult LbmSegmentReader::readSegment | ( | ) | [private] |
Reads a bitmap segment from the input stream.
Definition at line 75 of file LbmSegmentReader.cpp.
References advanceToByte(), LbmSegmentReaderBase::byteSegLen, LbmSegmentReaderBase::byteSegOffset, EXECRC_YIELD, LbmSegment::pSegDescStart, and LbmSegmentReaderBase::readBitmapSegTuple().
Referenced by advanceToByte().
00076 { 00077 ExecStreamResult rc = readBitmapSegTuple(); 00078 if (rc != EXECRC_YIELD) { 00079 return rc; 00080 } 00081 00082 if (pSegDescStart) { 00083 // in the case where the segment contains a descriptor, 00084 // set some initial values to make the first call to advanceToByte() 00085 // read the descriptor and point to the first bitmap in the segment 00086 byteSegLen = 0; 00087 return advanceToByte(byteSegOffset); 00088 } 00089 00090 return EXECRC_YIELD; 00091 }
void LbmSegmentReader::initCommon | ( | ) | [private] |
Common initialization method, called by all other init methods.
Definition at line 70 of file LbmSegmentReader.cpp.
References firstReadDone.
Referenced by init().
00071 { 00072 firstReadDone = false; 00073 }
void LbmSegmentReader::init | ( | SharedExecStreamBufAccessor & | pInAccessorInit, | |
TupleData & | bitmapSegTupleInit | |||
) |
Initializes reader to start reading bit segments from a specified input stream.
pInAccessorInit | input stream accessor | |
bitmapSegTupleInit | tuple data for reading segments |
Reimplemented from LbmSegmentReaderBase.
Definition at line 28 of file LbmSegmentReader.cpp.
Referenced by init(), LbmTupleRidReader::init(), and LbmRidReader::init().
00031 { 00032 init(pInAccessorInit, bitmapSegTuple, false, NULL); 00033 }
void LbmSegmentReader::init | ( | SharedExecStreamBufAccessor & | pInAccessorInit, | |
TupleData & | bitmapSegTupleInit, | |||
bool | setBitmapInit, | |||
boost::dynamic_bitset<> * | pBitmapInit | |||
) |
Initializes reader to start reading bit segments from a specified input stream, optionally keeping track of the bits read.
pInAccessorInit | input stream accessor | |
bitmapSegTupleInit | tuple data for reading segments | |
setBitmapInit | if true, keep track of bits read | |
pBitmapInit | pointer to the bitmap to be set if the setBitmapInit parameter is true |
Reimplemented from LbmSegmentReaderBase.
Definition at line 35 of file LbmSegmentReader.cpp.
References LbmSegmentReaderBase::init(), and initCommon().
00040 { 00041 LbmSegmentReaderBase::init( 00042 pInAccessorInit, 00043 bitmapSegTuple, 00044 setBitmapInit, 00045 pBitmapInit); 00046 initCommon(); 00047 }
void LbmSegmentReader::init | ( | SharedLbmTupleReader & | pTupleReaderInit, | |
TupleData & | bitmapSegTupleInit | |||
) |
Initializes reader to start reading bit segments from a specified tuple reader.
pTupleReaderInit | input tuple reader | |
bitmapSegTupleInit | tuple data for reading segments |
Reimplemented from LbmSegmentReaderBase.
Definition at line 49 of file LbmSegmentReader.cpp.
References init().
00052 { 00053 init(pTupleReaderInit, bitmapSegTuple, false, NULL); 00054 }
void LbmSegmentReader::init | ( | SharedLbmTupleReader & | pTupleReaderInit, | |
TupleData & | bitmapSegTupleInit, | |||
bool | setBitmapInit, | |||
boost::dynamic_bitset<> * | pBitmapInit | |||
) |
Initializes reader to start reading bit segments from a specified tuple reader, optionally keeping track of the bits read.
pTupleReaderInit | input tuple reader | |
bitmapSegTupleInit | tuple data for reading segments | |
setBitmapInit | if true, keep track of bits read | |
pBitmapInit | pointer to the bitmap to be set if the setBitmapInit parameter is true |
Reimplemented from LbmSegmentReaderBase.
Definition at line 56 of file LbmSegmentReader.cpp.
References LbmSegmentReaderBase::init(), and initCommon().
00061 { 00062 LbmSegmentReaderBase::init( 00063 pTupleReaderInit, 00064 bitmapSegTuple, 00065 setBitmapInit, 00066 pBitmapInit); 00067 initCommon(); 00068 }
ExecStreamResult LbmSegmentReader::advanceToRid | ( | LcsRid | rid | ) |
Advances within a segment to at least the specified rid, reading in new segments (as needed) to satisfy the request.
rid | desired rid |
Definition at line 123 of file LbmSegmentReader.cpp.
References advanceToByte(), and ridToByteNumber().
Referenced by LbmRidReaderBase::searchForNextRid().
00124 { 00125 return advanceToByte(ridToByteNumber(rid)); 00126 }
ExecStreamResult LbmSegmentReader::advanceToByte | ( | LbmByteNumber | byteNum | ) |
Advances within a bit segment to at least the specified byte number, reading in new segments (as needed) to satisfy the request.
Reading byte number "x" is equivalent to retrieving rid >= "x * 8".
byteNum | desired byte number |
Definition at line 93 of file LbmSegmentReader.cpp.
References LbmSegmentReaderBase::advanceSegment(), LbmSegmentReaderBase::byteSegLen, LbmSegmentReaderBase::byteSegOffset, EXECRC_YIELD, firstReadDone, opaqueToInt(), LbmSegment::pSegDescEnd, LbmSegment::pSegDescStart, LbmSegment::pSegStart, and readSegment().
Referenced by advanceToRid(), and readSegment().
00094 { 00095 // read byte segments until find a suitable one 00096 while (byteSegOffset + byteSegLen <= byteNum) { 00097 // if current segment is exhausted, read another 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 // advance to the next segment 00108 advanceSegment(); 00109 } 00110 00111 // Found a suitable segment, or were on a suitable one to begin 00112 // with. Move to correct position within segment. 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 }
Reads the current byte segment, based on current position.
startRid | returns rid value corresponding to the start of the current byte segment | |
byteSeg | returns current byte segment; note that the segment read is stored backwards, so the caller needs to read from right to left starting at byteSeg | |
len | returns length of current byte segment |
Definition at line 128 of file LbmSegmentReader.cpp.
References byteNumberToRid(), LbmSegmentReaderBase::byteSegLen, LbmSegmentReaderBase::byteSegOffset, firstReadDone, and LbmSegment::pSegStart.
Referenced by LbmRidReaderBase::searchForNextRid().
00130 { 00131 assert(firstReadDone); 00132 startRid = byteNumberToRid(byteSegOffset); 00133 byteSeg = pSegStart; 00134 len = byteSegLen; 00135 // assumes advanceToByte() has been called to move to a segment 00136 // that has actual bits set, and intermediate zeros have been removed 00137 assert(*byteSeg != 0); 00138 assert(len > 0); 00139 }
ExecStreamResult LbmSegmentReaderBase::readBitmapSegTuple | ( | ) | [protected, inherited] |
Reads a bitmap segment tuple from the input stream and extracts the starting rid, the descriptor, and bitmap fields.
Definition at line 81 of file LbmSegmentReaderBase.cpp.
References LbmSegmentReaderBase::byteSegLen, LbmSegmentReaderBase::byteSegOffset, EXECRC_YIELD, LbmSegmentReaderBase::iSegmentDesc, LbmSegmentReaderBase::iSegments, LbmSegmentReaderBase::iSrid, LbmSegment::LbmOneByteSize, LbmSegmentReaderBase::maxRidSet, opaqueToInt(), LbmSegmentReaderBase::pBitmap, LbmSegmentReaderBase::pBitmapSegTuple, LbmSegment::pSegDescEnd, LbmSegment::pSegDescStart, LbmSegment::pSegStart, LbmSegmentReaderBase::pTupleReader, ridToByteNumber(), LbmSegmentReaderBase::setBitmap, LbmSegmentReaderBase::setBitsRead(), LbmSegmentReaderBase::singleton, LbmSegment::startRID, LbmSegmentReaderBase::tupleChange, and LbmSegmentReaderBase::zeroBytes.
Referenced by readSegment(), and LbmSeqSegmentReader::readSegmentAndAdvance().
00082 { 00083 ExecStreamResult rc = pTupleReader->read(pBitmapSegTuple); 00084 if (rc != EXECRC_YIELD) { 00085 return rc; 00086 } 00087 00088 // extract starting rid and compute its equivalent byte segment number 00089 startRID = *reinterpret_cast<LcsRid const *> 00090 ((*pBitmapSegTuple)[iSrid].pData); 00091 byteSegOffset = ridToByteNumber(startRID); 00092 zeroBytes = 0; 00093 00094 // determine where the segment descriptor starts and ends, if there is 00095 // one 00096 pSegDescStart = (PBuffer) (*pBitmapSegTuple)[iSegmentDesc].pData; 00097 // descriptor can be NULL 00098 if (pSegDescStart != NULL) { 00099 pSegDescEnd = pSegDescStart + (*pBitmapSegTuple)[iSegmentDesc].cbData; 00100 } else { 00101 pSegDescEnd = NULL; 00102 } 00103 00104 // determine where the bitmap segment starts and its length 00105 if ((*pBitmapSegTuple)[iSegments].pData) { 00106 // note that bit segment is stored backwards 00107 byteSegLen = (*pBitmapSegTuple)[iSegments].cbData; 00108 pSegStart = (PBuffer) 00109 ((*pBitmapSegTuple)[iSegments].pData + byteSegLen - 1); 00110 } else { 00111 // singletons do not have a corresponding bitmap, so create one 00112 byteSegLen = 1; 00113 pSegStart = &singleton; 00114 singleton = (uint8_t)(1 << (opaqueToInt(startRID) % LbmOneByteSize)); 00115 if (setBitmap) { 00116 pBitmap->set(opaqueToInt(startRID % pBitmap->size())); 00117 if (startRID > maxRidSet) { 00118 maxRidSet = startRID; 00119 } 00120 } 00121 } 00122 00123 if (!pSegDescStart) { 00124 // For bitmaps without a descriptor, set the bits in the segment. 00125 // Bitmaps with descriptors will be handled as we advance through 00126 // each segment within the bitmap. 00127 setBitsRead(startRID, pSegStart, byteSegLen); 00128 } 00129 00130 tupleChange = true; 00131 return EXECRC_YIELD; 00132 }
void LbmSegmentReaderBase::advanceSegment | ( | ) | [protected, inherited] |
Advances byte segment offset and segment descriptor pointers to the next segment in a bitmap segment.
Definition at line 160 of file LbmSegmentReaderBase.cpp.
References byteNumberToRid(), LbmSegmentReaderBase::byteSegLen, LbmSegmentReaderBase::byteSegOffset, LbmSegment::pSegDescStart, LbmSegment::pSegStart, LbmSegment::readSegDescAndAdvance(), LbmSegmentReaderBase::setBitsRead(), and LbmSegmentReaderBase::zeroBytes.
Referenced by advanceToByte(), and LbmSeqSegmentReader::readSegmentAndAdvance().
00161 { 00162 // first, advance byte segment offset and segment pointer by the 00163 // length of the remaining part of the previous segment and the 00164 // trailing zero bytes 00165 byteSegOffset += byteSegLen + zeroBytes; 00166 pSegStart -= byteSegLen; 00167 00168 // then, read the segment descriptor to determine where the segment 00169 // starts and its length; also advance the segment descriptor to the 00170 // next descriptor 00171 readSegDescAndAdvance(pSegDescStart, byteSegLen, zeroBytes); 00172 00173 // keep track of the bits in the segment that we just advanced to 00174 setBitsRead(byteNumberToRid(byteSegOffset), pSegStart, byteSegLen); 00175 }
bool LbmSegmentReaderBase::getTupleChange | ( | ) | [inherited] |
Reports whether a new tuple was read.
Initially, this attribute is false. It is updated to true whenever a new tuple is read. The atribute is manually restored to false by calling resetChangeListener(). Otherwise, it will be stuck at true.
Definition at line 177 of file LbmSegmentReaderBase.cpp.
References LbmSegmentReaderBase::tupleChange.
Referenced by LbmNormalizerExecStream::produceTuple(), and LbmMinusExecStream::readMinuendInputAndFlush().
00178 { 00179 return tupleChange; 00180 }
void LbmSegmentReaderBase::resetChangeListener | ( | ) | [inherited] |
Resets the tuple change attribute to false.
Definition at line 182 of file LbmSegmentReaderBase.cpp.
References LbmSegmentReaderBase::tupleChange.
Referenced by LbmNormalizerExecStream::produceTuple(), and LbmMinusExecStream::readMinuendInputAndFlush().
00183 { 00184 tupleChange = false; 00185 }
LcsRid LbmSegmentReaderBase::getMaxRidSet | ( | ) | [inherited] |
Retrieves the maximum rid that has been read by this reader since it was initialized, provided the reader has been set to keep track of rids read.
Definition at line 187 of file LbmSegmentReaderBase.cpp.
References LbmSegmentReaderBase::maxRidSet.
00188 { 00189 return maxRidSet; 00190 }
Get value stored in a byte array.
The least significant bytes in the value is stored at the first location in the array.
array | a byte array | |
arraySize | size of the array(number of bytes) |
Definition at line 27 of file LbmSegment.cpp.
References LbmSegment::LbmOneByteSize.
Referenced by LbmEntry::adjustEntry(), LbmEntry::getCompressedRowCount(), and LbmSegment::readSegDescAndAdvance().
00028 { 00029 uint value = 0; 00030 while (arraySize > 0) { 00031 value = value * (uint)(1 << LbmOneByteSize) + array[arraySize - 1]; 00032 arraySize --; 00033 } 00034 return value; 00035 }
uint LbmSegment::value2ByteArray | ( | uint | value, | |
PBuffer | array, | |||
uint | arraySize | |||
) | [static, protected, inherited] |
Store value in a byte array.
The least significant bytes in the value is stored at the first location in the array.
value | ||
array | a byte array | |
arraySize | size of the array(number of bytes) |
Definition at line 38 of file LbmSegment.cpp.
References LbmSegment::LbmOneByteSize.
Referenced by LbmEntry::setZeroLength().
00039 { 00040 assert(value != 0); 00041 00042 uint size = 0; 00043 00044 while (value > 0 && size < arraySize) { 00045 array[size] = (uint8_t)(value & 0xff); 00046 value = value >> LbmOneByteSize; 00047 size ++; 00048 } 00049 /* 00050 * If value is non-zero, it means that the value cannot be encoded 00051 * within an array of arraySize. Return 0 in that case. 00052 */ 00053 if (value > 0) { 00054 size = 0; 00055 } 00056 00057 return size; 00058 }
Computes the number of bytes required to store a specified number of zero bytes.
nZeroBytes | the number of zero bytes to be stored |
Definition at line 60 of file LbmSegment.cpp.
References LbmSegment::LbmOneByteSize, and LbmSegment::LbmZeroLengthCompact.
Referenced by LbmEntry::addNewAdjacentSegment(), LbmEntry::addNewMiddleSegment(), and LbmSegment::computeSegDescLength().
00061 { 00062 if (nZeroBytes <= LbmZeroLengthCompact) { 00063 return 0; 00064 } 00065 00066 uint size = 0; 00067 while (nZeroBytes > 0) { 00068 nZeroBytes = nZeroBytes >> LbmOneByteSize; 00069 size++; 00070 } 00071 00072 return size; 00073 }
void LbmSegment::readSegDescAndAdvance | ( | PBuffer & | pSegDesc, | |
uint & | bmSegLen, | |||
uint & | zeroBytes | |||
) | [static, protected, inherited] |
Decodes the lengths stored in the descriptor for a segment, based on where the segment descriptor is currently pointing, and advances the segment descriptor to the next descriptor.
pSegDesc | pointer to segment descriptor | |
bmSegLen | returns length of bitmap segment | |
zeroBytes | returns number of trailing zeros in this segment |
Definition at line 75 of file LbmSegment.cpp.
References LbmSegment::byteArray2Value(), LbmSegment::LbmHalfByteSize, LbmSegment::LbmZeroLengthCompact, and LbmSegment::LbmZeroLengthMask.
Referenced by LbmSegmentReaderBase::advanceSegment(), LbmSegment::computeSegDescLength(), LbmSegment::computeSegLength(), LbmEntry::containsRid(), LbmSegment::countSegments(), LbmEntry::dumpSeg(), LbmEntry::dumpSegRID(), LbmEntry::generateSegRIDs(), LbmEntry::spliceSingleton(), and LbmEntry::splitEntry().
00077 { 00078 // should only be called in the case where the bit segment has 00079 // a descriptor 00080 assert(pSegDesc != NULL); 00081 bmSegLen = (*pSegDesc >> LbmHalfByteSize) + 1; 00082 uint zeroLen = (*pSegDesc & LbmZeroLengthMask); 00083 00084 // advance past the initial length byte 00085 pSegDesc++; 00086 00087 if (zeroLen <= LbmZeroLengthCompact) { 00088 zeroBytes = zeroLen; 00089 } else { 00090 zeroBytes = 00091 byteArray2Value(pSegDesc, zeroLen - LbmZeroLengthCompact); 00092 pSegDesc += zeroLen - LbmZeroLengthCompact; 00093 } 00094 }
Computes the length of the remaining segments in the current bitmap segment, starting at the one specified by the input segment descriptor.
segDesc | segment descriptor of the first segment that we want to start computing the length from |
Definition at line 110 of file LbmSegment.cpp.
References LbmSegment::pSegDescEnd, and LbmSegment::readSegDescAndAdvance().
Referenced by LbmEntry::addNewAdjacentSegment(), and LbmEntry::addNewMiddleSegment().
00111 { 00112 uint segLength = 0; 00113 00114 while (segDesc < pSegDescEnd) { 00115 uint segBytes; 00116 uint zeroBytes; 00117 readSegDescAndAdvance(segDesc, segBytes, zeroBytes); 00118 segLength += segBytes; 00119 } 00120 00121 return segLength; 00122 }
Computes the length of the remaining segment descriptors in the current bitmap segment, starting at the one specified by the input segment descriptor.
segDesc | segment descriptor of the first segment that we want to start computing the length from |
Definition at line 96 of file LbmSegment.cpp.
References LbmSegment::computeSpaceForZeroBytes(), LbmSegment::pSegDescEnd, and LbmSegment::readSegDescAndAdvance().
Referenced by LbmEntry::addNewAdjacentSegment(), and LbmEntry::addNewMiddleSegment().
00097 { 00098 uint segDescLength = 0; 00099 00100 while (segDesc < pSegDescEnd) { 00101 uint segBytes; 00102 uint zeroBytes; 00103 readSegDescAndAdvance(segDesc, segBytes, zeroBytes); 00104 segDescLength += computeSpaceForZeroBytes(zeroBytes) + 1; 00105 } 00106 00107 return segDescLength; 00108 }
uint LbmSegment::countSegments | ( | ) | [protected, inherited] |
Returns the number of segments in an entry.
Definition at line 124 of file LbmSegment.cpp.
References count(), LbmSegment::pSegDescEnd, LbmSegment::pSegDescStart, and LbmSegment::readSegDescAndAdvance().
Referenced by LbmEntry::splitEntry().
00125 { 00126 uint count = 0; 00127 00128 PBuffer segDesc = pSegDescStart; 00129 while (segDesc < pSegDescEnd) { 00130 uint segBytes; 00131 uint zeroBytes; 00132 readSegDescAndAdvance(segDesc, segBytes, zeroBytes); 00133 count++; 00134 } 00135 00136 return count; 00137 }
LcsRid LbmSegment::roundToByteBoundary | ( | LcsRid | rid | ) | [inline, static, inherited] |
Rounds a rid value down to the nearest byte boundary.
rid | value to be rounded |
Definition at line 241 of file LbmSegment.h.
References LbmSegment::LbmOneByteSizeBitMask, and opaqueToInt().
Referenced by LbmRidReaderBase::advanceToRid(), LbmEntry::closeCurrentSegment(), LbmEntryTest::compareExpected(), LbmSplicerExecStream::findBetterEntry(), LbmSplicerExecStream::findBTreeEntry(), LbmEntry::mergeEntry(), LbmEntry::openNewSegment(), LbmSplicerExecStream::ridOverlaps(), LbmRidReaderBase::searchForNextRid(), LbmEntry::setRIDAdjacentSegByte(), LbmEntry::singleton2Bitmap(), LbmEntryTest::testldb35(), and LbmEntryTest::testZeroBytes().
00242 { 00243 return LcsRid(opaqueToInt(rid) & LbmOneByteSizeBitMask); 00244 }
Sets the length descriptor for a new segment with zero trailing zeros.
segDescByte | byte that will be set with the segment length | |
segLen | length of the segment |
Definition at line 246 of file LbmSegment.h.
References LbmSegment::LbmHalfByteSize, and LbmSegment::LbmMaxSegSize.
Referenced by LbmEntry::addNewMiddleSegment(), LbmEntry::addSegDesc(), LbmSegmentWriter::addSegment(), LbmEntry::closeCurrentSegment(), LbmEntry::openLastSegment(), LbmEntry::openNewSegment(), and LbmEntry::setRIDAdjacentSegByte().
00247 { 00248 if (segLen > LbmMaxSegSize) { 00249 return false; 00250 } 00251 segDescByte = (uint8_t) ((segLen - 1) << LbmHalfByteSize); 00252 return true; 00253 }
Set segment length in an existing descriptor with the new segment length.
Also, leaves the current zero trailing bytes count untouched
segDescByte | segment descriptor byte to be modified | |
segLen | new segment length |
Definition at line 255 of file LbmSegment.h.
References LbmSegment::LbmHalfByteSize, LbmSegment::LbmMaxSegSize, and LbmSegment::LbmSegLengthMask.
Referenced by LbmEntry::addNewAdjacentSegment().
00256 { 00257 if (segLen > LbmMaxSegSize) { 00258 return false; 00259 } 00260 segDescByte &= ~LbmSegLengthMask; 00261 segDescByte |= (uint8_t) ((segLen - 1) << LbmHalfByteSize); 00262 return true; 00263 }
Get the segment length encoded in SegmentDescriptor.
segDescByte | the seg desc byte with segment length encoded. |
Definition at line 265 of file LbmSegment.h.
References LbmSegment::LbmHalfByteSize, and LbmSegment::LbmSegLengthMask.
Referenced by LbmEntry::addNewAdjacentSegment(), LbmEntry::getCompressedRowCount(), and LbmEntry::openLastSegment().
00266 { 00267 return (((segDescByte & LbmSegLengthMask) >> LbmHalfByteSize) + 1); 00268 }
Get the number of bytes to store the length of zero bytes.
segDescByte | the seg desc byte with length of zero bytes encoded. |
Definition at line 270 of file LbmSegment.h.
References LbmSegment::LbmZeroLengthCompact, and LbmSegment::LbmZeroLengthMask.
Referenced by LbmEntry::openLastSegment(), and LbmEntry::splitEntry().
00271 { 00272 uint lengthBytes = segDescByte & LbmZeroLengthMask; 00273 if (lengthBytes > LbmZeroLengthCompact) { 00274 return (lengthBytes - LbmZeroLengthCompact); 00275 } else { 00276 return 0; 00277 } 00278 }
LcsRid LbmSegment::getStartRID | ( | ) | [inline, inherited] |
Definition at line 280 of file LbmSegment.h.
References LbmSegment::startRID.
00281 { 00282 return startRID; 00283 }
bool LbmSegmentReader::firstReadDone [private] |
True if initial read has been done.
Definition at line 47 of file LbmSegmentReader.h.
Referenced by advanceToByte(), initCommon(), and readCurrentByteSegment().
SharedLbmTupleReader LbmSegmentReaderBase::pTupleReader [protected, inherited] |
Input tuple reader.
Definition at line 47 of file LbmSegmentReaderBase.h.
Referenced by LbmSegmentReaderBase::init(), and LbmSegmentReaderBase::readBitmapSegTuple().
uint LbmSegmentReaderBase::byteSegLen [protected, inherited] |
Length of the current byte segment.
Definition at line 52 of file LbmSegmentReaderBase.h.
Referenced by LbmSegmentReaderBase::advanceSegment(), advanceToByte(), LbmSegmentReaderBase::init(), LbmSegmentReaderBase::readBitmapSegTuple(), readCurrentByteSegment(), readSegment(), and LbmSeqSegmentReader::readSegmentAndAdvance().
LbmByteNumber LbmSegmentReaderBase::byteSegOffset [protected, inherited] |
Byte offset representing current position in segment.
Definition at line 57 of file LbmSegmentReaderBase.h.
Referenced by LbmSegmentReaderBase::advanceSegment(), advanceToByte(), LbmSegmentReaderBase::init(), LbmSegmentReaderBase::readBitmapSegTuple(), readCurrentByteSegment(), readSegment(), and LbmSeqSegmentReader::readSegmentAndAdvance().
TupleData* LbmSegmentReaderBase::pBitmapSegTuple [protected, inherited] |
Pointer to tuple data containing input bitmap segment.
Definition at line 62 of file LbmSegmentReaderBase.h.
Referenced by LbmSegmentReaderBase::init(), and LbmSegmentReaderBase::readBitmapSegTuple().
uint LbmSegmentReaderBase::iSrid [protected, inherited] |
Index of the bitmap columns.
Definition at line 67 of file LbmSegmentReaderBase.h.
Referenced by LbmSegmentReaderBase::init(), and LbmSegmentReaderBase::readBitmapSegTuple().
uint LbmSegmentReaderBase::iSegmentDesc [protected, inherited] |
Definition at line 68 of file LbmSegmentReaderBase.h.
Referenced by LbmSegmentReaderBase::init(), and LbmSegmentReaderBase::readBitmapSegTuple().
uint LbmSegmentReaderBase::iSegments [protected, inherited] |
Definition at line 69 of file LbmSegmentReaderBase.h.
Referenced by LbmSegmentReaderBase::init(), and LbmSegmentReaderBase::readBitmapSegTuple().
uint LbmSegmentReaderBase::zeroBytes [protected, inherited] |
Number of trailing zero bytes in the current segment.
Definition at line 74 of file LbmSegmentReaderBase.h.
Referenced by LbmSegmentReaderBase::advanceSegment(), LbmSegmentReaderBase::init(), and LbmSegmentReaderBase::readBitmapSegTuple().
uint8_t LbmSegmentReaderBase::singleton [protected, inherited] |
Used to construct singleton bitmap.
Definition at line 79 of file LbmSegmentReaderBase.h.
Referenced by LbmSegmentReaderBase::readBitmapSegTuple().
bool LbmSegmentReaderBase::tupleChange [protected, inherited] |
Detects when a new tuple is read.
Definition at line 84 of file LbmSegmentReaderBase.h.
Referenced by LbmSegmentReaderBase::getTupleChange(), LbmSegmentReaderBase::init(), LbmSegmentReaderBase::readBitmapSegTuple(), and LbmSegmentReaderBase::resetChangeListener().
LcsRid LbmSegment::startRID [protected, inherited] |
Starting rid in the bitmap segment (if singleton, startRID == RID column in entryTuple).
Definition at line 42 of file LbmSegment.h.
Referenced by LbmEntry::adjustEntry(), LbmEntry::containsRid(), LbmSeqSegmentReader::getSrid(), LbmSegment::getStartRID(), LbmEntry::growEntry(), LbmEntry::inRange(), LbmEntry::mergeEntry(), LbmEntry::mergeIntoSplitEntry(), LbmEntry::openLastSegment(), LbmEntry::produceEntryTuple(), LbmSegmentReaderBase::readBitmapSegTuple(), LbmEntry::setEntryTuple(), LbmEntry::singleton2Bitmap(), LbmEntry::spliceSingleton(), and LbmEntry::splitEntry().
PBuffer LbmSegment::pSegDescStart [protected, inherited] |
Increment forward from pSegDescStart.
Definition at line 47 of file LbmSegment.h.
Referenced by LbmSegmentReaderBase::advanceSegment(), advanceToByte(), LbmEntry::containsRid(), LbmSegment::countSegments(), LbmEntry::getRowCount(), LbmSegmentReaderBase::init(), LbmEntry::isSingleBitmap(), LbmEntry::LbmEntry(), LbmEntry::mergeIntoSplitEntry(), LbmEntry::produceEntryTuple(), LbmSegmentReaderBase::readBitmapSegTuple(), readSegment(), LbmSeqSegmentReader::readSegmentAndAdvance(), LbmEntry::setEntryTuple(), LbmEntry::singleton2Bitmap(), LbmEntry::spliceSingleton(), LbmEntry::splitEntry(), and LbmEntry::toString().
PBuffer LbmSegment::pSegDescEnd [protected, inherited] |
Definition at line 48 of file LbmSegment.h.
Referenced by LbmEntry::addNewAdjacentSegment(), LbmEntry::addNewMiddleSegment(), LbmEntry::addSegDesc(), advanceToByte(), LbmEntry::closeCurrentSegment(), LbmSegment::computeSegDescLength(), LbmSegment::computeSegLength(), LbmEntry::containsRid(), LbmEntry::copyToMergeBuffer(), LbmSegment::countSegments(), LbmEntry::getRowCount(), LbmSegmentReaderBase::init(), LbmEntry::mergeEntry(), LbmEntry::mergeIntoSplitEntry(), LbmEntry::openLastSegment(), LbmEntry::openNewSegment(), LbmEntry::produceEntryTuple(), LbmSegmentReaderBase::readBitmapSegTuple(), LbmSeqSegmentReader::readSegmentAndAdvance(), LbmEntry::setEntryTuple(), LbmEntry::spliceSingleton(), LbmEntry::splitEntry(), and LbmEntry::toString().
PBuffer LbmSegment::pSegStart [protected, inherited] |
Decrement backward from pSegStart.
Definition at line 53 of file LbmSegment.h.
Referenced by LbmEntry::adjustEntry(), LbmSegmentReaderBase::advanceSegment(), advanceToByte(), LbmEntry::containsRid(), LbmSegmentReaderBase::init(), LbmEntry::isSingleton(), LbmEntry::LbmEntry(), LbmEntry::mergeEntry(), LbmEntry::mergeIntoSplitEntry(), LbmEntry::openNewSegment(), LbmEntry::produceEntryTuple(), LbmSegmentReaderBase::readBitmapSegTuple(), readCurrentByteSegment(), LbmSeqSegmentReader::readSegmentAndAdvance(), LbmEntry::setEntryTuple(), LbmEntry::setRIDAdjacentSegByte(), LbmEntry::spliceSingleton(), LbmEntry::splitEntry(), and LbmEntry::toString().
PBuffer LbmSegment::pSegEnd [protected, inherited] |
Definition at line 54 of file LbmSegment.h.
Referenced by LbmEntry::addNewRid(), LbmEntry::adjustEntry(), LbmEntry::containsRid(), LbmEntry::copyToMergeBuffer(), LbmEntry::isSingleton(), LbmEntry::mergeEntry(), LbmEntry::mergeIntoSplitEntry(), LbmEntry::openLastSegment(), LbmEntry::openNewSegment(), LbmEntry::produceEntryTuple(), LbmEntry::setEntryTuple(), LbmEntry::setRIDAdjacentSegByte(), LbmEntry::splitEntry(), and LbmEntry::toString().
const uint LbmSegment::LbmHalfByteSize = 4 [static, protected, inherited] |
Use half of a byte to encode the segment length, or the zero bytes length.
Definition at line 60 of file LbmSegment.h.
Referenced by LbmEntry::adjustEntry(), LbmSegment::adjustSegLength(), LbmSegment::getSegLength(), LbmSegment::readSegDescAndAdvance(), and LbmSegment::setSegLength().
const uint8_t LbmSegment::LbmSegLengthMask = 0xf0 [static, protected, inherited] |
The upper 4 bits of Segment Descriptor byte is used to store the length of the corresponding segment.
Definition at line 66 of file LbmSegment.h.
Referenced by LbmSegment::adjustSegLength(), and LbmSegment::getSegLength().
const uint8_t LbmSegment::LbmZeroLengthMask = 0x0f [static, protected, inherited] |
The lower 4 bits of Segment Descriptor byte is used to store the length of the "gap" following the corresponding segment(till the next segment or the next LbmEntry).
Definition at line 73 of file LbmSegment.h.
Referenced by LbmEntry::addNewAdjacentSegment(), LbmEntry::adjustEntry(), LbmEntry::getCompressedRowCount(), LbmSegment::getZeroLengthByteCount(), LbmSegment::readSegDescAndAdvance(), LbmEntry::setZeroLength(), and LbmEntry::splitEntry().
const uint LbmSegment::LbmZeroLengthCompact = 12 [static, protected, inherited] |
If the length of zero bytes(a byte composed of 8 bits of 0s) is less than 12, the length can be stored within the segment descriptor.
Otherwise, the segment descriptor gives the length of additional bytes(maximumn is 3 bytes) in which the length is stored.
Definition at line 81 of file LbmSegment.h.
Referenced by LbmEntry::adjustEntry(), LbmSegment::computeSpaceForZeroBytes(), LbmEntry::getCompressedRowCount(), LbmSegment::getZeroLengthByteCount(), LbmSegment::readSegDescAndAdvance(), and LbmEntry::setZeroLength().
const uint LbmSegment::LbmZeroLengthExtended [static, protected, inherited] |
Initial value:
Additional bytes(maximumn is 3 bytes) in which the length is stored.It is stored with an offset of LbmZeroLengthCompact. LbmZeroLengthExtended = (uint)LbmZeroLengthMask - LbmZeroLengthCompact.
Definition at line 88 of file LbmSegment.h.
Referenced by LbmEntry::getScratchBufferSize(), LbmEntry::init(), and LbmEntry::setZeroLength().
const uint LbmSegment::LbmMaxSegSize = 16 [static, protected, inherited] |
Maximum size(in bytes) for a bitmap segment.
This size is limited by the number of bits(=4 bits) in SegDesc to describe the segment length.
Definition at line 95 of file LbmSegment.h.
Referenced by LbmEntry::addSegDesc(), LbmSegment::adjustSegLength(), LbmEntry::closeCurrentSegment(), LbmEntry::getMaxBitmapSize(), LbmEntry::getMergeSpaceRequired(), LbmEntry::setRIDAdjacentSegByte(), and LbmSegment::setSegLength().
const uint LbmSegment::LbmOneByteSize = 8 [static, inherited] |
One byte in the bitmap encodes 8 RIDs.
Definition at line 235 of file LbmSegment.h.
Referenced by LbmEntry::addNewAdjacentSegment(), LbmEntry::addNewMiddleSegment(), LbmEntry::addNewRid(), LbmEntry::addNewSegment(), LbmSegmentWriter::addSegment(), LbmEntry::adjustEntry(), LbmRidReaderBase::advanceToRid(), LbmSegment::byteArray2Value(), LbmMinusExecStream::canSkipMinus(), LbmEntry::closeCurrentSegment(), LbmUnionExecStream::computeRidLimit(), LbmSegment::computeSpaceForZeroBytes(), LbmEntry::containsRid(), LbmEntry::dumpSegRID(), LbmMinusExecStream::execute(), LbmSplicerExecStream::findBetterEntry(), LbmEntryTest::generateBitmaps(), LbmEntryTest::generateCompressedBitmaps(), LbmEntry::generateSegRIDs(), LbmEntryTest::generateSingleBitmaps(), LbmEntry::getCompressedRowCount(), LbmEntry::getRowCount(), LbmIntersectExecStream::intersectSegments(), LbmMinusExecStream::minusSegments(), LbmEntry::openLastSegment(), LbmSegmentReaderBase::readBitmapSegTuple(), LbmSplicerExecStream::ridOverlaps(), LbmRidReaderBase::searchForNextRid(), LbmEntry::segmentContainsRid(), LbmSegmentReaderBase::setBitsRead(), LbmEntry::setEntryTuple(), LbmEntry::setRID(), LbmEntry::setRIDAdjacentSegByte(), LbmEntry::setRIDSegByte(), LbmEntry::spliceSingleton(), LbmEntry::splitEntry(), LbmEntryTest::testldb35(), LbmEntryTest::testler5920(), LbmEntryTest::testZeroBytes(), and LbmSegment::value2ByteArray().
const uint LbmSegment::LbmOneByteSizeBitShift = 3 [static, inherited] |
Definition at line 236 of file LbmSegment.h.
Referenced by byteNumberToRid(), and ridToByteNumber().
const LcsRidPrimitive LbmSegment::LbmOneByteSizeBitMask [static, inherited] |
Initial value:
0xfffffffffffffff8ULL
Definition at line 237 of file LbmSegment.h.
Referenced by LbmSegment::roundToByteBoundary().