Remove ScanAllById operator
This commit is contained in:
parent
814c5eb397
commit
1b73ca4860
@ -149,8 +149,6 @@ class CostEstimator : public HierarchicalLogicalOperatorVisitor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Cost estimate ScanAllById?
|
|
||||||
|
|
||||||
// For the given op first increments the cardinality and then cost.
|
// For the given op first increments the cardinality and then cost.
|
||||||
#define POST_VISIT_CARD_FIRST(NAME) \
|
#define POST_VISIT_CARD_FIRST(NAME) \
|
||||||
bool PostVisit(NAME &) override { \
|
bool PostVisit(NAME &) override { \
|
||||||
|
@ -91,7 +91,6 @@ extern const Event ScanAllByLabelOperator;
|
|||||||
extern const Event ScanAllByLabelPropertyRangeOperator;
|
extern const Event ScanAllByLabelPropertyRangeOperator;
|
||||||
extern const Event ScanAllByLabelPropertyValueOperator;
|
extern const Event ScanAllByLabelPropertyValueOperator;
|
||||||
extern const Event ScanAllByLabelPropertyOperator;
|
extern const Event ScanAllByLabelPropertyOperator;
|
||||||
extern const Event ScanAllByIdOperator;
|
|
||||||
extern const Event ScanAllByPrimaryKeyOperator;
|
extern const Event ScanAllByPrimaryKeyOperator;
|
||||||
extern const Event ExpandOperator;
|
extern const Event ExpandOperator;
|
||||||
extern const Event ExpandVariableOperator;
|
extern const Event ExpandVariableOperator;
|
||||||
@ -560,24 +559,6 @@ UniqueCursorPtr ScanAllByPrimaryKey::MakeCursor(utils::MemoryResource *mem) cons
|
|||||||
throw QueryRuntimeException("ScanAllByPrimaryKey cursur is yet to be implemented.");
|
throw QueryRuntimeException("ScanAllByPrimaryKey cursur is yet to be implemented.");
|
||||||
}
|
}
|
||||||
|
|
||||||
ScanAllById::ScanAllById(const std::shared_ptr<LogicalOperator> &input, Symbol output_symbol, Expression *expression,
|
|
||||||
storage::v3::View view)
|
|
||||||
: ScanAll(input, output_symbol, view), expression_(expression) {
|
|
||||||
MG_ASSERT(expression);
|
|
||||||
}
|
|
||||||
|
|
||||||
ACCEPT_WITH_INPUT(ScanAllById)
|
|
||||||
|
|
||||||
UniqueCursorPtr ScanAllById::MakeCursor(utils::MemoryResource *mem) const {
|
|
||||||
EventCounter::IncrementCounter(EventCounter::ScanAllByIdOperator);
|
|
||||||
// TODO Reimplement when we have reliable conversion between hash value and pk
|
|
||||||
auto vertices = [](Frame & /*frame*/, ExecutionContext & /*context*/) -> std::optional<std::vector<VertexAccessor>> {
|
|
||||||
return std::nullopt;
|
|
||||||
};
|
|
||||||
return MakeUniqueCursorPtr<ScanAllCursor<decltype(vertices)>>(mem, output_symbol_, input_->MakeCursor(mem),
|
|
||||||
std::move(vertices), "ScanAllById");
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
template <class TEdges>
|
template <class TEdges>
|
||||||
|
@ -110,7 +110,6 @@ class ScanAllByLabel;
|
|||||||
class ScanAllByLabelPropertyRange;
|
class ScanAllByLabelPropertyRange;
|
||||||
class ScanAllByLabelPropertyValue;
|
class ScanAllByLabelPropertyValue;
|
||||||
class ScanAllByLabelProperty;
|
class ScanAllByLabelProperty;
|
||||||
class ScanAllById;
|
|
||||||
class ScanAllByPrimaryKey;
|
class ScanAllByPrimaryKey;
|
||||||
class Expand;
|
class Expand;
|
||||||
class ExpandVariable;
|
class ExpandVariable;
|
||||||
@ -142,7 +141,7 @@ class Foreach;
|
|||||||
using LogicalOperatorCompositeVisitor = utils::CompositeVisitor<
|
using LogicalOperatorCompositeVisitor = utils::CompositeVisitor<
|
||||||
Once, CreateNode, CreateExpand, ScanAll, ScanAllByLabel,
|
Once, CreateNode, CreateExpand, ScanAll, ScanAllByLabel,
|
||||||
ScanAllByLabelPropertyRange, ScanAllByLabelPropertyValue,
|
ScanAllByLabelPropertyRange, ScanAllByLabelPropertyValue,
|
||||||
ScanAllByLabelProperty, ScanAllById, ScanAllByPrimaryKey,
|
ScanAllByLabelProperty, ScanAllByPrimaryKey,
|
||||||
Expand, ExpandVariable, ConstructNamedPath, Filter, Produce, Delete,
|
Expand, ExpandVariable, ConstructNamedPath, Filter, Produce, Delete,
|
||||||
SetProperty, SetProperties, SetLabels, RemoveProperty, RemoveLabels,
|
SetProperty, SetProperties, SetLabels, RemoveProperty, RemoveLabels,
|
||||||
EdgeUniquenessFilter, Accumulate, Aggregate, Skip, Limit, OrderBy, Merge,
|
EdgeUniquenessFilter, Accumulate, Aggregate, Skip, Limit, OrderBy, Merge,
|
||||||
@ -865,24 +864,6 @@ given label and property.
|
|||||||
(:serialize (:slk))
|
(:serialize (:slk))
|
||||||
(:clone))
|
(:clone))
|
||||||
|
|
||||||
(lcp:define-class scan-all-by-id (scan-all)
|
|
||||||
((expression "Expression *" :scope :public
|
|
||||||
:slk-save #'slk-save-ast-pointer
|
|
||||||
:slk-load (slk-load-ast-pointer "Expression")))
|
|
||||||
(:documentation
|
|
||||||
"ScanAll producing a single node with ID equal to evaluated expression")
|
|
||||||
(:public
|
|
||||||
#>cpp
|
|
||||||
ScanAllById() {}
|
|
||||||
ScanAllById(const std::shared_ptr<LogicalOperator> &input,
|
|
||||||
Symbol output_symbol, Expression *expression,
|
|
||||||
storage::v3::View view = storage::v3::View::OLD);
|
|
||||||
|
|
||||||
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
|
|
||||||
UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
|
|
||||||
cpp<#)
|
|
||||||
(:serialize (:slk))
|
|
||||||
(:clone))
|
|
||||||
|
|
||||||
(lcp:define-struct expand-common ()
|
(lcp:define-struct expand-common ()
|
||||||
(
|
(
|
||||||
|
@ -86,14 +86,6 @@ bool PlanPrinter::PreVisit(query::v2::plan::ScanAllByLabelProperty &op) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlanPrinter::PreVisit(ScanAllById &op) {
|
|
||||||
WithPrintLn([&](auto &out) {
|
|
||||||
out << "* ScanAllById"
|
|
||||||
<< " (" << op.output_symbol_.name() << ")";
|
|
||||||
});
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PlanPrinter::PreVisit(query::v2::plan::Expand &op) {
|
bool PlanPrinter::PreVisit(query::v2::plan::Expand &op) {
|
||||||
WithPrintLn([&](auto &out) {
|
WithPrintLn([&](auto &out) {
|
||||||
*out_ << "* Expand (" << op.input_symbol_.name() << ")"
|
*out_ << "* Expand (" << op.input_symbol_.name() << ")"
|
||||||
@ -488,16 +480,6 @@ bool PlanToJsonVisitor::PreVisit(ScanAllByLabelProperty &op) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlanToJsonVisitor::PreVisit(ScanAllById &op) {
|
|
||||||
json self;
|
|
||||||
self["name"] = "ScanAllById";
|
|
||||||
self["output_symbol"] = ToJson(op.output_symbol_);
|
|
||||||
op.input_->Accept(*this);
|
|
||||||
self["input"] = PopOutput();
|
|
||||||
output_ = std::move(self);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PlanToJsonVisitor::PreVisit(CreateNode &op) {
|
bool PlanToJsonVisitor::PreVisit(CreateNode &op) {
|
||||||
json self;
|
json self;
|
||||||
self["name"] = "CreateNode";
|
self["name"] = "CreateNode";
|
||||||
|
@ -68,7 +68,6 @@ class PlanPrinter : public virtual HierarchicalLogicalOperatorVisitor {
|
|||||||
bool PreVisit(ScanAllByLabelPropertyValue &) override;
|
bool PreVisit(ScanAllByLabelPropertyValue &) override;
|
||||||
bool PreVisit(ScanAllByLabelPropertyRange &) override;
|
bool PreVisit(ScanAllByLabelPropertyRange &) override;
|
||||||
bool PreVisit(ScanAllByLabelProperty &) override;
|
bool PreVisit(ScanAllByLabelProperty &) override;
|
||||||
bool PreVisit(ScanAllById &) override;
|
|
||||||
|
|
||||||
bool PreVisit(Expand &) override;
|
bool PreVisit(Expand &) override;
|
||||||
bool PreVisit(ExpandVariable &) override;
|
bool PreVisit(ExpandVariable &) override;
|
||||||
@ -196,7 +195,6 @@ class PlanToJsonVisitor : public virtual HierarchicalLogicalOperatorVisitor {
|
|||||||
bool PreVisit(ScanAllByLabelPropertyRange &) override;
|
bool PreVisit(ScanAllByLabelPropertyRange &) override;
|
||||||
bool PreVisit(ScanAllByLabelPropertyValue &) override;
|
bool PreVisit(ScanAllByLabelPropertyValue &) override;
|
||||||
bool PreVisit(ScanAllByLabelProperty &) override;
|
bool PreVisit(ScanAllByLabelProperty &) override;
|
||||||
bool PreVisit(ScanAllById &) override;
|
|
||||||
|
|
||||||
bool PreVisit(Produce &) override;
|
bool PreVisit(Produce &) override;
|
||||||
bool PreVisit(Accumulate &) override;
|
bool PreVisit(Accumulate &) override;
|
||||||
|
@ -35,7 +35,6 @@ PRE_VISIT(ScanAllByLabel, RWType::R, true)
|
|||||||
PRE_VISIT(ScanAllByLabelPropertyRange, RWType::R, true)
|
PRE_VISIT(ScanAllByLabelPropertyRange, RWType::R, true)
|
||||||
PRE_VISIT(ScanAllByLabelPropertyValue, RWType::R, true)
|
PRE_VISIT(ScanAllByLabelPropertyValue, RWType::R, true)
|
||||||
PRE_VISIT(ScanAllByLabelProperty, RWType::R, true)
|
PRE_VISIT(ScanAllByLabelProperty, RWType::R, true)
|
||||||
PRE_VISIT(ScanAllById, RWType::R, true)
|
|
||||||
|
|
||||||
PRE_VISIT(Expand, RWType::R, true)
|
PRE_VISIT(Expand, RWType::R, true)
|
||||||
PRE_VISIT(ExpandVariable, RWType::R, true)
|
PRE_VISIT(ExpandVariable, RWType::R, true)
|
||||||
|
@ -59,7 +59,6 @@ class ReadWriteTypeChecker : public virtual HierarchicalLogicalOperatorVisitor {
|
|||||||
bool PreVisit(ScanAllByLabelPropertyValue &) override;
|
bool PreVisit(ScanAllByLabelPropertyValue &) override;
|
||||||
bool PreVisit(ScanAllByLabelPropertyRange &) override;
|
bool PreVisit(ScanAllByLabelPropertyRange &) override;
|
||||||
bool PreVisit(ScanAllByLabelProperty &) override;
|
bool PreVisit(ScanAllByLabelProperty &) override;
|
||||||
bool PreVisit(ScanAllById &) override;
|
|
||||||
|
|
||||||
bool PreVisit(Expand &) override;
|
bool PreVisit(Expand &) override;
|
||||||
bool PreVisit(ExpandVariable &) override;
|
bool PreVisit(ExpandVariable &) override;
|
||||||
|
@ -273,15 +273,6 @@ class IndexLookupRewriter final : public HierarchicalLogicalOperatorVisitor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PreVisit(ScanAllById &op) override {
|
|
||||||
prev_ops_.push_back(&op);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool PostVisit(ScanAllById &) override {
|
|
||||||
prev_ops_.pop_back();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PreVisit(ConstructNamedPath &op) override {
|
bool PreVisit(ConstructNamedPath &op) override {
|
||||||
prev_ops_.push_back(&op);
|
prev_ops_.push_back(&op);
|
||||||
return true;
|
return true;
|
||||||
@ -561,25 +552,8 @@ class IndexLookupRewriter final : public HierarchicalLogicalOperatorVisitor {
|
|||||||
const auto &view = scan.view_;
|
const auto &view = scan.view_;
|
||||||
const auto &modified_symbols = scan.ModifiedSymbols(*symbol_table_);
|
const auto &modified_symbols = scan.ModifiedSymbols(*symbol_table_);
|
||||||
std::unordered_set<Symbol> bound_symbols(modified_symbols.begin(), modified_symbols.end());
|
std::unordered_set<Symbol> bound_symbols(modified_symbols.begin(), modified_symbols.end());
|
||||||
auto are_bound = [&bound_symbols](const auto &used_symbols) {
|
|
||||||
for (const auto &used_symbol : used_symbols) {
|
// Try to see if we can use label+property index. If not, try to use
|
||||||
if (!utils::Contains(bound_symbols, used_symbol)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
// First, try to see if we can find a vertex by ID.
|
|
||||||
if (!max_vertex_count || *max_vertex_count >= 1) {
|
|
||||||
for (const auto &filter : filters_.IdFilters(node_symbol)) {
|
|
||||||
if (filter.id_filter->is_symbol_in_value_ || !are_bound(filter.used_symbols)) continue;
|
|
||||||
auto *value = filter.id_filter->value_;
|
|
||||||
filter_exprs_for_removal_.insert(filter.expression);
|
|
||||||
filters_.EraseFilter(filter);
|
|
||||||
return std::make_unique<ScanAllById>(input, node_symbol, value, view);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Now try to see if we can use label+property index. If not, try to use
|
|
||||||
// just the label index.
|
// just the label index.
|
||||||
const auto labels = filters_.FilteredLabels(node_symbol);
|
const auto labels = filters_.FilteredLabels(node_symbol);
|
||||||
if (labels.empty()) {
|
if (labels.empty()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user