You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@quickstep.apache.org by ji...@apache.org on 2017/06/02 02:32:12 UTC
incubator-quickstep git commit: Simplified ExtractCommonSubexpression
rule as a BottomUp rule.
Repository: incubator-quickstep
Updated Branches:
refs/heads/master f8181b526 -> 8a0e24787
Simplified ExtractCommonSubexpression rule as a BottomUp rule.
Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/8a0e2478
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/8a0e2478
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/8a0e2478
Branch: refs/heads/master
Commit: 8a0e24787766bdb3621044a5784cc42596eeddaf
Parents: f8181b5
Author: Zuyu Zhang <zu...@apache.org>
Authored: Sun May 21 14:49:08 2017 -0700
Committer: Zuyu Zhang <zu...@apache.org>
Committed: Thu Jun 1 18:44:09 2017 -0700
----------------------------------------------------------------------
query_optimizer/rules/CMakeLists.txt | 2 +-
.../rules/ExtractCommonSubexpression.cpp | 32 +++++---------------
.../rules/ExtractCommonSubexpression.hpp | 9 +++---
3 files changed, 12 insertions(+), 31 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8a0e2478/query_optimizer/rules/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/query_optimizer/rules/CMakeLists.txt b/query_optimizer/rules/CMakeLists.txt
index 36e5959..70302be 100644
--- a/query_optimizer/rules/CMakeLists.txt
+++ b/query_optimizer/rules/CMakeLists.txt
@@ -109,7 +109,7 @@ target_link_libraries(quickstep_queryoptimizer_rules_ExtractCommonSubexpression
quickstep_queryoptimizer_physical_Physical
quickstep_queryoptimizer_physical_PhysicalType
quickstep_queryoptimizer_physical_Selection
- quickstep_queryoptimizer_rules_Rule
+ quickstep_queryoptimizer_rules_BottomUpRule
quickstep_utility_HashError
quickstep_utility_Macros)
target_link_libraries(quickstep_queryoptimizer_rules_FuseAggregateJoin
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8a0e2478/query_optimizer/rules/ExtractCommonSubexpression.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/rules/ExtractCommonSubexpression.cpp b/query_optimizer/rules/ExtractCommonSubexpression.cpp
index 63b6b17..8b68bd2 100644
--- a/query_optimizer/rules/ExtractCommonSubexpression.cpp
+++ b/query_optimizer/rules/ExtractCommonSubexpression.cpp
@@ -66,30 +66,12 @@ ExtractCommonSubexpression::ExtractCommonSubexpression(
}
}
-P::PhysicalPtr ExtractCommonSubexpression::apply(const P::PhysicalPtr &input) {
- DCHECK(input->getPhysicalType() == P::PhysicalType::kTopLevelPlan);
-
- return applyInternal(input);
-}
-
-P::PhysicalPtr ExtractCommonSubexpression::applyInternal(
+P::PhysicalPtr ExtractCommonSubexpression::applyToNode(
const P::PhysicalPtr &input) {
- // First process all child nodes.
- std::vector<P::PhysicalPtr> new_children;
- for (const auto &child : input->children()) {
- new_children.emplace_back(applyInternal(child));
- }
-
- const P::PhysicalPtr node =
- new_children == input->children()
- ? input
- : input->copyWithNewChildren(new_children);
-
- // Process expressions of the current node.
- switch (node->getPhysicalType()) {
+ switch (input->getPhysicalType()) {
case P::PhysicalType::kAggregate: {
const P::AggregatePtr aggregate =
- std::static_pointer_cast<const P::Aggregate>(node);
+ std::static_pointer_cast<const P::Aggregate>(input);
std::vector<E::ExpressionPtr> expressions;
// Gather grouping expressions and aggregate functions' argument expressions.
@@ -159,7 +141,7 @@ P::PhysicalPtr ExtractCommonSubexpression::applyInternal(
}
case P::PhysicalType::kSelection: {
const P::SelectionPtr selection =
- std::static_pointer_cast<const P::Selection>(node);
+ std::static_pointer_cast<const P::Selection>(input);
// Transform Selection's project expressions.
const std::vector<E::NamedExpressionPtr> new_expressions =
@@ -175,7 +157,7 @@ P::PhysicalPtr ExtractCommonSubexpression::applyInternal(
}
case P::PhysicalType::kHashJoin: {
const P::HashJoinPtr hash_join =
- std::static_pointer_cast<const P::HashJoin>(node);
+ std::static_pointer_cast<const P::HashJoin>(input);
// Transform HashJoin's project expressions.
const std::vector<E::NamedExpressionPtr> new_expressions =
@@ -195,7 +177,7 @@ P::PhysicalPtr ExtractCommonSubexpression::applyInternal(
}
case P::PhysicalType::kNestedLoopsJoin: {
const P::NestedLoopsJoinPtr nested_loops_join =
- std::static_pointer_cast<const P::NestedLoopsJoin>(node);
+ std::static_pointer_cast<const P::NestedLoopsJoin>(input);
// Transform NestedLoopsJoin's project expressions.
const std::vector<E::NamedExpressionPtr> new_expressions =
@@ -214,7 +196,7 @@ P::PhysicalPtr ExtractCommonSubexpression::applyInternal(
break;
}
- return node;
+ return input;
}
std::vector<E::ExpressionPtr> ExtractCommonSubexpression::transformExpressions(
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8a0e2478/query_optimizer/rules/ExtractCommonSubexpression.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/rules/ExtractCommonSubexpression.hpp b/query_optimizer/rules/ExtractCommonSubexpression.hpp
index 26b09cc..7d69e00 100644
--- a/query_optimizer/rules/ExtractCommonSubexpression.hpp
+++ b/query_optimizer/rules/ExtractCommonSubexpression.hpp
@@ -34,7 +34,7 @@
#include "query_optimizer/expressions/ExpressionType.hpp"
#include "query_optimizer/expressions/Scalar.hpp"
#include "query_optimizer/physical/Physical.hpp"
-#include "query_optimizer/rules/Rule.hpp"
+#include "query_optimizer/rules/BottomUpRule.hpp"
#include "utility/Macros.hpp"
namespace quickstep {
@@ -54,7 +54,7 @@ class OptimizerContext;
* of the physical passes (e.g. ReuseAggregateExpressions) to be finalized
* before this one to maximize optimization opportunities.
*/
-class ExtractCommonSubexpression : public Rule<physical::Physical> {
+class ExtractCommonSubexpression : public BottomUpRule<physical::Physical> {
public:
/**
* @brief Constructor.
@@ -69,11 +69,10 @@ class ExtractCommonSubexpression : public Rule<physical::Physical> {
return "ExtractCommonSubexpression";
}
- physical::PhysicalPtr apply(const physical::PhysicalPtr &input) override;
+ protected:
+ physical::PhysicalPtr applyToNode(const physical::PhysicalPtr &input) override;
private:
- physical::PhysicalPtr applyInternal(const physical::PhysicalPtr &input);
-
struct ScalarHash {
inline std::size_t operator()(const expressions::ScalarPtr &scalar) const {
return scalar->hash();