LcsCompareColKeyUsingOffsetIndex Class Reference

This class implements the compare logic to sort the indices to the key offset vector, by comparing the data values stored at thse offsets. More...

#include <LcsHash.h>

List of all members.

Public Member Functions

 LcsCompareColKeyUsingOffsetIndex (SharedLcsClusterNodeWriter clusterBlockWriterInit, LcsHashTable *hashTableInit, TupleDescriptor const &colTupleDescInit, uint columnIdInit, UnalignedAttributeAccessor const &attrAccessorInit)
 Constructor.
 ~LcsCompareColKeyUsingOffsetIndex ()
bool lessThan (const uint16_t colKeyOffsetIndex1, const uint16_t colKeyOffsetIndex2)
 Compares the two values stored at the offsets located by the two indices.

Private Attributes

LcsHashTablehashTable
 Reference to the Hash Table where cluster column values are inserted into.
SharedLcsClusterNodeWriter clusterBlockWriter
 Reference to Node Writer to access the cluster column value.
uint columnId
 Column Id for this cluster column.
TupleDataWithBuffer colTuple1
 Two tuple instances to store the values being compared.
TupleDataWithBuffer colTuple2
TupleDescriptor colTupleDesc
 Tuple descriptor for the tuples being compared.
UnalignedAttributeAccessor attrAccessor


Detailed Description

This class implements the compare logic to sort the indices to the key offset vector, by comparing the data values stored at thse offsets.

The sorted indices can then be used to encode the offsets when preparing a compressed batch to write out.

Definition at line 322 of file LcsHash.h.


Constructor & Destructor Documentation

LcsCompareColKeyUsingOffsetIndex::LcsCompareColKeyUsingOffsetIndex ( SharedLcsClusterNodeWriter  clusterBlockWriterInit,
LcsHashTable hashTableInit,
TupleDescriptor const &  colTupleDescInit,
uint  columnIdInit,
UnalignedAttributeAccessor const &  attrAccessorInit 
) [explicit]

Constructor.

Parameters:
[in] clusterBlockWriterInit reference to clsuter node writer
[in] hashTableInit reference to the hash table
[in] colTupleDescInit reference to column tuple descriptor
[in] columnIdInit which column in the cluster is being compared
[in] attrAccessorInit attribute accessor of the column

Definition at line 566 of file LcsHash.cpp.

References attrAccessor, clusterBlockWriter, colTuple1, colTuple2, colTupleDesc, columnId, TupleDataWithBuffer::computeAndAllocate(), and hashTable.

00572 {
00573     hashTable      = hashTableInit;
00574     clusterBlockWriter = clusterBlockWriterInit;
00575     columnId = columnIdInit;
00576     colTupleDesc = colTupleDescInit;
00577     colTuple1.computeAndAllocate(colTupleDesc);
00578     colTuple2.computeAndAllocate(colTupleDesc);
00579     attrAccessor = attrAccessorInit;
00580 
00581     /*
00582      * Both tuples should have just one column.
00583      */
00584     assert((colTuple1.size() == 1) && (colTuple2.size() == 1));
00585 }

LcsCompareColKeyUsingOffsetIndex::~LcsCompareColKeyUsingOffsetIndex (  )  [inline]

Definition at line 379 of file LcsHash.h.

00379 {}


Member Function Documentation

bool LcsCompareColKeyUsingOffsetIndex::lessThan ( const uint16_t  colKeyOffsetIndex1,
const uint16_t  colKeyOffsetIndex2 
)

Compares the two values stored at the offsets located by the two indices.

The implementation uses type information saved in colTupleDesc when performing the comparison.

Parameters:
[in] colKeyOffsetIndex1 index into the offset of the first value
[in] colKeyOffsetIndex2 index into the offset of the second value
Returns:
true if value at offset located at colKeyOffsetIndex1 is less than value at offset loocated at colKeyOffsetIndex2

Definition at line 588 of file LcsHash.cpp.

References attrAccessor, clusterBlockWriter, colTuple1, colTuple2, colTupleDesc, columnId, TupleDescriptor::compareTuples(), hashTable, UnalignedAttributeAccessor::loadValue(), TupleDataWithBuffer::resetBuffer(), LcsHashTable::valueNodes, and LcsHashValueNode::valueOffset.

00591 {
00592     bool isLessThan = false;
00593 
00594     /*
00595      * Using index, locates the offset in the hash table then using offset,
00596      * constructs TupleDatum of the column "columnId".
00597      */
00598     attrAccessor.loadValue(
00599         colTuple1[0],
00600         clusterBlockWriter->getOffsetPtr(
00601             columnId, hashTable->valueNodes[colKeyOffsetIndex1].valueOffset));
00602 
00603     attrAccessor.loadValue(
00604         colTuple2[0],
00605         clusterBlockWriter->getOffsetPtr(
00606             columnId, hashTable->valueNodes[colKeyOffsetIndex2].valueOffset));
00607 
00608     /*
00609      * The std::sort interface requires a "less than" operator. Returns true if
00610      * first value is less than the second value.
00611      */
00612     isLessThan = colTupleDesc.compareTuples(colTuple1, colTuple2) < 0;
00613 
00614     colTuple1.resetBuffer();
00615     colTuple2.resetBuffer();
00616 
00617     return (isLessThan);
00618 }


Member Data Documentation

LcsHashTable* LcsCompareColKeyUsingOffsetIndex::hashTable [private]

Reference to the Hash Table where cluster column values are inserted into.

Definition at line 330 of file LcsHash.h.

Referenced by LcsCompareColKeyUsingOffsetIndex(), and lessThan().

SharedLcsClusterNodeWriter LcsCompareColKeyUsingOffsetIndex::clusterBlockWriter [private]

Reference to Node Writer to access the cluster column value.

Definition at line 335 of file LcsHash.h.

Referenced by LcsCompareColKeyUsingOffsetIndex(), and lessThan().

uint LcsCompareColKeyUsingOffsetIndex::columnId [private]

Column Id for this cluster column.

Node Writer is for the whole cluster. It needs the column ID to get the value for a column.

Definition at line 342 of file LcsHash.h.

Referenced by LcsCompareColKeyUsingOffsetIndex(), and lessThan().

TupleDataWithBuffer LcsCompareColKeyUsingOffsetIndex::colTuple1 [private]

Two tuple instances to store the values being compared.

Definition at line 347 of file LcsHash.h.

Referenced by LcsCompareColKeyUsingOffsetIndex(), and lessThan().

TupleDataWithBuffer LcsCompareColKeyUsingOffsetIndex::colTuple2 [private]

Definition at line 348 of file LcsHash.h.

Referenced by LcsCompareColKeyUsingOffsetIndex(), and lessThan().

TupleDescriptor LcsCompareColKeyUsingOffsetIndex::colTupleDesc [private]

Tuple descriptor for the tuples being compared.

Definition at line 353 of file LcsHash.h.

Referenced by LcsCompareColKeyUsingOffsetIndex(), and lessThan().

UnalignedAttributeAccessor LcsCompareColKeyUsingOffsetIndex::attrAccessor [private]

Definition at line 355 of file LcsHash.h.

Referenced by LcsCompareColKeyUsingOffsetIndex(), and lessThan().


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