Fennel: LcsClusterReader Class Reference (original) (raw)

Reads blocks from a single cluster. More...

#include <[LcsClusterReader.h](LcsClusterReader%5F8h-source.html)>

Inheritance diagram for LcsClusterReader:

List of all members.

Public Member Functions
LcsClusterReader (BTreeDescriptor const &treeDescriptor, CircularBuffer< LcsRidRun > *pRidRuns=NULL)
Constructor.
virtual ~LcsClusterReader ()
void setRootPageId (PageId rootPageId)
Sets the root pageId of the underlying btree corresponding to the cluster.
void initColumnReaders (uint nClusterColsInit, TupleProjection const &clusterProj)
Initializes cluster reader with column readers.
void open ()
Initializes state variables used by cluster reader.
void close ()
Performs shutdown on cluster reader.
bool getFirstClusterPageForRead (PConstLcsClusterNode &pBlock)
Gets first page in a cluster.
bool getNextClusterPageForRead (PConstLcsClusterNode &pBlock)
Gets next page in a cluster, based on current position in btree.
bool isPositioned () const
Returns true if positioned within some range in a batch.
LcsRid getRangeStartRid () const
Returns first rid in a range.
LcsRid getRangeEndRid () const
Returns first rid after the end of the current range.
uint getRangeSize () const
Returns number of rids in the range.
uint getRangePos () const
Returns offset within the current range.
LcsRid getCurrentRid () const
Returns rid currently positioned at.
uint getRangeRowsLeft () const
Returns number of rids yet to be read.
bool position (LcsRid rid)
Positions scan on the rid, moving to a new range if necessary.
bool nextRange ()
Positions scan on the first rid of the next range.
bool advance (uint nRids)
Moves "nRids" forward in the current range.
void advanceWithinBatch (uint nRids)
Advances nRids forward in the current batch.
virtual PageId getNextPageForPrefetch (LcsRid &rid, bool &found)
Determines the next page to be pre-fetched based on the rids that need to be read.
void catchUp (uint parentBufPos, LcsRid parentNextRid)
Resynchronizes the cluster reader's prefetch position to that of the parent scan.
RecordNum getNumRows ()
**Returns:**the number of rows in the cluster
uint getNumClusterCols ()
Returns number of columns in cluster.
void setNumClusterCols (uint nCols)
Sets number of columns in cluster.
void unlockClusterPage ()
Unlocks cluster page.
virtual void initPrefetchEntry (LcsRid &entry)
Initializes a specific entry in the pre-fetch queue.
Static Public Member Functions
static LcsRid getFetchRids (CircularBufferIter< LcsRidRun > &ridRunIter, LcsRid &nextRid, bool remove)
Retrieves the current and next rids that need to be read, based on the current rid run being processed.
Public Attributes
uint nColsToRead
Number of cluster columns that will be read.
boost::scoped_array< LcsColumnReader > clusterCols
Column readers for each cluster column that will be read.
Protected Member Functions
LcsRid readRid ()
Returns RID from btree tuple.
PageId readClusterPageId ()
Returns cluster pageid from btree tuple.
void setHdrOffsets (PConstLcsClusterNode pHdr)
Sets pointers to offset arrays in cluster page header.
Protected Attributes
TupleData bTreeTupleData
Tuple data representing the btree key corresponding to the cluster page.
SegmentAccessor segmentAccessor
Accessor for segment storing both btree and cluster pages.
ClusterPageLock clusterLock
Buffer lock for the actual cluster node pages.
PageId clusterPageId
Current cluster pageid.
LcsRid bTreeRid
Current rid in btree used to access current cluster page.
uint nClusterCols
Number of columns in cluster.
uint16_t * lastVal
Offsets to the last value stored on the page for each column in cluster.
uint16_t * firstVal
Offsets to the first value stored on the page for each column in cluster.
uint * nVal
Number of distinct values in the page for each column in cluster.
uint16_t * delta
For each column in the cluster, offset used to get the real offset within the page.
Private Member Functions
void moveToBlock (PageId clusterPageId)
Reads a cluster block and sets up necessary structures to navigate within the page.
bool moveToBlockWithRid (LcsRid rid)
Reads a cluster block and sets up necessary structures to navigate within the page corresponding to a rid.
bool positionInBlock (LcsRid rid)
Finds the range in the current block which contains "Rid".
void positionInRange (uint pos)
Positions on "pos" in the current range.
void setUpBlock ()
Updates class status to reflect page just read and sets header values to point within the current page.
LcsClusterNode const & readClusterPage ()
Reads a cluster page based on current btree position.
bool searchForRid (LcsRid rid)
Reads btree and locates rid in tree.
void getNextBTreeEntry ()
Reads the next entry in the rid-to-pageId btree map.
Private Attributes
SharedBTreeReader bTreeReader
Reads btree corresponding to cluster.
PLcsBatchDir pRangeBatches
Pointer to first batch in the current range.
LcsRid rangeStartRid
First rid in the current range.
LcsRid rangeEndRid
1 rid past the last rid in the current range
uint nRangePos
Offset from start of current range.
PBuffer pLeaf
Pointer to current cluster block.
PConstLcsClusterNode pLHdr
Pointer to header of cluster block.
PLcsBatchDir pBatches
Batch directory.
bool noPrefetch
If true, do not use pre-fetch.
CircularBufferIter< LcsRidRun > ridRunIter
Iterator over the circular buffer containing rid runs.
SegPageEntryIter< LcsRid > prefetchQueue
Pre-fetch queue for pages read from this cluster.
LcsRid nextRid
The next rid that needs to be read.
std::pair< PageId, LcsRid > nextBTreeEntry
The next entry in the rid-to-pageId btree map following the one that contains the last page that was pre-fetched.
std::pair< PageId, LcsRid > nextPrefetchEntry
The next entry from the pre-fetch queue.
bool dumbPrefetch
If true, switch has been made to dumb pre-fetch.
LcsRid currRid
The current rid that needs to be read.
Friends
class LcsColumnReader

