Skip to content

Commit

Permalink
Unify two generators
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinTF committed Nov 20, 2024
1 parent 190b8de commit 3bbc466
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/engine/Join.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,13 @@ namespace {
// more efficient access in the join columns below and apply the given
// permutation to each table.
cppcoro::generator<ad_utility::IdTableAndFirstCol<IdTable>> convertGenerator(
Result::Generator gen, std::vector<ColumnIndex> permutation) {
Result::Generator gen, std::vector<ColumnIndex> permutation = {}) {
for (auto& [table, localVocab] : gen) {
// Make sure to actually move the table into the wrapper so that the tables
// live as long as the wrapper.
table.setColumnSubset(permutation);
ad_utility::IdTableAndFirstCol t{std::move(table), std::move(localVocab)};
co_yield t;
}
}
// Convert a `generator<IdTableVocab>` to a `generator<IdTableAndFirstCol>` for
// more efficient access in the join columns below.
cppcoro::generator<ad_utility::IdTableAndFirstCol<IdTable>> convertGenerator(
Result::Generator gen) {
for (auto& [table, localVocab] : gen) {
if (!permutation.empty()) {
table.setColumnSubset(permutation);
}
ad_utility::IdTableAndFirstCol t{std::move(table), std::move(localVocab)};
co_yield t;
}
Expand Down

0 comments on commit 3bbc466

Please sign in to comment.