-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into regex-arbitrary-chi…
…ld-expression
- Loading branch information
Showing
57 changed files
with
1,749 additions
and
728 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,30 +3,28 @@ | |
// Author: Björn Buchhold ([email protected]) | ||
#pragma once | ||
|
||
#include <utility> | ||
#include <vector> | ||
|
||
#include "engine/Operation.h" | ||
#include "engine/QueryExecutionTree.h" | ||
#include "parser/ParsedQuery.h" | ||
|
||
using std::vector; | ||
|
||
class Distinct : public Operation { | ||
private: | ||
std::shared_ptr<QueryExecutionTree> subtree_; | ||
vector<ColumnIndex> _keepIndices; | ||
std::vector<ColumnIndex> keepIndices_; | ||
|
||
static constexpr int64_t CHUNK_SIZE = 100'000; | ||
|
||
public: | ||
Distinct(QueryExecutionContext* qec, | ||
std::shared_ptr<QueryExecutionTree> subtree, | ||
const vector<ColumnIndex>& keepIndices); | ||
const std::vector<ColumnIndex>& keepIndices); | ||
|
||
[[nodiscard]] size_t getResultWidth() const override; | ||
|
||
[[nodiscard]] string getDescriptor() const override; | ||
|
||
[[nodiscard]] vector<ColumnIndex> resultSortedOn() const override { | ||
[[nodiscard]] std::vector<ColumnIndex> resultSortedOn() const override { | ||
return subtree_->resultSortedOn(); | ||
} | ||
|
||
|
@@ -46,15 +44,45 @@ class Distinct : public Operation { | |
|
||
bool knownEmptyResult() override { return subtree_->knownEmptyResult(); } | ||
|
||
vector<QueryExecutionTree*> getChildren() override { | ||
std::vector<QueryExecutionTree*> getChildren() override { | ||
return {subtree_.get()}; | ||
} | ||
|
||
protected: | ||
[[nodiscard]] string getCacheKeyImpl() const override; | ||
|
||
private: | ||
ProtoResult computeResult([[maybe_unused]] bool requestLaziness) override; | ||
ProtoResult computeResult(bool requestLaziness) override; | ||
|
||
VariableToColumnMap computeVariableToColumnMap() const override; | ||
|
||
// Helper function that only compares rows on the columns in `keepIndices_`. | ||
bool matchesRow(const auto& a, const auto& b) const; | ||
|
||
// Return a generator that applies an in-place unique algorithm to the | ||
// `IdTables`s yielded by the input generator. The `yieldOnce` flag controls | ||
// if every `IdTable` from `input` should yield it's own `IdTable` or if all | ||
// of them should get aggregated into a single big `IdTable`. | ||
template <size_t WIDTH> | ||
Result::Generator lazyDistinct(Result::Generator input, bool yieldOnce) const; | ||
|
||
// Removes all duplicates from input with regards to the columns | ||
// in keepIndices. The input needs to be sorted on the keep indices, | ||
// otherwise the result of this function is undefined. The argument | ||
// `previousRow` might hold a row representing the last row of the previous | ||
// `IdTable`, so that the `IdTable` that will be returned doesn't return | ||
// values that were already returned in the previous `IdTable`. | ||
template <size_t WIDTH> | ||
IdTable distinct( | ||
IdTable dynInput, | ||
std::optional<typename IdTableStatic<WIDTH>::row_type> previousRow) const; | ||
|
||
// Out-of-place implementation of the unique algorithm. Does only copy values | ||
// if they're actually unique. | ||
template <size_t WIDTH> | ||
IdTable outOfPlaceDistinct(const IdTable& dynInput) const; | ||
|
||
FRIEND_TEST(Distinct, distinct); | ||
FRIEND_TEST(Distinct, distinctWithEmptyInput); | ||
FRIEND_TEST(Distinct, testChunkEdgeCases); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.