Skip to content

Commit

Permalink
Preparations for migrating the lazy operations from Coroutines to C++…
Browse files Browse the repository at this point in the history
…17 (#1802)

* `Result` can now be constructed from a `LazyResult` (which is a type-erased input range).
* `InputRangeFromGet` now works with move-only types.
  • Loading branch information
joka921 authored Feb 14, 2025
1 parent 2d6046a commit 98caf37
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/engine/Result.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ Result::Result(IdTableVocabPair pair, std::vector<ColumnIndex> sortedBy)

// _____________________________________________________________________________
Result::Result(Generator idTables, std::vector<ColumnIndex> sortedBy)
: Result{LazyResult{std::move(idTables)}, std::move(sortedBy)} {}

// _____________________________________________________________________________
Result::Result(LazyResult idTables, std::vector<ColumnIndex> sortedBy)
: data_{GenContainer{[](auto idTables, auto sortedBy) -> Generator {
std::optional<IdTable::row_type> previousId = std::nullopt;
for (IdTableVocabPair& pair : idTables) {
Expand Down
2 changes: 2 additions & 0 deletions src/engine/Result.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ class Result {
LocalVocab&& localVocab);
Result(IdTableVocabPair pair, std::vector<ColumnIndex> sortedBy);
Result(Generator idTables, std::vector<ColumnIndex> sortedBy);
Result(LazyResult idTables, std::vector<ColumnIndex> sortedBy);

// Prevent accidental copying of a result table.
Result(const Result& other) = delete;
Result& operator=(const Result& other) = delete;
Expand Down
5 changes: 5 additions & 0 deletions src/util/Iterators.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,11 @@ class InputRangeFromGet {

public:
virtual ~InputRangeFromGet() = default;
InputRangeFromGet() = default;
InputRangeFromGet(InputRangeFromGet&&) = default;
InputRangeFromGet& operator=(InputRangeFromGet&&) = default;
InputRangeFromGet(const InputRangeFromGet&) = default;
InputRangeFromGet& operator=(const InputRangeFromGet&) = default;

// Get the next value and store it.
void getNextAndStore() { storage_ = get(); }
Expand Down

0 comments on commit 98caf37

Please sign in to comment.