Пример #1
0
void SimplePipeliningTableScan::executePlanOperation() {
  // if there is no input data, just return.
  if (!_tbl) {
    LOG4CXX_DEBUG(_pipelineLogger, "executePlanOperation: no input. Just return.");
    return;
  }

  LOG4CXX_DEBUG(_pipelineLogger, "executePlanOperation: input available. Normal operation.");

  size_t row = _ofDelta ? checked_pointer_cast<const storage::Store>(_tbl)->deltaOffset() : 0;
  for (size_t input_size = _tbl->size(); row < input_size; ++row) {
    if ((*_comparator)(row)) {
      _pos_list->push_back(row);
      if (_pos_list->size() > _chunkSize) {
        createAndEmitChunk();
      }
    }
  }
  if (_pos_list->size() > 0) {
    LOG4CXX_DEBUG(_pipelineLogger, "Emitting final chunk.");
    createAndEmitChunk();
  } else {
    LOG4CXX_DEBUG(_pipelineLogger, "No final chunk necessary.");
  }
}
Пример #2
0
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) {
      createAndEmitChunk();
    }
  }

  // Emit final results.
  if (_buildTablePosList->size() > 0) {
    createAndEmitChunk();
  }

  LOG4CXX_DEBUG(logger, "Done Probing");
}
Пример #3
0
void PipeliningTableScan::executePlanOperation() {
  // TODO can we take this and move it into the PipelineObserver interface?
  if (!getInputTable()) {
    return;
  }
  size_t start, stop;
  const auto& tablerange = std::dynamic_pointer_cast<const storage::TableRangeView>(getInputTable());
  if (tablerange) {
    start = tablerange->getStart();
    stop = start + tablerange->size();
  } else {
    start = 0;
    stop = getInputTable()->size();
  }

  // When the input is 0, dont bother trying to generate results
  pos_list_t* positions = new pos_list_t();
  if (stop - start > 0)
    // scan in 100K chunks
    for (size_t chunk = 0; chunk < ((stop - start) / 100000 + 1); ++chunk) {
      size_t partial_start = start + chunk * 100000;
      size_t partial_stop = std::min(partial_start + 100000, stop);
      _expr->match(positions, partial_start, partial_stop);
      if (positions->size() >= _chunkSize) {
        createAndEmitChunk(positions);
        positions = new pos_list_t();
      }
    }
  else {
    createAndEmitChunk(positions);
  }

  // emit final chunk
  if (positions->size()) {
    createAndEmitChunk(positions);
  }
}