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 05413200C1B for ; Tue, 31 Jan 2017 05:21:37 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 03C7A160B61; Tue, 31 Jan 2017 04:21:37 +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 2F46D160B4D for ; Tue, 31 Jan 2017 05:21:36 +0100 (CET) Received: (qmail 64014 invoked by uid 500); 31 Jan 2017 04:21:35 -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 63994 invoked by uid 99); 31 Jan 2017 04:21:34 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 31 Jan 2017 04:21:34 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id B3087181A94 for ; Tue, 31 Jan 2017 04:21:33 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -6.219 X-Spam-Level: X-Spam-Status: No, score=-6.219 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id xD6UWlWw6EFE for ; Tue, 31 Jan 2017 04:21:32 +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 EB2A95F46D for ; Tue, 31 Jan 2017 04:21:30 +0000 (UTC) Received: (qmail 63987 invoked by uid 99); 31 Jan 2017 04:21:30 -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, 31 Jan 2017 04:21:30 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 0B460DFE46; Tue, 31 Jan 2017 04:21:30 +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 Date: Tue, 31 Jan 2017 04:21:31 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [2/2] incubator-quickstep git commit: Minor refactor for HashJoinInnerJoin. archived-at: Tue, 31 Jan 2017 04:21:37 -0000 Minor refactor for HashJoinInnerJoin. Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/23e14b8e Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/23e14b8e Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/23e14b8e Branch: refs/heads/refactor-inner-join Commit: 23e14b8e078f42a8d3e5f6c0c4885dee271d99aa Parents: f2e7726 Author: Zuyu Zhang Authored: Mon Jan 30 15:28:49 2017 -0800 Committer: Zuyu Zhang Committed: Mon Jan 30 20:21:23 2017 -0800 ---------------------------------------------------------------------- relational_operators/CMakeLists.txt | 1 + relational_operators/HashJoinOperator.cpp | 42 ++++++++++++++------------ 2 files changed, 23 insertions(+), 20 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/23e14b8e/relational_operators/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/relational_operators/CMakeLists.txt b/relational_operators/CMakeLists.txt index c1caaa3..b2e08cf 100644 --- a/relational_operators/CMakeLists.txt +++ b/relational_operators/CMakeLists.txt @@ -199,6 +199,7 @@ target_link_libraries(quickstep_relationaloperators_FinalizeAggregationOperator target_link_libraries(quickstep_relationaloperators_HashJoinOperator ${GFLAGS_LIB_NAME} glog + quickstep_catalog_CatalogAttribute quickstep_catalog_CatalogRelation quickstep_catalog_CatalogRelationSchema quickstep_catalog_CatalogTypedefs http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/23e14b8e/relational_operators/HashJoinOperator.cpp ---------------------------------------------------------------------- diff --git a/relational_operators/HashJoinOperator.cpp b/relational_operators/HashJoinOperator.cpp index fd3841f..7394554 100644 --- a/relational_operators/HashJoinOperator.cpp +++ b/relational_operators/HashJoinOperator.cpp @@ -25,6 +25,7 @@ #include #include +#include "catalog/CatalogAttribute.hpp" #include "catalog/CatalogRelation.hpp" #include "catalog/CatalogRelationSchema.hpp" #include "catalog/CatalogTypedefs.hpp" @@ -165,6 +166,12 @@ class OuterJoinTupleCollector { TupleIdSequence *filter_; }; +// For InnerJoin. +constexpr std::size_t kNumValueAccessors = 3u; +constexpr std::size_t kBuildValueAccessorIndex = 0, + kProbeValueAccessorIndex = 1u, + kTempResultValueAccessorIndex = 2u; + } // namespace bool HashJoinOperator::getAllWorkOrders( @@ -565,31 +572,27 @@ void HashInnerJoinWorkOrder::execute() { }); } - // We also need a temp value accessor to store results of any scalar expressions. ColumnVectorsValueAccessor temp_result; // Create a map of ValueAccessors and what attributes we want to pick from them - std::vector>> accessor_attribute_map; - const std::vector accessors{ - ordered_build_accessor.get(), ordered_probe_accessor.get(), &temp_result}; - const unsigned int build_index = 0, probe_index = 1, temp_index = 2; - for (auto &accessor : accessors) { - accessor_attribute_map.push_back(std::make_pair( - accessor, - std::vector(selection_.size(), kInvalidCatalogId))); - } + std::vector>> accessor_attribute_map( + kNumValueAccessors, std::make_pair(nullptr, // A late binding ValueAccessor. + vector(selection_.size(), kInvalidCatalogId))); - attribute_id dest_attr = 0; - std::vector> zipped_joined_tuple_ids; + accessor_attribute_map[kBuildValueAccessorIndex].first = ordered_build_accessor.get(); + accessor_attribute_map[kProbeValueAccessorIndex].first = ordered_probe_accessor.get(); + accessor_attribute_map[kTempResultValueAccessorIndex].first = &temp_result; + attribute_id dest_attr = 0; for (auto &selection_cit : selection_) { // If the Scalar (column) is not an attribute in build/probe blocks, then // insert it into a ColumnVectorsValueAccessor. if (selection_cit->getDataSource() != Scalar::ScalarDataSource::kAttribute) { // Current destination attribute maps to the column we'll create now. - accessor_attribute_map[temp_index].second[dest_attr] = temp_result.getNumColumns(); + accessor_attribute_map[kTempResultValueAccessorIndex].second[dest_attr] = temp_result.getNumColumns(); + std::vector> zipped_joined_tuple_ids; if (temp_result.getNumColumns() == 0) { // The getAllValuesForJoin function below needs joined tuple IDs as // a vector of pair of (build-tuple-ID, probe-tuple-ID), and we have @@ -599,9 +602,8 @@ void HashInnerJoinWorkOrder::execute() { // they don't have scalar expressions with attributes from both // build and probe relations (other expressions would have been // pushed down to before the join). - zipped_joined_tuple_ids.reserve(build_tids.size()); for (std::size_t i = 0; i < build_tids.size(); ++i) { - zipped_joined_tuple_ids.push_back(std::make_pair(build_tids[i], probe_tids[i])); + zipped_joined_tuple_ids.emplace_back(build_tids[i], probe_tids[i]); } } temp_result.addColumn( @@ -610,12 +612,12 @@ void HashInnerJoinWorkOrder::execute() { probe_relation_id, probe_accessor.get(), zipped_joined_tuple_ids)); } else { - auto scalar_attr = static_cast(selection_cit.get()); - const attribute_id attr_id = scalar_attr->getAttribute().getID(); - if (scalar_attr->getAttribute().getParent().getID() == build_relation_id) { - accessor_attribute_map[build_index].second[dest_attr] = attr_id; + const CatalogAttribute &attr = static_cast(selection_cit.get())->getAttribute(); + const attribute_id attr_id = attr.getID(); + if (attr.getParent().getID() == build_relation_id) { + accessor_attribute_map[kBuildValueAccessorIndex].second[dest_attr] = attr_id; } else { - accessor_attribute_map[probe_index].second[dest_attr] = attr_id; + accessor_attribute_map[kProbeValueAccessorIndex].second[dest_attr] = attr_id; } } ++dest_attr;