Detailed Description

Reads blocks from a single cluster.

A column reader object (LcsColumnReader) is used to read the value of a particular column at the current rowid of the LcsClusterReader.

A cluster holds the values for one or more columns. The values of these columns are held in rowid ranges. Each range contains one batch (LcsBatchDir) for each column; this batch holds the values of that column for each rowid in the range. A batch may be "fixed", "compressed", or "variable".

Suppose a table has 2 column store clusters: one containing columns A, B, and C, and another containing columns D and E. To read the values of columns A and C, create a LcsClusterReader on the first cluster, and two LcsColumnReader onto this LcsClusterReader, one for each column, A and C.

Here's how to use a LcsClusterReader (scan) and LcsColumnReader (colScan) for doing a full table scan:

scan.init for i in 0..nClusterCols colScan[i].init scan.position(first rid) do for i in 0..nClusterCols colScan[i].sync do for i in 0..nClusterCols colScan[i].getCurrentValue while scan.advance(1) while scan.nextRange != false scan.close()

Definition at line 84 of file LcsClusterReader.h.


Constructor & Destructor Documentation

| LcsClusterReader::~LcsClusterReader | ( | | ) | [virtual] | | ------------------------------------ | - | | - | ----------- |


Member Function Documentation

void LcsClusterReader::moveToBlock ( PageId clusterPageId ) [private]
bool LcsClusterReader::moveToBlockWithRid ( LcsRid rid ) [private]
bool LcsClusterReader::positionInBlock ( LcsRid rid ) [private]
void LcsClusterReader::positionInRange ( uint pos ) [inline, private]

| void LcsClusterReader::setUpBlock | ( | | ) | [private] | | --------------------------------- | - | | - | ----------- |

| LcsClusterNode const & LcsClusterReader::readClusterPage | ( | | ) | [private] | | ------------------------------------------------------------------------------------- | - | | - | ----------- |

Reads a cluster page based on current btree position.

Returns:

cluster page read

Definition at line 58 of file LcsClusterReader.cpp.

References bTreeReader, LcsClusterAccessBase::bTreeRid, LcsClusterAccessBase::bTreeTupleData, LcsClusterAccessBase::clusterLock, LcsClusterAccessBase::clusterPageId, LcsClusterNode::firstRID, SegNodeLock< Node >::getNodeForRead(), SegPageLock::lockShared(), LcsClusterAccessBase::readClusterPageId(), and LcsClusterAccessBase::readRid().

