#include <LhxPartition.h>
Public Member Functions | |
LhxPartitionInfo () | |
void | init (LhxHashInfo *hashInfoInit) |
Set up the recursive partitioning context. | |
void | open (LhxHashTableReader *hashTableReaderInit, LhxPartitionReader *buildReader, TupleData &buildTuple, SharedLhxPartition probePartition, uint buildInputIndex) |
Prepare to partition the inputs: Build inout reads from both hash table and an existing reader. | |
void | open (LhxHashTableReader *hashTableReaderInit, LhxPartitionReader *buildReader, TupleData &buildTuple, AggComputerList *aggList) |
Prepare to aggregate and partition the (build) input which reads from both hash table and an existing reader. | |
void | close () |
Close the reader stream and the writer streams. | |
Public Attributes | |
LhxHashTableReader * | hashTableReader |
Hash Table Reader for hash aggregates. | |
LhxPartitionReader | probeReader |
Src partition reader. | |
LhxPartitionReader * | reader |
TupleData | buildTuple |
holding the tuple which is not yet inserted into hash table | |
vector< SharedLhxPartitionWriter > | writerList |
Child partitions for both inputs have to be complete before child plans can be created. | |
vector< SharedLhxPartition > | destPartitionList |
vector< shared_ptr< dynamic_bitset<> > > | joinFilterList |
shared_array< uint > | filteredRowCountList |
vector< shared_array< uint > > | subPartStatList |
uint | numInputs |
uint | curInputIndex |
LhxHashInfo * | hashInfo |
bool | partitionMemory |
Definition at line 180 of file LhxPartition.h.
LhxPartitionInfo::LhxPartitionInfo | ( | ) | [inline] |
Definition at line 246 of file LhxPartition.h.
References hashTableReader, and reader.
00247 { 00248 reader = NULL; 00249 hashTableReader = NULL; 00250 }
void LhxPartitionInfo::init | ( | LhxHashInfo * | hashInfoInit | ) |
Set up the recursive partitioning context.
Definition at line 260 of file LhxPartition.cpp.
References filteredRowCountList, hashInfo, LhxHashInfo::inputDesc, LhxPlan::LhxChildPartCount, numInputs, and writerList.
Referenced by LhxJoinExecStream::open(), and LhxAggExecStream::open().
00261 { 00262 hashInfo = hashInfoInit; 00263 numInputs = (hashInfo->inputDesc).size(); 00264 00265 writerList.clear(); 00266 /* 00267 * writerList is shared across iterations of partitioning. At each 00268 * iteration, writerList is initialized with new destination partitions. 00269 */ 00270 for (uint i = 0; i < numInputs * LhxPlan::LhxChildPartCount; i ++) { 00271 writerList.push_back( 00272 SharedLhxPartitionWriter(new LhxPartitionWriter())); 00273 } 00274 00275 filteredRowCountList.reset( 00276 new uint[numInputs * LhxPlan::LhxChildPartCount]); 00277 }
void LhxPartitionInfo::open | ( | LhxHashTableReader * | hashTableReaderInit, | |
LhxPartitionReader * | buildReader, | |||
TupleData & | buildTuple, | |||
SharedLhxPartition | probePartition, | |||
uint | buildInputIndex | |||
) |
Prepare to partition the inputs: Build inout reads from both hash table and an existing reader.
There is also a inflight tuple that is part of this partition. Probe input reads from a partition, which could be either disk partition or execution buffer stream.
Definition at line 279 of file LhxPartition.cpp.
References LhxHashTableReader::bindKey(), buildTuple, curInputIndex, destPartitionList, filteredRowCountList, hashInfo, hashTableReader, joinFilterList, LhxPlan::LhxChildPartCount, LhxPlan::LhxSubPartCount, numInputs, LhxPartitionReader::open(), partitionMemory, probeReader, reader, subPartStatList, and writerList.
Referenced by LhxJoinExecStream::execute(), and LhxAggExecStream::execute().
00285 { 00286 uint i, j; 00287 00288 probeReader.open(probePartition, *hashInfo); 00289 00290 /* 00291 * Start partitioning from the build side. 00292 */ 00293 curInputIndex = buildInputIndex; 00294 00295 hashTableReader = hashTableReaderInit; 00296 /* 00297 * Reset the reader and bind it to no particular key(will read the 00298 * whole hash table). 00299 */ 00300 hashTableReader->bindKey(NULL); 00301 00302 /* 00303 * The build reader is from the LhxJoinExecStream and is already open. 00304 */ 00305 reader = buildReader; 00306 00307 /* 00308 * The inflight (between disk partition and hash table) build tuple. 00309 */ 00310 buildTuple = buildTupleInit; 00311 00312 destPartitionList.clear(); 00313 subPartStatList.clear(); 00314 joinFilterList.clear(); 00315 shared_array<uint> curSubPartStat; 00316 00317 for (i = 0; i < numInputs * LhxPlan::LhxChildPartCount; i ++) { 00318 destPartitionList.push_back( 00319 SharedLhxPartition(new LhxPartition(probePartition->pExecStream))); 00320 destPartitionList[i]->inputIndex = (i / LhxPlan::LhxChildPartCount); 00321 subPartStatList.push_back( 00322 shared_array<uint>(new uint[LhxPlan::LhxSubPartCount])); 00323 00324 curSubPartStat = subPartStatList[i]; 00325 00326 for (j = 0; j < LhxPlan::LhxSubPartCount; j ++) { 00327 curSubPartStat[j] = 0; 00328 } 00329 00330 /* 00331 * One filter for each partition 00332 * filter bitmap is only allocated when a partition is written to 00333 */ 00334 joinFilterList.push_back(shared_ptr<dynamic_bitset<> >()); 00335 00336 writerList[i]->open(destPartitionList[i], *hashInfo); 00337 filteredRowCountList[i] = 0; 00338 } 00339 00340 /* 00341 * Tuples will come from memory (hash table) first. 00342 */ 00343 partitionMemory = true; 00344 }
void LhxPartitionInfo::open | ( | LhxHashTableReader * | hashTableReaderInit, | |
LhxPartitionReader * | buildReader, | |||
TupleData & | buildTuple, | |||
AggComputerList * | aggList | |||
) |
Prepare to aggregate and partition the (build) input which reads from both hash table and an existing reader.
There is also a inflight tuple that is part of this partition. aggList contains the agg computers which aggregate the input.
Definition at line 346 of file LhxPartition.cpp.
References LhxHashTableReader::bindKey(), buildTuple, curInputIndex, destPartitionList, filteredRowCountList, LhxPartitionReader::getSourcePartition(), hashInfo, hashTableReader, joinFilterList, LhxPlan::LhxChildPartCount, LhxPlan::LhxSubPartCount, LhxHashInfo::numCachePages, numInputs, partitionMemory, reader, subPartStatList, and writerList.
00351 { 00352 uint i, j; 00353 assert (numInputs == 1); 00354 uint buildIndex = numInputs - 1; 00355 00356 curInputIndex = buildIndex; 00357 00358 hashTableReader = hashTableReaderInit; 00359 /* 00360 * Reset the reader and bind it to no particular key (will read the 00361 * whole hash table). 00362 */ 00363 hashTableReader->bindKey(NULL); 00364 00365 // REVIEW jvs 26-Aug-2006: no join if doing agg... 00366 /* 00367 * The build reader is from the LhxJoinExecStream and is already open. 00368 */ 00369 reader = buildReader; 00370 00371 /* 00372 * The inflight(between disk partition and hash table) build tuple. 00373 */ 00374 buildTuple = buildTupleInit; 00375 00376 /* 00377 * The hash table contained in the writer should only use up to the child's 00378 * share of scratch buffer. 00379 */ 00380 uint numWriterCachePages = 00381 hashInfo->numCachePages / LhxPlan::LhxChildPartCount; 00382 00383 destPartitionList.clear(); 00384 subPartStatList.clear(); 00385 joinFilterList.clear(); 00386 shared_array<uint> curSubPartStat; 00387 00388 for (i = 0; i < numInputs * LhxPlan::LhxChildPartCount; i ++) { 00389 destPartitionList.push_back( 00390 SharedLhxPartition( 00391 new LhxPartition(reader->getSourcePartition()->pExecStream))); 00392 destPartitionList[i]->inputIndex = (i / LhxPlan::LhxChildPartCount); 00393 subPartStatList.push_back( 00394 shared_array<uint>(new uint[LhxPlan::LhxSubPartCount])); 00395 00396 curSubPartStat = subPartStatList[i]; 00397 00398 for (j = 0; j < LhxPlan::LhxSubPartCount; j ++) { 00399 curSubPartStat[j] = 0; 00400 } 00401 00402 // REVIEW jvs 26-Aug-2006: no join if doing agg... 00403 /* 00404 * One filter for each partition 00405 * filter bitmap is only allocated when a partition is written to 00406 */ 00407 joinFilterList.push_back(shared_ptr<dynamic_bitset<> >()); 00408 00409 writerList[i]->open( 00410 destPartitionList[i], 00411 *hashInfo, 00412 aggList, 00413 numWriterCachePages); 00414 filteredRowCountList[i] = 0; 00415 } 00416 00417 /* 00418 * Tuples will come from memory(hash table) first. 00419 */ 00420 partitionMemory = true; 00421 }
void LhxPartitionInfo::close | ( | ) |
Close the reader stream and the writer streams.
Definition at line 423 of file LhxPartition.cpp.
References LhxPartitionReader::close(), reader, and writerList.
Referenced by LhxJoinExecStream::execute(), and LhxAggExecStream::execute().
00424 { 00425 reader->close(); 00426 00427 uint numWriters = writerList.size(); 00428 00429 for (uint i = 0; i < numWriters; i ++) { 00430 writerList[i]->close(); 00431 } 00432 00433 /* 00434 * Partial aggregate hash tables used inside the writers(one HT 00435 * for each writer) share the same scratch buffer space. 00436 * Release the buffer pages used by these hash tables at the end, 00437 * after all writers have been closed(so that there will be no more 00438 * scratch page alloc calls). 00439 */ 00440 for (uint i = 0; i < numWriters; i ++) { 00441 writerList[i]->releaseResources(); 00442 } 00443 }
Hash Table Reader for hash aggregates.
Definition at line 185 of file LhxPartition.h.
Referenced by LhxPlan::generatePartitions(), LhxPartitionInfo(), and open().
Src partition reader.
It could either be a local reader (probeReader), or a reader passed in from the exec stream in open() method. The latter is used to partition a build input. When the hash table overflows, all the data from the hash table, plus the remaining data from the build partition, as well as the inflight tuple which caused the hash table overflow, need to be repartitioned.
Definition at line 197 of file LhxPartition.h.
Referenced by LhxPlan::generatePartitions(), and open().
Definition at line 198 of file LhxPartition.h.
Referenced by close(), LhxPlan::generatePartitions(), LhxPartitionInfo(), and open().
holding the tuple which is not yet inserted into hash table
Definition at line 203 of file LhxPartition.h.
Referenced by LhxPlan::generatePartitions(), and open().
Child partitions for both inputs have to be complete before child plans can be created.
writerList.size() == destPartitionList.size() == numInputs * LhxPlan::LhxChildPartCount
Input filters are used to filter only one input (the build input) of each child partition.
joinFilterList.size() == LhxPlan::LhxChildPartCount
Definition at line 220 of file LhxPartition.h.
Referenced by close(), LhxPlan::generatePartitions(), init(), and open().
vector<shared_ptr<dynamic_bitset<> > > LhxPartitionInfo::joinFilterList |
Definition at line 224 of file LhxPartition.h.
Referenced by LhxPlan::createChildren(), LhxPlan::generatePartitions(), and open().
shared_array<uint> LhxPartitionInfo::filteredRowCountList |
Definition at line 225 of file LhxPartition.h.
Referenced by LhxPlan::createChildren(), LhxPlan::generatePartitions(), init(), and open().
vector<shared_array<uint> > LhxPartitionInfo::subPartStatList |
Definition at line 233 of file LhxPartition.h.
Referenced by LhxPlan::createChildren(), LhxPlan::generatePartitions(), and open().
Definition at line 235 of file LhxPartition.h.
Referenced by LhxPlan::createChildren(), LhxPlan::generatePartitions(), init(), and open().
Definition at line 236 of file LhxPartition.h.
Referenced by LhxPlan::generatePartitions(), and open().
Definition at line 244 of file LhxPartition.h.
Referenced by LhxPlan::generatePartitions(), and open().