[GitHub] incubator-quickstep pull request #73: Move hash join's probe and build node ...

2016-08-03 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/incubator-quickstep/pull/73


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-quickstep pull request #73: Move hash join's probe and build node ...

2016-08-03 Thread jianqiao
Github user jianqiao commented on a diff in the pull request:

https://github.com/apache/incubator-quickstep/pull/73#discussion_r73290304
  
--- Diff: query_optimizer/rules/BottomUpRule.hpp ---
@@ -80,6 +81,14 @@ class BottomUpRule : public Rule {
*/
   virtual TreeNodePtr applyToNode(const TreeNodePtr ) = 0;
 
+  /**
+   * @brief Initialization code to be used for each node.
--- End diff --

The initialization is only applied with the tree's root node but not "each 
node".
Other places look good. I'll do this minor revision and then merge.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-quickstep pull request #73: Move hash join's probe and build node ...

2016-08-02 Thread jianqiao
Github user jianqiao commented on a diff in the pull request:

https://github.com/apache/incubator-quickstep/pull/73#discussion_r73208331
  
--- Diff: query_optimizer/rules/SwapProbeBuild.hpp ---
@@ -0,0 +1,47 @@
+#ifndef QUICKSTEP_QUERY_OPTIMIZER_RULES_SWAP_PROBE_BUILD_HPP_
+#define QUICKSTEP_QUERY_OPTIMIZER_RULES_SWAP_PROBE_BUILD_HPP_
+
+#include 
--- End diff --

Add `#include ` as `std::unique_ptr` is used in this file.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-quickstep pull request #73: Move hash join's probe and build node ...

2016-08-02 Thread jianqiao
Github user jianqiao commented on a diff in the pull request:

https://github.com/apache/incubator-quickstep/pull/73#discussion_r73207435
  
--- Diff: query_optimizer/rules/SwapProbeBuild.cpp ---
@@ -0,0 +1,64 @@
+#include "query_optimizer/rules/SwapProbeBuild.hpp"
+
+#include 
+#include 
+
+#include "query_optimizer/cost_model/StarSchemaSimpleCostModel.hpp"
+#include "query_optimizer/expressions/AttributeReference.hpp"
+#include "query_optimizer/physical/HashJoin.hpp"
+#include "query_optimizer/physical/PatternMatcher.hpp"
+#include "query_optimizer/physical/Physical.hpp"
+#include "query_optimizer/physical/TopLevelPlan.hpp"
+#include "query_optimizer/rules/Rule.hpp"
+
+
+namespace quickstep {
+namespace optimizer {
+
+P::PhysicalPtr SwapProbeBuild::applyToNode(const P::PhysicalPtr ) {
+  P::HashJoinPtr hash_join;
+
+  if (P::SomeHashJoin::MatchesWithConditionalCast(input, _join)
+  && hash_join->join_type() == P::HashJoin::JoinType::kInnerJoin) {
+P::PhysicalPtr left = hash_join->left();
+P::PhysicalPtr right = hash_join->right();
+
+
+
--- End diff --

Remove the extra blank lines here (at most 1 line).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-quickstep pull request #73: Move hash join's probe and build node ...

2016-08-02 Thread jianqiao
Github user jianqiao commented on a diff in the pull request:

https://github.com/apache/incubator-quickstep/pull/73#discussion_r73204750
  
--- Diff: query_optimizer/rules/BottomUpRule.hpp ---
@@ -80,6 +81,8 @@ class BottomUpRule : public Rule {
*/
   virtual TreeNodePtr applyToNode(const TreeNodePtr ) = 0;
 
+  virtual void init(const TreeNodePtr ) = 0;
--- End diff --

Let's provide a default no-op implementation for `init()` here (instead of 
pure virtual) so we don't have to implement it for every subclass.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-quickstep pull request #73: Move hash join's probe and build node ...

2016-08-02 Thread hakanmemisoglu
Github user hakanmemisoglu commented on a diff in the pull request:

https://github.com/apache/incubator-quickstep/pull/73#discussion_r73118755
  
