Move OrderByCursor from LCP to CPP
Reviewers: mtomic, llugovic Reviewed By: mtomic Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D2060
This commit is contained in:
parent
0075eee58b
commit
abbb57c868
@ -2852,11 +2852,6 @@ OrderBy::OrderBy(const std::shared_ptr<LogicalOperator> &input,
|
||||
|
||||
ACCEPT_WITH_INPUT(OrderBy)
|
||||
|
||||
UniqueCursorPtr OrderBy::MakeCursor(database::GraphDbAccessor *db,
|
||||
utils::MemoryResource *mem) const {
|
||||
return MakeUniqueCursorPtr<OrderByCursor>(mem, *this, db, mem);
|
||||
}
|
||||
|
||||
std::vector<Symbol> OrderBy::OutputSymbols(
|
||||
const SymbolTable &symbol_table) const {
|
||||
// Propagate this to potential Produce.
|
||||
@ -2867,12 +2862,13 @@ std::vector<Symbol> OrderBy::ModifiedSymbols(const SymbolTable &table) const {
|
||||
return input_->ModifiedSymbols(table);
|
||||
}
|
||||
|
||||
OrderBy::OrderByCursor::OrderByCursor(const OrderBy &self,
|
||||
database::GraphDbAccessor *db,
|
||||
class OrderByCursor : public Cursor {
|
||||
public:
|
||||
OrderByCursor(const OrderBy &self, database::GraphDbAccessor *db,
|
||||
utils::MemoryResource *mem)
|
||||
: self_(self), input_cursor_(self_.input_->MakeCursor(db, mem)) {}
|
||||
|
||||
bool OrderBy::OrderByCursor::Pull(Frame &frame, ExecutionContext &context) {
|
||||
bool Pull(Frame &frame, ExecutionContext &context) override {
|
||||
SCOPED_PROFILE_OP("OrderBy");
|
||||
|
||||
if (!did_pull_all_) {
|
||||
@ -2920,16 +2916,34 @@ bool OrderBy::OrderByCursor::Pull(Frame &frame, ExecutionContext &context) {
|
||||
cache_it_++;
|
||||
return true;
|
||||
}
|
||||
void Shutdown() override { input_cursor_->Shutdown(); }
|
||||
|
||||
void OrderBy::OrderByCursor::Shutdown() { input_cursor_->Shutdown(); }
|
||||
|
||||
void OrderBy::OrderByCursor::Reset() {
|
||||
void Reset() override {
|
||||
input_cursor_->Reset();
|
||||
did_pull_all_ = false;
|
||||
cache_.clear();
|
||||
cache_it_ = cache_.begin();
|
||||
}
|
||||
|
||||
private:
|
||||
const OrderBy &self_;
|
||||
const UniqueCursorPtr input_cursor_;
|
||||
bool did_pull_all_{false};
|
||||
// a cache of elements pulled from the input
|
||||
// first pair element is the order-by vector
|
||||
// second pair is the remember vector
|
||||
// the cache is filled and sorted (only on first pair elem) on first Pull
|
||||
std::vector<std::pair<std::vector<TypedValue>, std::vector<TypedValue>>>
|
||||
cache_;
|
||||
// iterator over the cache_, maintains state between Pulls
|
||||
decltype(cache_.begin()) cache_it_ = cache_.begin();
|
||||
};
|
||||
|
||||
UniqueCursorPtr OrderBy::MakeCursor(database::GraphDbAccessor *db,
|
||||
utils::MemoryResource *mem) const {
|
||||
return MakeUniqueCursorPtr<OrderByCursor>(mem, *this, db, mem);
|
||||
}
|
||||
|
||||
Merge::Merge(const std::shared_ptr<LogicalOperator> &input,
|
||||
const std::shared_ptr<LogicalOperator> &merge_match,
|
||||
const std::shared_ptr<LogicalOperator> &merge_create)
|
||||
|
@ -1789,30 +1789,6 @@ are valid for usage after the OrderBy operator.")
|
||||
input_ = input;
|
||||
}
|
||||
cpp<#)
|
||||
(:private
|
||||
#>cpp
|
||||
class OrderByCursor : public Cursor {
|
||||
public:
|
||||
OrderByCursor(const OrderBy &, database::GraphDbAccessor *,
|
||||
utils::MemoryResource *);
|
||||
bool Pull(Frame &, ExecutionContext &) override;
|
||||
void Shutdown() override;
|
||||
void Reset() override;
|
||||
|
||||
private:
|
||||
const OrderBy &self_;
|
||||
const UniqueCursorPtr input_cursor_;
|
||||
bool did_pull_all_{false};
|
||||
// a cache of elements pulled from the input
|
||||
// first pair element is the order-by vector
|
||||
// second pair is the remember vector
|
||||
// the cache is filled and sorted (only on first pair elem) on first Pull
|
||||
std::vector<std::pair<std::vector<TypedValue>, std::vector<TypedValue>>>
|
||||
cache_;
|
||||
// iterator over the cache_, maintains state between Pulls
|
||||
decltype(cache_.begin()) cache_it_ = cache_.begin();
|
||||
};
|
||||
cpp<#)
|
||||
(:serialize (:slk))
|
||||
(:clone))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user