Referenced by getFirstClusterPageForRead(), getNextClusterPageForRead(), and getNumRows().

bool LcsClusterReader::searchForRid ( LcsRid rid ) [private]

| void LcsClusterReader::getNextBTreeEntry | ( | | ) | [private] | | ---------------------------------------- | - | | - | ----------- |

void LcsClusterReader::setRootPageId ( PageId rootPageId )

Sets the root pageId of the underlying btree corresponding to the cluster.

Parameters:

rootPageId the root pageId that's set

Definition at line 53 of file LcsClusterReader.cpp.

References bTreeReader.

void LcsClusterReader::initColumnReaders ( uint nClusterColsInit,
TupleProjection const & clusterProj
)

| void LcsClusterReader::open | ( | | ) | | --------------------------- | - | | - |

| void LcsClusterReader::close | ( | | ) | | ---------------------------- | - | | - |

| bool LcsClusterReader::isPositioned | ( | | ) | const [inline] | | ----------------------------------- | - | | - | ---------------- |

| LcsRid LcsClusterReader::getRangeStartRid | ( | | ) | const [inline] | | ----------------------------------------- | - | | - | ---------------- |

| LcsRid LcsClusterReader::getRangeEndRid | ( | | ) | const [inline] | | --------------------------------------- | - | | - | ---------------- |

| uint LcsClusterReader::getRangeSize | ( | | ) | const [inline] | | ------------------------------------------------------------------------------------------------ | - | | - | ---------------- |

| uint LcsClusterReader::getRangePos | ( | | ) | const [inline] | | ----------------------------------------------------------------------------------------------- | - | | - | ---------------- |

| LcsRid LcsClusterReader::getCurrentRid | ( | | ) | const [inline] | | -------------------------------------- | - | | - | ---------------- |

| uint LcsClusterReader::getRangeRowsLeft | ( | | ) | const [inline] | | ---------------------------------------------------------------------------------------------------- | - | | - | ---------------- |

bool LcsClusterReader::position ( LcsRid rid )

Positions scan on the rid, moving to a new range if necessary.

Parameters:

Returns:

false if rid is beyond end of cluster

Definition at line 135 of file LcsClusterReader.cpp.

References bTreeReader, currRid, SegPageEntryIter< EntryT >::mapRange(), moveToBlock(), moveToBlockWithRid(), noPrefetch, NULL_PAGE_ID, pLeaf, positionInBlock(), prefetchQueue, LcsClusterAccessBase::readClusterPageId(), searchForRid(), and LcsClusterAccessBase::segmentAccessor.

Referenced by nextRange().

| bool LcsClusterReader::nextRange | ( | | ) | [inline] | | -------------------------------- | - | | - | ---------- |

bool LcsClusterReader::advance ( uint nRids )

Moves "nRids" forward in the current range.

Parameters:

nRids number of rids to move forward

Returns:

false if we are at the endof the range and therefore cannot advance the desired number of rids

Definition at line 295 of file LcsClusterReader.cpp.

References nRangePos.

00296 { 00297 uint newPos = nRangePos + nRids; 00298 00299 if (newPos < pRangeBatches->nRow) { 00300 nRangePos = newPos; 00301 return true; 00302 } else { 00303 return false; 00304 } 00305 }

void LcsClusterReader::advanceWithinBatch ( uint nRids ) [inline]

Advances nRids forward in the current batch.

Parameters:

nRids number of rids to advance

Definition at line 464 of file LcsClusterReader.h.

References nRangePos.

PageId LcsClusterReader::getNextPageForPrefetch ( LcsRid & rid,
bool & found
) [virtual]

Determines the next page to be pre-fetched based on the rids that need to be read.

Parameters:

[out] rid returns the rid corresponding to the page to be pre-fetched
[out] found true if a pre-fetch page was found

Returns:

the page to be pre-fetched next

Implements SegPageEntryIterSource< LcsRid >.

Definition at line 307 of file LcsClusterReader.cpp.

References currRid, CircularBufferIter< T >::done(), dumbPrefetch, getFetchRids(), getNextBTreeEntry(), MAXU, nextBTreeEntry, nextRid, NULL_PAGE_ID, LcsClusterAccessBase::readClusterPageId(), LcsClusterAccessBase::readRid(), ridRunIter, and searchForRid().