--- Diff: query_optimizer/rules/SwapProbeBuild.cpp ---
@@ -0,0 +1,72 @@
+#include "query_optimizer/rules/SwapProbeBuild.hpp"
+
+#include 
+#include 
+
+#include "query_optimizer/cost_model/StarSchemaSimpleCostModel.hpp"
+#include "query_optimizer/expressions/AttributeReference.hpp"
+#include "query_optimizer/physical/HashJoin.hpp"
+#include "query_optimizer/physical/PatternMatcher.hpp"
+#include "query_optimizer/physical/Physical.hpp"
+#include "query_optimizer/physical/TopLevelPlan.hpp"
+#include "query_optimizer/rules/Rule.hpp"
+
+
+namespace quickstep {
+namespace optimizer {
+
+P::PhysicalPtr SwapProbeBuild::applyToNode(const P::PhysicalPtr ) {
+  P::HashJoinPtr hash_join;
+
+  if (P::SomeHashJoin::MatchesWithConditionalCast(input, _join)) {
+P::PhysicalPtr left = hash_join->left();
+P::PhysicalPtr right = hash_join->right();
+
+P::TopLevelPlanPtr top_level;
+if (P::SomeTopLevelPlan::MatchesWithConditionalCast(input, 
_level)) {
--- End diff --

@jianqiao , Thanks for the catch. 

> In fact, BottomUpRule does not provide a place for initializing 
cost_model_.

It is the reason why, I have implemented initialization of cost model in 
"applyToNode". 
I will introduce init(const P::PhysicalPtr _level_plan) as you said.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-quickstep pull request #73: Move hash join's probe and build node ...

2016-08-01 Thread zuyu
Github user zuyu commented on a diff in the pull request:

https://github.com/apache/incubator-quickstep/pull/73#discussion_r73080240
  
--- Diff: query_optimizer/rules/SwapProbeBuild.hpp ---
@@ -0,0 +1,46 @@
+#ifndef QUICKSTEP_QUERY_OPTIMIZER_RULES_SWAP_PROBE_BUILD_HPP_
+#define QUICKSTEP_QUERY_OPTIMIZER_RULES_SWAP_PROBE_BUILD_HPP_
+
+#include 
+
+#include "query_optimizer/physical/Physical.hpp"
+#include "query_optimizer/rules/Rule.hpp"
+#include "query_optimizer/rules/BottomUpRule.hpp"
+#include "query_optimizer/cost_model/StarSchemaSimpleCostModel.hpp"
+#include "utility/Macros.hpp"
+
+namespace quickstep {
+namespace optimizer {
+
+/** \addtogroup OptimizerRules
+ *  @{
+ */
+
+namespace P = ::quickstep::optimizer::physical;
+namespace E = ::quickstep::optimizer::expressions;
+namespace C = ::quickstep::optimizer::cost;
+
+/**
+ * @brief Rule that applies to a physical plan to arrange probe and
+ *build side based on the cardinalities.
+ */
+class SwapProbeBuild : public BottomUpRule {
+ public:
+  SwapProbeBuild() {
+  }
+
+  std::string getName() const override { return "SwapProbeBuild"; }
+
+ protected:
+  P::PhysicalPtr applyToNode(const P::PhysicalPtr ) override;
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(SwapProbeBuild);
+
+  std::unique_ptr cost_model_;
--- End diff --

Actually, we should use the base class of the cost model, and initiate some 
implementation as @jianqiao suggested.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-quickstep pull request #73: Move hash join's probe and build node ...

2016-08-01 Thread jianqiao
Github user jianqiao commented on a diff in the pull request:

https://github.com/apache/incubator-quickstep/pull/73#discussion_r73079256
  
--- Diff: query_optimizer/rules/SwapProbeBuild.hpp ---
@@ -0,0 +1,46 @@
+#ifndef QUICKSTEP_QUERY_OPTIMIZER_RULES_SWAP_PROBE_BUILD_HPP_
+#define QUICKSTEP_QUERY_OPTIMIZER_RULES_SWAP_PROBE_BUILD_HPP_
+
+#include 
+
+#include "query_optimizer/physical/Physical.hpp"
+#include "query_optimizer/rules/Rule.hpp"
+#include "query_optimizer/rules/BottomUpRule.hpp"
+#include "query_optimizer/cost_model/StarSchemaSimpleCostModel.hpp"
+#include "utility/Macros.hpp"
+
+namespace quickstep {
+namespace optimizer {
+
+/** \addtogroup OptimizerRules
+ *  @{
+ */
+
+namespace P = ::quickstep::optimizer::physical;
+namespace E = ::quickstep::optimizer::expressions;
+namespace C = ::quickstep::optimizer::cost;
+
+/**
+ * @brief Rule that applies to a physical plan to arrange probe and
+ *build side based on the cardinalities.
+ */
+class SwapProbeBuild : public BottomUpRule {
+ public:
+  SwapProbeBuild() {
+  }
+
+  std::string getName() const override { return "SwapProbeBuild"; }
+
+ protected:
+  P::PhysicalPtr applyToNode(const P::PhysicalPtr ) override;
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(SwapProbeBuild);
+
+  std::unique_ptr cost_model_;
--- End diff --

Currently use `SimpleCostModel` instead of `StarSchemaSimpleCostModel` for 
deciding the build/probe sides.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---