void PipeliningHashBuild::executePlanOperation() { // if no input is available, do nothing. if (input.sizeOf<storage::AbstractTable>() == 0) { return; } size_t row_offset = 0; // check if table is a TableRangeView; if yes, provide the offset to HashTable auto input = std::dynamic_pointer_cast<const storage::TableRangeView>(getInputTable()); if (input) row_offset = input->getStart(); if (_key == "groupby" || _key == "selfjoin") { if (_field_definition.size() == 1) emitChunk(std::make_shared<storage::SingleAggregateHashTable>(getInputTable(), _field_definition, row_offset)); else emitChunk(std::make_shared<storage::AggregateHashTable>(getInputTable(), _field_definition, row_offset)); } else if (_key == "join") { if (_field_definition.size() == 1) emitChunk(std::make_shared<storage::SingleJoinHashTable>(getInputTable(), _field_definition, row_offset)); else emitChunk(std::make_shared<storage::JoinHashTable>(getInputTable(), _field_definition, row_offset)); } else { throw std::runtime_error("Type in Plan operation HashBuild not supported; key: " + _key); } }
void PipeliningHashProbe::fetchPositions() { const auto& probeTable = getProbeTable(); const auto& hash_table = std::dynamic_pointer_cast<const HashTable>(getInputHashTable(0)); assert(hash_table != nullptr); LOG4CXX_DEBUG(logger, hash_table->stats()); LOG4CXX_DEBUG(logger, "Probe Table Size: " << probeTable->size()); LOG4CXX_DEBUG(logger, "Hash Table Size: " << hash_table->size()); for (pos_t probeTableRow = 0; probeTableRow < probeTable->size(); ++probeTableRow) { pos_list_t matchingRows(hash_table->get(probeTable, _field_definition, probeTableRow)); if (!matchingRows.empty()) { _buildTablePosList->insert(_buildTablePosList->end(), matchingRows.begin(), matchingRows.end()); _probeTablePosList->insert(_probeTablePosList->end(), matchingRows.size(), probeTableRow); } // We can only monitor the size of the output after each row has been probed. // Each probed row can produce n matches. The output table will increase by those n rows. // As soon as the current n causes the output table to reach the _chunkSize threshold, // we will emit a chunk and reset the _buildTablePosList and _probeTablePosList. if (_buildTablePosList->size() > _chunkSize) { emitChunk(); } } // Emit final results. if (_buildTablePosList->size() > 0) { emitChunk(); } LOG4CXX_DEBUG(logger, "Done Probing"); }
void PipeliningTableScan::createAndEmitChunk(pos_list_t* positions) { emitChunk(storage::PointerCalculator::create(_table, positions)); }