Retrieves the current and next rids that need to be read, based on the current rid run being processed.

Parameters:

ridRunIter iterator over the circular buffer that provides the rid runs
[in,out] nextRid on input, indicates the minimum rid value to be retrieved; on return, the next rid that will need to be read
remove if true, remove the first element from the circular buffer if the rid run buffer's position is incremented

Returns:

the current rid that needs to be read

Definition at line 390 of file LcsClusterReader.cpp.

References CircularBufferIter< T >::end(), MAXU, LcsRidRun::nRids, CircularBufferIter< T >::removeFront(), ridRunIter, and LcsRidRun::startRid.

Referenced by LcsRowScanExecStream::execute(), and getNextPageForPrefetch().

void LcsClusterReader::catchUp ( uint parentBufPos,
LcsRid parentNextRid
)

| LcsRid LcsClusterAccessBase::readRid | ( | | ) | [protected, inherited] | | ------------------------------------ | - | | - | ------------------------ |

| PageId LcsClusterAccessBase::readClusterPageId | ( | | ) | [protected, inherited] | | ---------------------------------------------- | - | | - | ------------------------ |

| uint LcsClusterAccessBase::getNumClusterCols | ( | | ) | [inline, inherited] | | --------------------------------------------------------------------------------------------------------- | - | | - | --------------------- |

void LcsClusterAccessBase::setNumClusterCols ( uint nCols ) [inline, inherited]

| void LcsClusterAccessBase::unlockClusterPage | ( | | ) | [inherited] | | -------------------------------------------- | - | | - | ------------- |

virtual void SegPageEntryIterSource< LcsRid >::initPrefetchEntry ( LcsRid & entry ) [inline, virtual, inherited]

Initializes a specific entry in the pre-fetch queue.

Parameters:

entry the entry that will be initialized

Definition at line 46 of file SegPageEntryIterSource.h.



Member Data Documentation

Number of columns in cluster.

Definition at line 68 of file LcsClusterAccessBase.h.

Referenced by LcsClusterNodeWriter::addValue(), LcsClusterNodeWriter::allocArrays(), LcsClusterDump::dump(), getNumRows(), LcsClusterNodeWriter::init(), initColumnReaders(), LcsClusterNodeWriter::LcsClusterNodeWriter(), LcsClusterNodeWriter::moveFromIndexToTemp(), LcsClusterNodeWriter::moveFromTempToIndex(), LcsClusterNodeWriter::openAppend(), LcsClusterNodeWriter::openNew(), positionInBlock(), and LcsClusterAccessBase::setHdrOffsets().

Offsets to the last value stored on the page for each column in cluster.

Definition at line 74 of file LcsClusterAccessBase.h.

Referenced by LcsClusterNodeWriter::addValue(), LcsClusterDump::dump(), LcsClusterNodeWriter::moveFromIndexToTemp(), LcsClusterNodeWriter::moveFromTempToIndex(), LcsClusterNodeWriter::openAppend(), LcsClusterNodeWriter::openNew(), LcsClusterNodeWriter::pickCompressionMode(), LcsClusterNodeWriter::putCompressedBatch(), LcsClusterNodeWriter::putFixedVarBatch(), LcsClusterNodeWriter::rollBackLastBatch(), LcsClusterAccessBase::setHdrOffsets(), and LcsClusterNodeWriter::undoValue().

Number of distinct values in the page for each column in cluster.

Definition at line 87 of file LcsClusterAccessBase.h.

Referenced by LcsClusterNodeWriter::addValue(), LcsClusterDump::dump(), LcsClusterNodeWriter::moveFromIndexToTemp(), LcsClusterNodeWriter::moveFromTempToIndex(), LcsClusterNodeWriter::openAppend(), LcsClusterNodeWriter::openNew(), LcsClusterNodeWriter::pickCompressionMode(), LcsClusterNodeWriter::putCompressedBatch(), LcsClusterNodeWriter::putFixedVarBatch(), LcsClusterNodeWriter::rollBackLastBatch(), LcsClusterAccessBase::setHdrOffsets(), and LcsClusterNodeWriter::undoValue().


The documentation for this class was generated from the following files:


Generated on Mon Jun 22 04:00:37 2009 for Fennel by doxygen 1.5.1