-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1854 from kuzudb/update-planner-removal
Remove update planner
- Loading branch information
Showing
11 changed files
with
276 additions
and
254 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 was deleted.
Oops, something went wrong.
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
6 changes: 5 additions & 1 deletion
6
src/planner/plan_operator/CMakeLists.txt → src/planner/plan/CMakeLists.txt
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
File renamed without changes.
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 @@ | ||
#include "binder/query/updating_clause/bound_create_clause.h" | ||
#include "binder/query/updating_clause/bound_set_clause.h" | ||
#include "planner/logical_plan/logical_operator/logical_create.h" | ||
#include "planner/query_planner.h" | ||
|
||
using namespace kuzu::binder; | ||
|
||
namespace kuzu { | ||
namespace planner { | ||
|
||
void QueryPlanner::appendCreateNode( | ||
const std::vector<std::unique_ptr<binder::BoundCreateNode>>& createNodes, LogicalPlan& plan) { | ||
std::vector<std::shared_ptr<NodeExpression>> nodes; | ||
expression_vector primaryKeys; | ||
std::vector<std::unique_ptr<BoundSetNodeProperty>> setNodeProperties; | ||
for (auto& createNode : createNodes) { | ||
auto node = createNode->getNode(); | ||
nodes.push_back(node); | ||
primaryKeys.push_back(createNode->getPrimaryKeyExpression()); | ||
for (auto& setItem : createNode->getSetItems()) { | ||
setNodeProperties.push_back(std::make_unique<BoundSetNodeProperty>(node, setItem)); | ||
} | ||
} | ||
auto createNode = std::make_shared<LogicalCreateNode>( | ||
std::move(nodes), std::move(primaryKeys), plan.getLastOperator()); | ||
appendFlattens(createNode->getGroupsPosToFlatten(), plan); | ||
createNode->setChild(0, plan.getLastOperator()); | ||
createNode->computeFactorizedSchema(); | ||
plan.setLastOperator(createNode); | ||
appendSetNodeProperty(setNodeProperties, plan); | ||
} | ||
|
||
void QueryPlanner::appendCreateRel( | ||
const std::vector<std::unique_ptr<binder::BoundCreateRel>>& createRels, LogicalPlan& plan) { | ||
std::vector<std::shared_ptr<RelExpression>> rels; | ||
std::vector<std::vector<expression_pair>> setItemsPerRel; | ||
for (auto& createRel : createRels) { | ||
rels.push_back(createRel->getRel()); | ||
setItemsPerRel.push_back(createRel->getSetItems()); | ||
} | ||
auto createRel = std::make_shared<LogicalCreateRel>( | ||
std::move(rels), std::move(setItemsPerRel), plan.getLastOperator()); | ||
appendFlattens(createRel->getGroupsPosToFlatten(), plan); | ||
createRel->setChild(0, plan.getLastOperator()); | ||
createRel->computeFactorizedSchema(); | ||
plan.setLastOperator(createRel); | ||
} | ||
|
||
} // namespace planner | ||
} // namespace kuzu |
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,34 @@ | ||
#include "binder/query/updating_clause/bound_delete_clause.h" | ||
#include "planner/logical_plan/logical_operator/logical_delete.h" | ||
#include "planner/query_planner.h" | ||
|
||
namespace kuzu { | ||
namespace planner { | ||
|
||
void QueryPlanner::appendDeleteNode( | ||
const std::vector<std::unique_ptr<binder::BoundDeleteNode>>& deleteNodes, LogicalPlan& plan) { | ||
std::vector<std::shared_ptr<NodeExpression>> nodes; | ||
expression_vector primaryKeys; | ||
for (auto& deleteNode : deleteNodes) { | ||
nodes.push_back(deleteNode->getNode()); | ||
primaryKeys.push_back(deleteNode->getPrimaryKeyExpression()); | ||
} | ||
auto deleteNode = std::make_shared<LogicalDeleteNode>( | ||
std::move(nodes), std::move(primaryKeys), plan.getLastOperator()); | ||
deleteNode->computeFactorizedSchema(); | ||
plan.setLastOperator(std::move(deleteNode)); | ||
} | ||
|
||
void QueryPlanner::appendDeleteRel( | ||
const std::vector<std::shared_ptr<binder::RelExpression>>& deleteRels, LogicalPlan& plan) { | ||
auto deleteRel = std::make_shared<LogicalDeleteRel>(deleteRels, plan.getLastOperator()); | ||
for (auto i = 0u; i < deleteRel->getNumRels(); ++i) { | ||
appendFlattens(deleteRel->getGroupsPosToFlatten(i), plan); | ||
deleteRel->setChild(0, plan.getLastOperator()); | ||
} | ||
deleteRel->computeFactorizedSchema(); | ||
plan.setLastOperator(std::move(deleteRel)); | ||
} | ||
|
||
} // namespace planner | ||
} // namespace kuzu |
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,59 @@ | ||
#include "binder/query/updating_clause/bound_set_clause.h" | ||
#include "planner/logical_plan/logical_operator/logical_set.h" | ||
#include "planner/query_planner.h" | ||
|
||
namespace kuzu { | ||
namespace planner { | ||
|
||
void QueryPlanner::appendSetNodeProperty( | ||
const std::vector<std::unique_ptr<binder::BoundSetNodeProperty>>& setNodeProperties, | ||
LogicalPlan& plan) { | ||
std::vector<std::shared_ptr<NodeExpression>> nodes; | ||
std::vector<expression_pair> setItems; | ||
for (auto& setNodeProperty : setNodeProperties) { | ||
nodes.push_back(setNodeProperty->getNode()); | ||
setItems.push_back(setNodeProperty->getSetItem()); | ||
} | ||
for (auto i = 0u; i < setItems.size(); ++i) { | ||
auto lhsNodeID = nodes[i]->getInternalIDProperty(); | ||
auto rhs = setItems[i].second; | ||
// flatten rhs | ||
auto rhsDependentGroupsPos = plan.getSchema()->getDependentGroupsPos(rhs); | ||
auto rhsGroupsPosToFlatten = factorization::FlattenAllButOne::getGroupsPosToFlatten( | ||
rhsDependentGroupsPos, plan.getSchema()); | ||
appendFlattens(rhsGroupsPosToFlatten, plan); | ||
// flatten lhs if needed | ||
auto lhsGroupPos = plan.getSchema()->getGroupPos(*lhsNodeID); | ||
auto rhsLeadingGroupPos = | ||
SchemaUtils::getLeadingGroupPos(rhsDependentGroupsPos, *plan.getSchema()); | ||
if (lhsGroupPos != rhsLeadingGroupPos) { | ||
appendFlattenIfNecessary(lhsGroupPos, plan); | ||
} | ||
} | ||
auto setNodeProperty = std::make_shared<LogicalSetNodeProperty>( | ||
std::move(nodes), std::move(setItems), plan.getLastOperator()); | ||
setNodeProperty->computeFactorizedSchema(); | ||
plan.setLastOperator(setNodeProperty); | ||
} | ||
|
||
void QueryPlanner::appendSetRelProperty( | ||
const std::vector<std::unique_ptr<binder::BoundSetRelProperty>>& setRelProperties, | ||
LogicalPlan& plan) { | ||
std::vector<std::shared_ptr<RelExpression>> rels; | ||
std::vector<expression_pair> setItems; | ||
for (auto& setRelProperty : setRelProperties) { | ||
rels.push_back(setRelProperty->getRel()); | ||
setItems.push_back(setRelProperty->getSetItem()); | ||
} | ||
auto setRelProperty = std::make_shared<LogicalSetRelProperty>( | ||
std::move(rels), std::move(setItems), plan.getLastOperator()); | ||
for (auto i = 0u; i < setRelProperty->getNumRels(); ++i) { | ||
appendFlattens(setRelProperty->getGroupsPosToFlatten(i), plan); | ||
setRelProperty->setChild(0, plan.getLastOperator()); | ||
} | ||
setRelProperty->computeFactorizedSchema(); | ||
plan.setLastOperator(setRelProperty); | ||
} | ||
|
||
} // namespace planner | ||
} // namespace kuzu |
Oops, something went wrong.