Fennel: LhxHashGenerator Class Reference (original) (raw)
A hash function generator class that uses different seed values for each level, so that with the same key, different hash values are generated for different levels. More...
#include <[LhxHashGenerator.h](LhxHashGenerator%5F8h-source.html)>
| Public Member Functions | |
|---|---|
| void | init (uint levelInit) |
| Initialize the generator. | |
| uint | getLevel () |
| Get level information for this hash generator. | |
| uint | hash (TupleData const &inputTuple, TupleProjection const &keyProjection, vector< LhxHashTrim > const &isKeyColVarChar) |
| Compute hash value for a TupleData, on both value and length information. | |
| uint | hash (TupleDatum const &inputCol, LhxHashTrim isVarChar) |
| Compute hash value for a TupleDatum, on both value and length information. | |
| uint | hash (PConstBuffer pBuf, uint bufSize) |
| Compute hash value from value stored in a buffer. | |
| Private Member Functions | |
| void | hashOneBuffer (uint &hashValue, PConstBuffer pBuf, uint bufSize) |
| Compute hash value from value stored in a buffer. | |
| void | hashOneColumn (uint &hashValue, TupleDatum const &inputCol, LhxHashTrim isVarChar) |
| Compute hash value, from both value and length information, for a TupleDatum. | |
| Private Attributes | |
| uint | level |
| uint | hashValueSeed |
| uint8_t * | magicTable |
Detailed Description
A hash function generator class that uses different seed values for each level, so that with the same key, different hash values are generated for different levels.
Version:
Id
//open/dev/fennel/hashexe/LhxHashGenerator.h#3
Definition at line 43 of file LhxHashGenerator.h.
Member Function Documentation
| void LhxHashGenerator::hashOneBuffer | ( | uint & | hashValue, |
|---|---|---|---|
| PConstBuffer | pBuf, | ||
| uint | bufSize | ||
| ) | [private] |
Compute hash value from value stored in a buffer.
Parameters:
| [out] | hashValue | |
|---|---|---|
| [in] | pBuf | buffer containing the value |
| [in] | bufSize | size of the buffer |
Definition at line 86 of file LhxHashGenerator.cpp.
References count(), and magicTable.
Referenced by hash(), and hashOneColumn().
00090 { 00091 uint numValueBytes = sizeof(uint); 00092 uint8_t byteForNull = 0xff; 00093 00094 if (pBuf == NULL) { 00095 bufSize = 1; 00096 pBuf = &byteForNull; 00097 } 00098 00099 for (int count = 0; count < bufSize; count ++) { 00100 PBuffer pByte = (PBuffer) &hashValue; 00101 00102 for (int i = 0; i < numValueBytes; i++) { 00103 *pByte = magicTable[(*pByte) ^ (*pBuf)]; 00104 pByte ++; 00105 } 00106 00107 pBuf ++; 00108 } 00109 }
Compute hash value, from both value and length information, for a TupleDatum.
Parameters:
| [out] | hashValue | |
|---|---|---|
| [in] | inputCol | input TupleDatum |
| [in] | isVarChar | if col is varchar type |
Definition at line 111 of file LhxHashGenerator.cpp.
References TupleDatum::cbData, HASH_TRIM_UNICODE_VARCHAR, HASH_TRIM_VARCHAR, hashOneBuffer(), and TupleDatum::pData.
Referenced by hash().
00115 {
00116 uint trimmedLength = inputCol.cbData;
00117 PConstBuffer pData = inputCol.pData;
00118
00119 if (pData) {
00120
00121
00122
00123 if (isVarChar == HASH_TRIM_VARCHAR) {
00124 PConstBuffer pChar = pData + trimmedLength - 1;
00125 while ((pChar >= pData) && (*pChar == ' ')) {
00126 --pChar;
00127 }
00128 trimmedLength = pChar - pData + 1;
00129 } else if (isVarChar == HASH_TRIM_UNICODE_VARCHAR) {
00130 PConstBuffer pChar = pData + trimmedLength - 2;
00131 while ((pChar >= pData)
00132 && (*reinterpret_cast<uint16_t const *>(pChar) == ' '))
00133 {
00134 pChar -= 2;
00135 }
00136 trimmedLength = pChar - pData + 2;
00137 }
00138 }
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148 if (pData) {
00149 hashOneBuffer(
00150 hashValue,
00151 (PConstBuffer) &(trimmedLength),
00152 sizeof(TupleStorageByteLength));
00153 }
00154
00155
00156
00157
00158 hashOneBuffer(
00159 hashValue,
00160 pData,
00161 trimmedLength);
00162 }
| void LhxHashGenerator::init | ( | uint | levelInit | ) |
|---|
| uint LhxHashGenerator::getLevel | ( | | ) | [inline] | | -------------------------------------------------------------------------------------------- | - | | - | ---------- |
Compute hash value from value stored in a buffer.
Parameters:
| [in] | pBuf | buffer containing the value |
|---|---|---|
| [in] | bufSize | size of the buffer |
Returns:
the hash value
Definition at line 151 of file LhxHashGenerator.h.
References hashOneBuffer(), and hashValueSeed.
Member Data Documentation
The documentation for this class was generated from the following files:
- /home/pub/open/dev/fennel/hashexe/LhxHashGenerator.h
- /home/pub/open/dev/fennel/hashexe/LhxHashGenerator.cpp
