[GitHub] incubator-quickstep pull request #300: QUICKSTEP-106: Hash-Join-Fuse: Featur...
Github user asfgit closed the pull request at: https://github.com/apache/incubator-quickstep/pull/300 ---
[GitHub] incubator-quickstep pull request #300: QUICKSTEP-106: Hash-Join-Fuse: Featur...
Github user dylanpbacon commented on a diff in the pull request: https://github.com/apache/incubator-quickstep/pull/300#discussion_r140610972 --- Diff: query_optimizer/strategy/Join.cpp --- @@ -371,6 +373,7 @@ void Join::addHashJoin(const logical::ProjectPtr _project, left_join_attributes, right_join_attributes, residual_predicate, + build_predicate, --- End diff -- Agreed, less superfluous that way. ---
[GitHub] incubator-quickstep pull request #300: QUICKSTEP-106: Hash-Join-Fuse: Featur...
Github user zuyu commented on a diff in the pull request: https://github.com/apache/incubator-quickstep/pull/300#discussion_r140575177 --- Diff: query_optimizer/rules/FuseHashSelect.hpp --- @@ -0,0 +1,67 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + **/ + +#ifndef QUICKSTEP_QUERY_OPTIMIZER_RULES_FUSE_HASH_SELECT_HPP_ +#define QUICKSTEP_QUERY_OPTIMIZER_RULES_FUSE_HASH_SELECT_HPP_ + +#include +#include +#include + + --- End diff -- Remove this duplicated empty line, and unused headers, if any. ---
[GitHub] incubator-quickstep pull request #300: QUICKSTEP-106: Hash-Join-Fuse: Featur...
Github user zuyu commented on a diff in the pull request: https://github.com/apache/incubator-quickstep/pull/300#discussion_r140569985 --- Diff: query_optimizer/ExecutionGenerator.cpp --- @@ -939,6 +939,15 @@ void ExecutionGenerator::convertHashJoin(const P::HashJoinPtr _plan) { query_context_proto_->add_predicates()->CopyFrom(residual_predicate->getProto()); } + // Convert the build predicate proto. + QueryContext::predicate_id build_predicate_index = QueryContext::kInvalidPredicateId; + if (physical_plan->build_predicate()) { +build_predicate_index = query_context_proto_->predicates_size(); + +unique_ptr build_predicate(convertPredicate(physical_plan->build_predicate())); + query_context_proto_->add_predicates()->CopyFrom(build_predicate->getProto()); --- End diff -- Change to `MergeFrom` to avoid an unnecessary reset function call. ---
[GitHub] incubator-quickstep pull request #300: QUICKSTEP-106: Hash-Join-Fuse: Featur...
Github user zuyu commented on a diff in the pull request: https://github.com/apache/incubator-quickstep/pull/300#discussion_r140575077 --- Diff: query_optimizer/rules/FuseHashSelect.cpp --- @@ -0,0 +1,91 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + **/ + +#include "query_optimizer/rules/FuseHashSelect.hpp" + +#include +#include +#include +#include + +#include "query_optimizer/expressions/AttributeReference.hpp" +#include "query_optimizer/expressions/ExpressionUtil.hpp" +#include "query_optimizer/expressions/PatternMatcher.hpp" +#include "query_optimizer/expressions/Predicate.hpp" +#include "query_optimizer/physical/HashJoin.hpp" +#include "query_optimizer/physical/PatternMatcher.hpp" +#include "query_optimizer/physical/Physical.hpp" +#include "query_optimizer/physical/PhysicalType.hpp" +#include "query_optimizer/physical/Selection.hpp" + +#include "glog/logging.h" --- End diff -- Do we actually use sth from all these headers above? If no, please remove the unused headers. ---
[GitHub] incubator-quickstep pull request #300: QUICKSTEP-106: Hash-Join-Fuse: Featur...
Github user zuyu commented on a diff in the pull request: https://github.com/apache/incubator-quickstep/pull/300#discussion_r140570548 --- Diff: query_optimizer/PhysicalGenerator.cpp --- @@ -175,6 +176,8 @@ P::PhysicalPtr PhysicalGenerator::optimizePlan() { rules.push_back(std::make_unique(optimizer_context_)); } + rules.emplace_back(new FuseHashSelect()); --- End diff -- You may want to add a `gflags` with a default `true` value to switch between using this rule or not, w/o rebuilding the binary. ---
[GitHub] incubator-quickstep pull request #300: QUICKSTEP-106: Hash-Join-Fuse: Featur...
Github user zuyu commented on a diff in the pull request: https://github.com/apache/incubator-quickstep/pull/300#discussion_r140575916 --- Diff: query_optimizer/strategy/Join.cpp --- @@ -371,6 +373,7 @@ void Join::addHashJoin(const logical::ProjectPtr _project, left_join_attributes, right_join_attributes, residual_predicate, + build_predicate, --- End diff -- Optionally, I think `E::PredicatePtr() /* build_predicate */,` is better. ---
[GitHub] incubator-quickstep pull request #300: QUICKSTEP-106: Hash-Join-Fuse: Featur...
Github user zuyu commented on a diff in the pull request: https://github.com/apache/incubator-quickstep/pull/300#discussion_r140575606 --- Diff: query_optimizer/rules/FuseHashSelect.hpp --- @@ -0,0 +1,67 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + **/ + +#ifndef QUICKSTEP_QUERY_OPTIMIZER_RULES_FUSE_HASH_SELECT_HPP_ +#define QUICKSTEP_QUERY_OPTIMIZER_RULES_FUSE_HASH_SELECT_HPP_ + +#include +#include +#include + + +#include "query_optimizer/physical/HashJoin.hpp" +#include "query_optimizer/physical/Physical.hpp" +#include "query_optimizer/rules/TopDownRule.hpp" +#include "utility/Macros.hpp" + +namespace quickstep { +namespace optimizer { + +/** \addtogroup OptimizerRules + * @{ + */ + +/** + * @brief Rule that applies to a physical plan to fuse a select node in the + *build predicate of a hash join to the join. + */ +class FuseHashSelect : public TopDownRule { + public: +/** + * @brief Constructor. + */ +FuseHashSelect() {} + +~FuseHashSelect() override {} + +std::string getName() const override { + return "FuseHashSelect"; +} + + protected: +physical::PhysicalPtr applyToNode(const physical::PhysicalPtr ) override; + + private: +DISALLOW_COPY_AND_ASSIGN(FuseHashSelect); +}; + +} // namespace optimizer +} // namespace quickstep + +#endif /* QUICKSTEP_QUERY_OPTIMIZER_RULES_FUSE_HASH_SELECT_HPP_ */ --- End diff -- The new style is `#endif // QUICKSTEP_QUERY_OPTIMIZER_RULES_FUSE_HASH_SELECT_HPP_`. ---