Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id CB174200CBC for ; Tue, 20 Jun 2017 23:41:53 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id C92DA160BE1; Tue, 20 Jun 2017 21:41:53 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id E9218160BCC for ; Tue, 20 Jun 2017 23:41:52 +0200 (CEST) Received: (qmail 56332 invoked by uid 500); 20 Jun 2017 21:41:51 -0000 Mailing-List: contact commits-help@quickstep.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@quickstep.incubator.apache.org Delivered-To: mailing list commits@quickstep.incubator.apache.org Received: (qmail 56323 invoked by uid 99); 20 Jun 2017 21:41:51 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Jun 2017 21:41:51 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 6B7C01B0F30 for ; Tue, 20 Jun 2017 21:41:51 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.222 X-Spam-Level: X-Spam-Status: No, score=-4.222 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id mEmyV4LBlKpE for ; Tue, 20 Jun 2017 21:41:49 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id 31BA35F523 for ; Tue, 20 Jun 2017 21:41:48 +0000 (UTC) Received: (qmail 56310 invoked by uid 99); 20 Jun 2017 21:41:47 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Jun 2017 21:41:47 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 27960DFC2E; Tue, 20 Jun 2017 21:41:47 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: zuyuz@apache.org To: commits@quickstep.incubator.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: incubator-quickstep git commit: Refactored Create Factory Method for Physical Selection. Date: Tue, 20 Jun 2017 21:41:47 +0000 (UTC) archived-at: Tue, 20 Jun 2017 21:41:54 -0000 Repository: incubator-quickstep Updated Branches: refs/heads/master 261c955ad -> 85b537451 Refactored Create Factory Method for Physical Selection. Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/85b53745 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/85b53745 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/85b53745 Branch: refs/heads/master Commit: 85b537451d7684befbaebb263ed983e440c1eb30 Parents: 261c955 Author: Zuyu Zhang Authored: Tue Jun 20 15:42:31 2017 -0500 Committer: Zuyu Zhang Committed: Tue Jun 20 15:42:31 2017 -0500 ---------------------------------------------------------------------- query_optimizer/physical/Selection.cpp | 25 -------------------- query_optimizer/physical/Selection.hpp | 5 +++- query_optimizer/rules/CollapseSelection.cpp | 3 ++- .../rules/ExtractCommonSubexpression.cpp | 3 ++- .../PushDownLowCostDisjunctivePredicate.cpp | 3 ++- query_optimizer/rules/ReorderColumns.cpp | 3 ++- query_optimizer/strategy/Selection.cpp | 17 ++++++++++++- 7 files changed, 28 insertions(+), 31 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/85b53745/query_optimizer/physical/Selection.cpp ---------------------------------------------------------------------- diff --git a/query_optimizer/physical/Selection.cpp b/query_optimizer/physical/Selection.cpp index e2fa69e..3307e9e 100644 --- a/query_optimizer/physical/Selection.cpp +++ b/query_optimizer/physical/Selection.cpp @@ -42,31 +42,6 @@ namespace physical { namespace E = ::quickstep::optimizer::expressions; -SelectionPtr Selection::Create( - const PhysicalPtr &input, - const std::vector &project_expressions, - const E::PredicatePtr &filter_predicate, - PartitionSchemeHeader *output_partition_scheme_header) { - std::unique_ptr partition_scheme_header(output_partition_scheme_header); - - if (!partition_scheme_header) { - const PartitionSchemeHeader *input_partition_scheme_header = input->getOutputPartitionSchemeHeader(); - if (input_partition_scheme_header) { - unordered_set project_expr_ids; - for (const E::NamedExpressionPtr &project_expression : project_expressions) { - project_expr_ids.insert(project_expression->id()); - } - - if (input_partition_scheme_header->reusablePartitionScheme(project_expr_ids)) { - partition_scheme_header = std::make_unique(*input_partition_scheme_header); - } - } - } - - return SelectionPtr( - new Selection(input, project_expressions, filter_predicate, partition_scheme_header.release())); -} - PhysicalPtr Selection::copyWithNewChildren( const std::vector &new_children) const { DCHECK_EQ(children().size(), new_children.size()); http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/85b53745/query_optimizer/physical/Selection.hpp ---------------------------------------------------------------------- diff --git a/query_optimizer/physical/Selection.hpp b/query_optimizer/physical/Selection.hpp index 204eb2f..4cbc856 100644 --- a/query_optimizer/physical/Selection.hpp +++ b/query_optimizer/physical/Selection.hpp @@ -109,7 +109,10 @@ class Selection : public Physical { const PhysicalPtr &input, const std::vector &project_expressions, const expressions::PredicatePtr &filter_predicate, - PartitionSchemeHeader *output_partition_scheme_header = nullptr); + PartitionSchemeHeader *output_partition_scheme_header = nullptr) { + return SelectionPtr( + new Selection(input, project_expressions, filter_predicate, output_partition_scheme_header)); + } /** * @brief Creates a conjunctive predicate with \p filter_predicates http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/85b53745/query_optimizer/rules/CollapseSelection.cpp ---------------------------------------------------------------------- diff --git a/query_optimizer/rules/CollapseSelection.cpp b/query_optimizer/rules/CollapseSelection.cpp index f92e1b2..fc45ffd 100644 --- a/query_optimizer/rules/CollapseSelection.cpp +++ b/query_optimizer/rules/CollapseSelection.cpp @@ -49,7 +49,8 @@ P::PhysicalPtr CollapseSelection::applyToNode(const P::PhysicalPtr &input) { { &project_expressions } /* project_expression_lists */); return P::Selection::Create(child_selection->input(), project_expressions, - selection->filter_predicate()); + selection->filter_predicate(), + child_selection->input()->cloneOutputPartitionSchemeHeader()); } return input; http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/85b53745/query_optimizer/rules/ExtractCommonSubexpression.cpp ---------------------------------------------------------------------- diff --git a/query_optimizer/rules/ExtractCommonSubexpression.cpp b/query_optimizer/rules/ExtractCommonSubexpression.cpp index 8b68bd2..4c4d33e 100644 --- a/query_optimizer/rules/ExtractCommonSubexpression.cpp +++ b/query_optimizer/rules/ExtractCommonSubexpression.cpp @@ -151,7 +151,8 @@ P::PhysicalPtr ExtractCommonSubexpression::applyToNode( if (new_expressions != selection->project_expressions()) { return P::Selection::Create(selection->input(), new_expressions, - selection->filter_predicate()); + selection->filter_predicate(), + selection->input()->cloneOutputPartitionSchemeHeader()); } break; } http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/85b53745/query_optimizer/rules/PushDownLowCostDisjunctivePredicate.cpp ---------------------------------------------------------------------- diff --git a/query_optimizer/rules/PushDownLowCostDisjunctivePredicate.cpp b/query_optimizer/rules/PushDownLowCostDisjunctivePredicate.cpp index 1c71485..69cc299 100644 --- a/query_optimizer/rules/PushDownLowCostDisjunctivePredicate.cpp +++ b/query_optimizer/rules/PushDownLowCostDisjunctivePredicate.cpp @@ -195,7 +195,8 @@ P::PhysicalPtr PushDownLowCostDisjunctivePredicate::attachPredicates( const P::PhysicalPtr selection = P::Selection::Create(output, E::ToNamedExpressions(output->getOutputAttributes()), - CreateConjunctive(node_it->second.predicates)); + CreateConjunctive(node_it->second.predicates), + output->cloneOutputPartitionSchemeHeader()); // Applicable case 1: The stored relation has small cardinality. const bool is_small_cardinality_relation = http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/85b53745/query_optimizer/rules/ReorderColumns.cpp ---------------------------------------------------------------------- diff --git a/query_optimizer/rules/ReorderColumns.cpp b/query_optimizer/rules/ReorderColumns.cpp index f7e58d5..4783a8d 100644 --- a/query_optimizer/rules/ReorderColumns.cpp +++ b/query_optimizer/rules/ReorderColumns.cpp @@ -189,7 +189,8 @@ P::PhysicalPtr ReorderColumns::applyInternal(const P::PhysicalPtr &input, std::static_pointer_cast(node); output = P::Selection::Create(output, project_expressions, - old_node->filter_predicate()); + old_node->filter_predicate(), + output->cloneOutputPartitionSchemeHeader()); break; } default: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/85b53745/query_optimizer/strategy/Selection.cpp ---------------------------------------------------------------------- diff --git a/query_optimizer/strategy/Selection.cpp b/query_optimizer/strategy/Selection.cpp index 2fbcdec..d738921 100644 --- a/query_optimizer/strategy/Selection.cpp +++ b/query_optimizer/strategy/Selection.cpp @@ -119,8 +119,23 @@ void Selection::addSelection( } } + std::unique_ptr physical_output_partition_scheme_header; + const P::PartitionSchemeHeader *physical_input_partition_scheme_header = + physical_input->getOutputPartitionSchemeHeader(); + if (physical_input_partition_scheme_header) { + std::unordered_set project_expr_ids; + for (const E::NamedExpressionPtr &project_expression : project_expressions) { + project_expr_ids.insert(project_expression->id()); + } + + if (physical_input_partition_scheme_header->reusablePartitionScheme(project_expr_ids)) { + physical_output_partition_scheme_header = + std::make_unique(*physical_input_partition_scheme_header); + } + } + *physical_output = P::Selection::Create(physical_input, project_expressions, - filter_predicate); + filter_predicate, physical_output_partition_scheme_header.release()); } } // namespace strategy