Skip to content

Commit

Permalink
Rename bijoin plan node (vesoft-inc#4977)
Browse files Browse the repository at this point in the history
* Rename BiJoin to HashJoin

* Rename cartesian product to cross join

* Fix compile
  • Loading branch information
yixinglu authored and codesigner committed Dec 5, 2022
1 parent cae3fe2 commit 8c7c677
Show file tree
Hide file tree
Showing 25 changed files with 155 additions and 153 deletions.
12 changes: 6 additions & 6 deletions src/graph/executor/Executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,14 +530,14 @@ Executor *Executor::makeExecutor(QueryContext *qctx, const PlanNode *node) {
case PlanNode::Kind::kAppendVertices: {
return pool->makeAndAdd<AppendVerticesExecutor>(node, qctx);
}
case PlanNode::Kind::kBiLeftJoin: {
return pool->makeAndAdd<BiLeftJoinExecutor>(node, qctx);
case PlanNode::Kind::kHashLeftJoin: {
return pool->makeAndAdd<HashLeftJoinExecutor>(node, qctx);
}
case PlanNode::Kind::kBiInnerJoin: {
return pool->makeAndAdd<BiInnerJoinExecutor>(node, qctx);
case PlanNode::Kind::kHashInnerJoin: {
return pool->makeAndAdd<HashInnerJoinExecutor>(node, qctx);
}
case PlanNode::Kind::kBiCartesianProduct: {
return pool->makeAndAdd<BiCartesianProductExecutor>(node, qctx);
case PlanNode::Kind::kCrossJoin: {
return pool->makeAndAdd<CrossJoinExecutor>(node, qctx);
}
case PlanNode::Kind::kRollUpApply: {
return pool->makeAndAdd<RollUpApplyExecutor>(node, qctx);
Expand Down
14 changes: 7 additions & 7 deletions src/graph/executor/algo/CartesianProductExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,20 @@ void CartesianProductExecutor::doCartesianProduct(const DataSet& lds,
}
}

BiCartesianProductExecutor::BiCartesianProductExecutor(const PlanNode* node, QueryContext* qctx)
CrossJoinExecutor::CrossJoinExecutor(const PlanNode* node, QueryContext* qctx)
: CartesianProductExecutor(node, qctx) {
name_ = "BiCartesianProductExecutor";
name_ = "CrossJoinExecutor";
}

folly::Future<Status> BiCartesianProductExecutor::execute() {
folly::Future<Status> CrossJoinExecutor::execute() {
SCOPED_TIMER(&execTime_);

auto* BiCP = asNode<BiCartesianProduct>(node());
const auto& lds = ectx_->getResult(BiCP->leftInputVar()).value().getDataSet();
const auto& rds = ectx_->getResult(BiCP->rightInputVar()).value().getDataSet();
auto* cj = asNode<CrossJoin>(node());
const auto& lds = ectx_->getResult(cj->leftInputVar()).value().getDataSet();
const auto& rds = ectx_->getResult(cj->rightInputVar()).value().getDataSet();
DataSet result;
doCartesianProduct(lds, rds, result);
result.colNames = BiCP->colNames();
result.colNames = cj->colNames();
return finish(ResultBuilder().value(Value(std::move(result))).build());
}
} // namespace graph
Expand Down
4 changes: 2 additions & 2 deletions src/graph/executor/algo/CartesianProductExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class CartesianProductExecutor : public Executor {
std::vector<std::vector<std::string>> colNames_;
};

class BiCartesianProductExecutor : public CartesianProductExecutor {
class CrossJoinExecutor : public CartesianProductExecutor {
public:
BiCartesianProductExecutor(const PlanNode* node, QueryContext* qctx);
CrossJoinExecutor(const PlanNode* node, QueryContext* qctx);

folly::Future<Status> execute() override;
};
Expand Down
16 changes: 8 additions & 8 deletions src/graph/executor/query/InnerJoinExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,29 +245,29 @@ void InnerJoinExecutor::buildNewRow(const std::unordered_map<T, std::vector<cons
}

const std::string& InnerJoinExecutor::leftVar() const {
if (node_->kind() == PlanNode::Kind::kBiInnerJoin) {
return node_->asNode<BiJoin>()->leftInputVar();
if (node_->kind() == PlanNode::Kind::kHashInnerJoin) {
return node_->asNode<HashJoin>()->leftInputVar();
} else {
return node_->asNode<Join>()->leftVar().first;
}
}

const std::string& InnerJoinExecutor::rightVar() const {
if (node_->kind() == PlanNode::Kind::kBiInnerJoin) {
return node_->asNode<BiJoin>()->rightInputVar();
if (node_->kind() == PlanNode::Kind::kHashInnerJoin) {
return node_->asNode<HashJoin>()->rightInputVar();
} else {
return node_->asNode<Join>()->rightVar().first;
}
}

BiInnerJoinExecutor::BiInnerJoinExecutor(const PlanNode* node, QueryContext* qctx)
HashInnerJoinExecutor::HashInnerJoinExecutor(const PlanNode* node, QueryContext* qctx)
: InnerJoinExecutor(node, qctx) {
name_ = "BiInnerJoinExecutor";
name_ = "HashInnerJoinExecutor";
}

folly::Future<Status> BiInnerJoinExecutor::execute() {
folly::Future<Status> HashInnerJoinExecutor::execute() {
SCOPED_TIMER(&execTime_);
auto* joinNode = asNode<BiJoin>(node());
auto* joinNode = asNode<HashJoin>(node());
NG_RETURN_IF_ERROR(checkBiInputDataSets());
return join(joinNode->hashKeys(), joinNode->probeKeys(), joinNode->colNames());
}
Expand Down
4 changes: 2 additions & 2 deletions src/graph/executor/query/InnerJoinExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ class InnerJoinExecutor : public JoinExecutor {

// No diffrence with inner join in processing data, but the dependencies would be executed in
// paralell.
class BiInnerJoinExecutor final : public InnerJoinExecutor {
class HashInnerJoinExecutor final : public InnerJoinExecutor {
public:
BiInnerJoinExecutor(const PlanNode* node, QueryContext* qctx);
HashInnerJoinExecutor(const PlanNode* node, QueryContext* qctx);

folly::Future<Status> execute() override;
};
Expand Down
2 changes: 1 addition & 1 deletion src/graph/executor/query/JoinExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Status JoinExecutor::checkInputDataSets() {
}

Status JoinExecutor::checkBiInputDataSets() {
auto* join = asNode<BiJoin>(node());
auto* join = asNode<HashJoin>(node());
lhsIter_ = ectx_->getResult(join->leftInputVar()).iter();
DCHECK(!!lhsIter_);
if (lhsIter_->isGetNeighborsIter() || lhsIter_->isDefaultIter()) {
Expand Down
8 changes: 4 additions & 4 deletions src/graph/executor/query/LeftJoinExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,14 @@ void LeftJoinExecutor::buildNewRow(const std::unordered_map<T, std::vector<const
}
}

BiLeftJoinExecutor::BiLeftJoinExecutor(const PlanNode* node, QueryContext* qctx)
HashLeftJoinExecutor::HashLeftJoinExecutor(const PlanNode* node, QueryContext* qctx)
: LeftJoinExecutor(node, qctx) {
name_ = "BiLeftJoinExecutor";
name_ = "HashLeftJoinExecutor";
}

folly::Future<Status> BiLeftJoinExecutor::execute() {
folly::Future<Status> HashLeftJoinExecutor::execute() {
SCOPED_TIMER(&execTime_);
auto* joinNode = asNode<BiJoin>(node());
auto* joinNode = asNode<HashJoin>(node());
auto& rhsResult = ectx_->getResult(joinNode->rightInputVar());
rightColSize_ = rhsResult.valuePtr()->getDataSet().colNames.size();
NG_RETURN_IF_ERROR(checkBiInputDataSets());
Expand Down
4 changes: 2 additions & 2 deletions src/graph/executor/query/LeftJoinExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ class LeftJoinExecutor : public JoinExecutor {

// No diffrence with left join in processing data, but the dependencies would be executed in
// paralell.
class BiLeftJoinExecutor final : public LeftJoinExecutor {
class HashLeftJoinExecutor final : public LeftJoinExecutor {
public:
BiLeftJoinExecutor(const PlanNode* node, QueryContext* qctx);
HashLeftJoinExecutor(const PlanNode* node, QueryContext* qctx);

folly::Future<Status> execute() override;
};
Expand Down
13 changes: 7 additions & 6 deletions src/graph/executor/test/JoinTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ TEST_F(JoinTest, InnerJoin) {
testInnerJoin("var2", "var1", expected, __LINE__);
}

TEST_F(JoinTest, BiInnerJoin) {
TEST_F(JoinTest, HashInnerJoin) {
DataSet expected;
expected.colNames = {"v1", "e1", "v2", "v3", "e2"};
Row row1;
Expand Down Expand Up @@ -243,9 +243,10 @@ TEST_F(JoinTest, BiInnerJoin) {
rhs->setOutputVar("var5");
rhs->setColNames({"v2", "e2", "v3"});

auto* join = BiInnerJoin::make(qctx_.get(), lhs, rhs, std::move(hashKeys), std::move(probeKeys));
auto* join =
HashInnerJoin::make(qctx_.get(), lhs, rhs, std::move(hashKeys), std::move(probeKeys));

auto joinExe = std::make_unique<BiInnerJoinExecutor>(join, qctx_.get());
auto joinExe = std::make_unique<HashInnerJoinExecutor>(join, qctx_.get());
auto future = joinExe->execute();
auto status = std::move(future).get();
EXPECT_TRUE(status.ok());
Expand Down Expand Up @@ -380,7 +381,7 @@ TEST_F(JoinTest, LeftJoin) {
testLeftJoin("var1", "var2", expected, __LINE__);
}

TEST_F(JoinTest, BiLeftJoin) {
TEST_F(JoinTest, HashLeftJoin) {
DataSet expected;
expected.colNames = {"v2", "e2", "v3", "v1", "e1"};
Row row1;
Expand Down Expand Up @@ -422,9 +423,9 @@ TEST_F(JoinTest, BiLeftJoin) {
rhs->setOutputVar("var4");
rhs->setColNames({"v1", "e1", "v2", "v3"});

auto* join = BiLeftJoin::make(qctx_.get(), lhs, rhs, std::move(hashKeys), std::move(probeKeys));
auto* join = HashLeftJoin::make(qctx_.get(), lhs, rhs, std::move(hashKeys), std::move(probeKeys));

auto joinExe = std::make_unique<BiLeftJoinExecutor>(join, qctx_.get());
auto joinExe = std::make_unique<HashLeftJoinExecutor>(join, qctx_.get());
auto future = joinExe->execute();
auto status = std::move(future).get();
EXPECT_TRUE(status.ok());
Expand Down
6 changes: 3 additions & 3 deletions src/graph/optimizer/rule/RemoveNoopProjectRule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ namespace opt {
PlanNode::Kind::kDataCollect,
PlanNode::Kind::kLeftJoin,
PlanNode::Kind::kInnerJoin,
PlanNode::Kind::kBiLeftJoin,
PlanNode::Kind::kBiInnerJoin,
PlanNode::Kind::kBiCartesianProduct,
PlanNode::Kind::kHashLeftJoin,
PlanNode::Kind::kHashInnerJoin,
PlanNode::Kind::kCrossJoin,
PlanNode::Kind::kRollUpApply,
PlanNode::Kind::kArgument};

Expand Down
2 changes: 1 addition & 1 deletion src/graph/planner/match/MatchPlanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Status MatchPlanner::connectMatchPlan(SubPlan& queryPlan, MatchClauseContext* ma
queryPlan = SegmentsConnector::innerJoin(matchCtx->qctx, queryPlan, matchPlan, interAliases);
}
} else {
queryPlan.root = BiCartesianProduct::make(matchCtx->qctx, queryPlan.root, matchPlan.root);
queryPlan.root = CrossJoin::make(matchCtx->qctx, queryPlan.root, matchPlan.root);
}

return Status::OK();
Expand Down
6 changes: 3 additions & 3 deletions src/graph/planner/match/SegmentsConnector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ SubPlan SegmentsConnector::innerJoin(QueryContext* qctx,
const SubPlan& right,
const std::unordered_set<std::string>& intersectedAliases) {
SubPlan newPlan = left;
auto innerJoin = BiInnerJoin::make(qctx, left.root, right.root);
auto innerJoin = HashInnerJoin::make(qctx, left.root, right.root);
std::vector<Expression*> hashKeys;
std::vector<Expression*> probeKeys;
auto pool = qctx->objPool();
Expand All @@ -39,7 +39,7 @@ SubPlan SegmentsConnector::leftJoin(QueryContext* qctx,
const SubPlan& right,
const std::unordered_set<std::string>& intersectedAliases) {
SubPlan newPlan = left;
auto leftJoin = BiLeftJoin::make(qctx, left.root, right.root);
auto leftJoin = HashLeftJoin::make(qctx, left.root, right.root);
std::vector<Expression*> hashKeys;
std::vector<Expression*> probeKeys;
auto pool = qctx->objPool();
Expand All @@ -61,7 +61,7 @@ SubPlan SegmentsConnector::cartesianProduct(QueryContext* qctx,
const SubPlan& left,
const SubPlan& right) {
SubPlan newPlan = left;
newPlan.root = BiCartesianProduct::make(qctx, left.root, right.root);
newPlan.root = CrossJoin::make(qctx, left.root, right.root);
return newPlan;
}

Expand Down
4 changes: 2 additions & 2 deletions src/graph/planner/match/ShortestPathPlanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ShortestPathPlanner::ShortestPathPlanner(CypherClauseContextBase* ctx, const Pat
// +------------+---------------+
// |
// +--------+---------+
// |BiCartesianProduct|
// | CrossJoin |
// +--------+---------+
// |
// +--------+---------+
Expand Down Expand Up @@ -95,7 +95,7 @@ StatusOr<SubPlan> ShortestPathPlanner::transform(WhereClauseContext* bindWhereCl
auto& leftPlan = plans.front();
auto& rightPlan = plans.back();

auto cp = BiCartesianProduct::make(qctx, leftPlan.root, rightPlan.root);
auto cp = CrossJoin::make(qctx, leftPlan.root, rightPlan.root);

auto shortestPath = ShortestPath::make(qctx, cp, spaceId, singleShortest);
auto vertexProp = SchemaUtil::getAllVertexProp(qctx, spaceId, true);
Expand Down
15 changes: 7 additions & 8 deletions src/graph/planner/plan/Algo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,34 +104,33 @@ std::vector<std::string> CartesianProduct::inputVars() const {
return varNames;
}

std::unique_ptr<PlanNodeDescription> BiCartesianProduct::explain() const {
std::unique_ptr<PlanNodeDescription> CrossJoin::explain() const {
return BinaryInputNode::explain();
}

PlanNode* BiCartesianProduct::clone() const {
PlanNode* CrossJoin::clone() const {
auto* node = make(qctx_);
node->cloneMembers(*this);
return node;
}

void BiCartesianProduct::cloneMembers(const BiCartesianProduct& r) {
void CrossJoin::cloneMembers(const CrossJoin& r) {
BinaryInputNode::cloneMembers(r);
}

BiCartesianProduct::BiCartesianProduct(QueryContext* qctx, PlanNode* left, PlanNode* right)
: BinaryInputNode(qctx, Kind::kBiCartesianProduct, left, right) {
CrossJoin::CrossJoin(QueryContext* qctx, PlanNode* left, PlanNode* right)
: BinaryInputNode(qctx, Kind::kCrossJoin, left, right) {
auto lColNames = left->colNames();
auto rColNames = right->colNames();
lColNames.insert(lColNames.end(), rColNames.begin(), rColNames.end());
setColNames(lColNames);
}

void BiCartesianProduct::accept(PlanNodeVisitor* visitor) {
void CrossJoin::accept(PlanNodeVisitor* visitor) {
visitor->visit(this);
}

BiCartesianProduct::BiCartesianProduct(QueryContext* qctx)
: BinaryInputNode(qctx, Kind::kBiCartesianProduct) {}
CrossJoin::CrossJoin(QueryContext* qctx) : BinaryInputNode(qctx, Kind::kCrossJoin) {}

std::unique_ptr<PlanNodeDescription> Subgraph::explain() const {
auto desc = SingleDependencyNode::explain();
Expand Down
16 changes: 8 additions & 8 deletions src/graph/planner/plan/Algo.h
Original file line number Diff line number Diff line change
Expand Up @@ -367,10 +367,10 @@ class Subgraph final : public SingleInputNode {
std::unique_ptr<std::vector<EdgeProp>> edgeProps_;
};

class BiCartesianProduct final : public BinaryInputNode {
class CrossJoin final : public BinaryInputNode {
public:
static BiCartesianProduct* make(QueryContext* qctx, PlanNode* left, PlanNode* right) {
return qctx->objPool()->makeAndAdd<BiCartesianProduct>(qctx, left, right);
static CrossJoin* make(QueryContext* qctx, PlanNode* left, PlanNode* right) {
return qctx->objPool()->makeAndAdd<CrossJoin>(qctx, left, right);
}

std::unique_ptr<PlanNodeDescription> explain() const override;
Expand All @@ -383,15 +383,15 @@ class BiCartesianProduct final : public BinaryInputNode {
friend ObjectPool;

// used for clone only
static BiCartesianProduct* make(QueryContext* qctx) {
return qctx->objPool()->makeAndAdd<BiCartesianProduct>(qctx);
static CrossJoin* make(QueryContext* qctx) {
return qctx->objPool()->makeAndAdd<CrossJoin>(qctx);
}

void cloneMembers(const BiCartesianProduct& r);
void cloneMembers(const CrossJoin& r);

BiCartesianProduct(QueryContext* qctx, PlanNode* left, PlanNode* right);
CrossJoin(QueryContext* qctx, PlanNode* left, PlanNode* right);
// use for clone
explicit BiCartesianProduct(QueryContext* qctx);
explicit CrossJoin(QueryContext* qctx);
};
} // namespace graph
} // namespace nebula
Expand Down
12 changes: 6 additions & 6 deletions src/graph/planner/plan/PlanNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,12 @@ const char* PlanNode::toString(PlanNode::Kind kind) {
return "Traverse";
case Kind::kAppendVertices:
return "AppendVertices";
case Kind::kBiLeftJoin:
return "BiLeftJoin";
case Kind::kBiInnerJoin:
return "BiInnerJoin";
case Kind::kBiCartesianProduct:
return "BiCartesianProduct";
case Kind::kHashLeftJoin:
return "HashLeftJoin";
case Kind::kHashInnerJoin:
return "HashInnerJoin";
case Kind::kCrossJoin:
return "CrossJoin";
case Kind::kShortestPath:
return "ShortestPath";
case Kind::kArgument:
Expand Down
6 changes: 3 additions & 3 deletions src/graph/planner/plan/PlanNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ class PlanNode {
kDataCollect,
kLeftJoin,
kInnerJoin,
kBiLeftJoin,
kBiInnerJoin,
kBiCartesianProduct,
kHashLeftJoin,
kHashInnerJoin,
kCrossJoin,
kRollUpApply,
kArgument,

Expand Down
4 changes: 2 additions & 2 deletions src/graph/planner/plan/PlanNodeVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ class PlanNodeVisitor {
virtual void visit(Traverse *node) = 0;
virtual void visit(ScanEdges *node) = 0;
virtual void visit(AppendVertices *node) = 0;
virtual void visit(BiJoin *node) = 0;
virtual void visit(HashJoin *node) = 0;
virtual void visit(Union *node) = 0;
virtual void visit(Unwind *node) = 0;
virtual void visit(BiCartesianProduct *node) = 0;
virtual void visit(CrossJoin *node) = 0;
};

} // namespace graph
Expand Down
Loading

0 comments on commit 8c7c677

Please sign in to comment.