-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/match path expression (#3997)
* Add match path pattern expression. * Change to relationship pattern. * Fix typo. * Resolve shift/reduce conflict by precedence. * Resolve reduce/reduce/conflict by GLR. * Add benchmark. * Update benchmark info. * Disable undefined variable. * Separate check function. * Implement pattern expression in where. * Remove unsued variable. * Don't group by edge variable. * Support in filter. * Add more test cases. * Add multiple patterns in filter. * Collect path by RollUpApply. * Modify ldbc cases. * Fix case. * Forbid special case. * Tune ldbc cases. * Tune some cases. * Remove skip. * Fix scanner test case. * Tune ldbc case. Co-authored-by: Sophie <[email protected]>
- Loading branch information
1 parent
166e70c
commit 7d12727
Showing
77 changed files
with
1,781 additions
and
511 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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* Copyright (c) 2022 vesoft inc. All rights reserved. | ||
* | ||
* This source code is licensed under Apache 2.0 License. | ||
*/ | ||
|
||
#include "common/expression/MatchPathPatternExpression.h" | ||
|
||
#include "common/expression/ExprVisitor.h" | ||
|
||
namespace nebula { | ||
|
||
const Value& MatchPathPatternExpression::eval(ExpressionContext& ctx) { | ||
result_ = DCHECK_NOTNULL(prop_)->eval(ctx); | ||
return result_; | ||
} | ||
|
||
bool MatchPathPatternExpression::operator==(const Expression& rhs) const { | ||
if (kind() != rhs.kind()) { | ||
return false; | ||
} | ||
|
||
if (matchPath_ != matchPath_) { | ||
return false; | ||
} | ||
|
||
// The prop_ field is used for evaluation internally, so it don't identify the expression. | ||
// We don't compare it here. | ||
// Ditto for result_ field. | ||
|
||
return true; | ||
} | ||
|
||
std::string MatchPathPatternExpression::toString() const { | ||
return matchPath_->toString(); | ||
} | ||
|
||
void MatchPathPatternExpression::accept(ExprVisitor* visitor) { | ||
visitor->visit(this); | ||
} | ||
|
||
Expression* MatchPathPatternExpression::clone() const { | ||
auto expr = | ||
MatchPathPatternExpression::make(pool_, std::make_unique<MatchPath>(matchPath_->clone())); | ||
if (prop_ != nullptr) { | ||
expr->setInputProp(static_cast<InputPropertyExpression*>(prop_->clone())); | ||
} | ||
return expr; | ||
} | ||
|
||
} // namespace nebula |
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 |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* Copyright (c) 2022 vesoft inc. All rights reserved. | ||
* | ||
* This source code is licensed under Apache 2.0 License. | ||
*/ | ||
|
||
#ifndef COMMON_EXPRESSION_MATCHPATHPATTERNEXPRESSION_H_ | ||
#define COMMON_EXPRESSION_MATCHPATHPATTERNEXPRESSION_H_ | ||
|
||
#include "common/expression/Expression.h" | ||
#include "parser/MatchSentence.h" | ||
|
||
namespace nebula { | ||
|
||
// For expression like (v:player)-[e:like]->(p) | ||
// Evaluate to [[v, e, p], [v, e, p]...] | ||
class MatchPathPatternExpression final : public Expression { | ||
public: | ||
MatchPathPatternExpression& operator=(const MatchPathPatternExpression& rhs) = delete; | ||
MatchPathPatternExpression& operator=(MatchPathPatternExpression&&) = delete; | ||
|
||
static MatchPathPatternExpression* make(ObjectPool* pool, | ||
std::unique_ptr<MatchPath>&& matchPath) { | ||
return pool->add(new MatchPathPatternExpression(pool, std::move(matchPath))); | ||
} | ||
|
||
const Value& eval(ExpressionContext& ctx) override; | ||
|
||
bool operator==(const Expression& rhs) const override; | ||
|
||
std::string toString() const override; | ||
|
||
void accept(ExprVisitor* visitor) override; | ||
|
||
Expression* clone() const override; | ||
|
||
// Evaluate expression by fetch result from input variable | ||
void setInputProp(const std::string& prop) { | ||
prop_ = InputPropertyExpression::make(pool_, prop); | ||
} | ||
|
||
void setInputProp(InputPropertyExpression* expr) { | ||
prop_ = expr; | ||
} | ||
|
||
InputPropertyExpression* inputProp() const { | ||
return prop_; | ||
} | ||
|
||
const MatchPath& matchPath() const { | ||
return *matchPath_; | ||
} | ||
|
||
MatchPath& matchPath() { | ||
return *matchPath_; | ||
} | ||
|
||
private: | ||
explicit MatchPathPatternExpression(ObjectPool* pool, std::unique_ptr<MatchPath>&& matchPath) | ||
: Expression(pool, Kind::kMatchPathPattern), matchPath_(std::move(matchPath)) {} | ||
|
||
// This expression contains variable implicitly, so we don't support persist or transform it. | ||
void writeTo(Encoder&) const override { | ||
LOG(FATAL) << "Not implemented"; | ||
} | ||
|
||
// This expression contains variable implicitly, so we don't support persist or transform it. | ||
void resetFrom(Decoder&) override { | ||
LOG(FATAL) << "Not implemented"; | ||
} | ||
|
||
private: | ||
std::unique_ptr<MatchPath> matchPath_; | ||
InputPropertyExpression* prop_{ | ||
nullptr}; // The column of input stored the result of the expression | ||
Value result_; | ||
}; | ||
} // namespace nebula | ||
#endif // COMMON_EXPRESSION_MATCHPATHPATTERNEXPRESSION_H_ |
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.