#include <LbmRidReader.h>
Public Member Functions | |
~LbmDeletionIndexReader () | |
void | init (SharedBTreeReader &btreeReader, TupleData &bitmapSegTuple) |
Initializes reader to search for RIDs stored in a btree specified BTreeReader. | |
void | endSearch () |
Releases any locks held. | |
bool | isEmpty () |
Determines whether the deletion index is empty. | |
bool | searchForRid (LcsRid rid) |
Searches for a RID in the btree. | |
Private Member Functions | |
void | initRidReader () |
Reinitializes the internal rid reader. | |
Private Attributes | |
SharedBTreeReader | btreeReader |
Deletion index btree reader. | |
TupleData * | pBitmapSegTuple |
Pointer to tuple data containing a btree bitmap segment. | |
TupleData | searchEntry |
TupleData for searching btree. | |
bool | currTuple |
Whether a tuple is currently being searched. | |
LbmTupleRidReader | ridReader |
Reads rids from a tuple sequentially. | |
LcsRid | btreeRid |
The last rid read. | |
bool | emptyIndex |
True if the deletion index is empty. | |
bool | emptyIndexUnknown |
True if it is not known whether the deletion index is empty. |
Definition at line 229 of file LbmRidReader.h.
LbmDeletionIndexReader::~LbmDeletionIndexReader | ( | ) |
Definition at line 205 of file LbmRidReader.cpp.
References endSearch().
00206 { 00207 endSearch(); 00208 }
void LbmDeletionIndexReader::initRidReader | ( | ) | [private] |
Reinitializes the internal rid reader.
Should be called whenever a new tuple is read or to restart a read on the current tuple.
Definition at line 225 of file LbmRidReader.cpp.
References btreeRid, currTuple, LbmIterableRidReader::getNext(), LbmTupleRidReader::init(), pBitmapSegTuple, and ridReader.
Referenced by searchForRid().
00226 { 00227 currTuple = true; 00228 ridReader.init(*pBitmapSegTuple); 00229 btreeRid = ridReader.getNext(); 00230 }
void LbmDeletionIndexReader::init | ( | SharedBTreeReader & | btreeReader, | |
TupleData & | bitmapSegTuple | |||
) |
Initializes reader to search for RIDs stored in a btree specified BTreeReader.
btreeReader | input btree reader | |
bitmapSegTuple | tuple data for reading segments |
Definition at line 210 of file LbmRidReader.cpp.
References btreeReader, TupleData::compute(), currTuple, emptyIndexUnknown, pBitmapSegTuple, and searchEntry.
Referenced by LbmSplicerExecStream::open().
00213 { 00214 // the btree must be a deletion index 00215 assert(btreeReaderInit->getTupleDescriptor().size() == 3); 00216 assert(bitmapSegTuple.size() == 3); 00217 00218 btreeReader = btreeReaderInit; 00219 pBitmapSegTuple = &bitmapSegTuple; 00220 searchEntry.compute(btreeReader->getKeyDescriptor()); 00221 emptyIndexUnknown = true; 00222 currTuple = false; 00223 }
void LbmDeletionIndexReader::endSearch | ( | ) |
Releases any locks held.
Definition at line 232 of file LbmRidReader.cpp.
References btreeReader.
Referenced by LbmSplicerExecStream::closeImpl(), and ~LbmDeletionIndexReader().
00233 { 00234 if (btreeReader) { 00235 btreeReader->endSearch(); 00236 } 00237 }
bool LbmDeletionIndexReader::isEmpty | ( | ) |
Determines whether the deletion index is empty.
Definition at line 239 of file LbmRidReader.cpp.
References btreeReader, emptyIndex, and emptyIndexUnknown.
Referenced by searchForRid().
00240 { 00241 if (emptyIndexUnknown) { 00242 emptyIndex = !btreeReader->searchFirst(); 00243 emptyIndexUnknown = false; 00244 } 00245 return emptyIndex; 00246 }
bool LbmDeletionIndexReader::searchForRid | ( | LcsRid | rid | ) |
Searches for a RID in the btree.
rid | the RID to search for |
Definition at line 248 of file LbmRidReader.cpp.
References btreeReader, btreeRid, currTuple, DUP_SEEK_BEGIN, LbmIterableRidReader::getNext(), LbmEntry::getStartRid(), LbmIterableRidReader::hasNext(), initRidReader(), isEmpty(), pBitmapSegTuple, ridReader, and searchEntry.
Referenced by LbmSplicerExecStream::countKeyRows(), and LbmSplicerExecStream::getValidatedTuple().
00249 { 00250 if (isEmpty()) { 00251 return false; 00252 } 00253 00254 LcsRid prevSrid = LcsRid(0); 00255 if (currTuple) { 00256 prevSrid = LbmEntry::getStartRid(*pBitmapSegTuple); 00257 } 00258 00259 searchEntry[0].pData = reinterpret_cast<PConstBuffer>(&rid); 00260 btreeReader->searchForKey(searchEntry, DUP_SEEK_BEGIN, false); 00261 btreeReader->getTupleAccessorForRead().unmarshal(*pBitmapSegTuple); 00262 LcsRid foundSrid = LbmEntry::getStartRid(*pBitmapSegTuple); 00263 00264 // determine whether the tuple rid reader must be restarted. it should 00265 // be restarted if the tuple has changed or if the rid we are searching 00266 // for would be positioned before the last rid read. 00267 bool sameTuple = (currTuple && prevSrid == foundSrid); 00268 if (!sameTuple || (rid < btreeRid)) { 00269 initRidReader(); 00270 } 00271 00272 // advance within a tuple to search for the rid 00273 while (btreeRid < rid) { 00274 if (ridReader.hasNext()) { 00275 btreeRid = ridReader.getNext(); 00276 } else { 00277 break; 00278 } 00279 } 00280 return (btreeRid == rid); 00281 }
Deletion index btree reader.
Definition at line 234 of file LbmRidReader.h.
Referenced by endSearch(), init(), isEmpty(), and searchForRid().
TupleData* LbmDeletionIndexReader::pBitmapSegTuple [private] |
Pointer to tuple data containing a btree bitmap segment.
Definition at line 239 of file LbmRidReader.h.
Referenced by init(), initRidReader(), and searchForRid().
TupleData LbmDeletionIndexReader::searchEntry [private] |
TupleData for searching btree.
Definition at line 244 of file LbmRidReader.h.
Referenced by init(), and searchForRid().
bool LbmDeletionIndexReader::currTuple [private] |
Whether a tuple is currently being searched.
Definition at line 249 of file LbmRidReader.h.
Referenced by init(), initRidReader(), and searchForRid().
Reads rids from a tuple sequentially.
Definition at line 254 of file LbmRidReader.h.
Referenced by initRidReader(), and searchForRid().
LcsRid LbmDeletionIndexReader::btreeRid [private] |
The last rid read.
Definition at line 259 of file LbmRidReader.h.
Referenced by initRidReader(), and searchForRid().
bool LbmDeletionIndexReader::emptyIndex [private] |
True if the deletion index is empty.
Definition at line 264 of file LbmRidReader.h.
Referenced by isEmpty().
bool LbmDeletionIndexReader::emptyIndexUnknown [private] |
True if it is not known whether the deletion index is empty.
Definition at line 269 of file LbmRidReader.h.