Skip to content

Commit

Permalink
Return IdTable instead of using output variable
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinTF committed Oct 15, 2024
1 parent ec9cc5a commit aa7b723
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
16 changes: 7 additions & 9 deletions src/engine/Union.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,8 @@ ProtoResult Union::computeResult([[maybe_unused]] bool requestLaziness) {
std::shared_ptr<const Result> subRes2 = _subtrees[1]->getResult();
LOG(DEBUG) << "Union subresult computation done." << std::endl;

IdTable idTable{getExecutionContext()->getAllocator()};

idTable.setNumColumns(getResultWidth());
computeUnion(&idTable, subRes1->idTable(), subRes2->idTable(),
_columnOrigins);
IdTable idTable =
computeUnion(subRes1->idTable(), subRes2->idTable(), _columnOrigins);

LOG(DEBUG) << "Union result computation done" << std::endl;
// If only one of the two operands has a non-empty local vocabulary, share
Expand Down Expand Up @@ -198,10 +195,10 @@ void Union::fillChunked(auto beg, auto end, const auto& value) const {
};

// _____________________________________________________________________________
void Union::computeUnion(
IdTable* resPtr, const IdTable& left, const IdTable& right,
const std::vector<std::array<size_t, 2>>& columnOrigins) {
IdTable& res = *resPtr;
IdTable Union::computeUnion(
const IdTable& left, const IdTable& right,
const std::vector<std::array<size_t, 2>>& columnOrigins) const {
IdTable res{getResultWidth(), getExecutionContext()->getAllocator()};
res.resize(left.size() + right.size());

// Write the column with the `inputColumnIndex` from the `inputTable` into the
Expand Down Expand Up @@ -230,4 +227,5 @@ void Union::computeUnion(
writeColumn(left, targetColumn, leftCol, 0u);
writeColumn(right, targetColumn, rightCol, left.size());
}
return res;
}
6 changes: 3 additions & 3 deletions src/engine/Union.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ class Union : public Operation {
static constexpr size_t chunkSize = 1'000'000;

// The method is declared here to make it unit testable
void computeUnion(IdTable* inputTable, const IdTable& left,
const IdTable& right,
const std::vector<std::array<size_t, 2>>& columnOrigins);
IdTable computeUnion(
const IdTable& left, const IdTable& right,
const std::vector<std::array<size_t, 2>>& columnOrigins) const;

vector<QueryExecutionTree*> getChildren() override {
return {_subtrees[0].get(), _subtrees[1].get()};
Expand Down

0 comments on commit aa7b723

Please sign in to comment.