#include <LcsHash.h>
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 | |
LcsHashTable * | hashTable |
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 |
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.
LcsCompareColKeyUsingOffsetIndex::LcsCompareColKeyUsingOffsetIndex | ( | SharedLcsClusterNodeWriter | clusterBlockWriterInit, | |
LcsHashTable * | hashTableInit, | |||
TupleDescriptor const & | colTupleDescInit, | |||
uint | columnIdInit, | |||
UnalignedAttributeAccessor const & | attrAccessorInit | |||
) | [explicit] |
Constructor.
[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] |
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.
[in] | colKeyOffsetIndex1 | index into the offset of the first value |
[in] | colKeyOffsetIndex2 | index into the offset of the second value |
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 }
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().
Reference to Node Writer to access the cluster column value.
Definition at line 335 of file LcsHash.h.
Referenced by LcsCompareColKeyUsingOffsetIndex(), and lessThan().
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().
Two tuple instances to store the values being compared.
Definition at line 347 of file LcsHash.h.
Referenced by LcsCompareColKeyUsingOffsetIndex(), and lessThan().
Definition at line 348 of file LcsHash.h.
Referenced by LcsCompareColKeyUsingOffsetIndex(), and lessThan().
Tuple descriptor for the tuples being compared.
Definition at line 353 of file LcsHash.h.
Referenced by LcsCompareColKeyUsingOffsetIndex(), and lessThan().
Definition at line 355 of file LcsHash.h.
Referenced by LcsCompareColKeyUsingOffsetIndex(), and lessThan().