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 4F266200B38 for ; Tue, 31 May 2016 01:21:10 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 4DD79160A19; Mon, 30 May 2016 23:21:10 +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 4D8A2160A3E for ; Tue, 31 May 2016 01:21:09 +0200 (CEST) Received: (qmail 4237 invoked by uid 500); 30 May 2016 23:21:08 -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 4220 invoked by uid 99); 30 May 2016 23:21:08 -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; Mon, 30 May 2016 23:21:08 +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 01D4F1A4844 for ; Mon, 30 May 2016 23:21:08 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.646 X-Spam-Level: X-Spam-Status: No, score=-4.646 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=-1.426] autolearn=disabled Received: from mx2-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id oLZbsh_USQYt for ; Mon, 30 May 2016 23:21:05 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx2-lw-us.apache.org (ASF Mail Server at mx2-lw-us.apache.org) with SMTP id B38BC60D27 for ; Mon, 30 May 2016 23:21:02 +0000 (UTC) Received: (qmail 3096 invoked by uid 99); 30 May 2016 23:21:01 -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; Mon, 30 May 2016 23:21:01 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 33378E7E34; Mon, 30 May 2016 23:21:01 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: zuyuz@apache.org To: commits@quickstep.incubator.apache.org Date: Mon, 30 May 2016 23:21:21 -0000 Message-Id: <3d348e380de649bfb2010d1165f87ca3@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [22/33] incubator-quickstep git commit: Quickstep gen stats (#225) archived-at: Mon, 30 May 2016 23:21:10 -0000 Quickstep gen stats (#225) Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/30f0981d Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/30f0981d Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/30f0981d Branch: refs/heads/travis-grpc Commit: 30f0981db21cb53c9edbb7799a90f0de8979dde7 Parents: be35bb5 Author: Rogers Jeffrey Leo John Authored: Thu May 19 20:31:37 2016 -0500 Committer: Zuyu Zhang Committed: Mon May 30 15:47:52 2016 -0700 ---------------------------------------------------------------------- catalog/Catalog.proto | 2 +- query_optimizer/CMakeLists.txt | 1 + query_optimizer/ExecutionGenerator.cpp | 10 +++ relational_operators/CMakeLists.txt | 11 +++ .../GenerateNumRowsStatsOperator.cpp | 42 +++++++++++ .../GenerateNumRowsStatsOperator.hpp | 79 ++++++++++++++++++++ 6 files changed, 144 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/30f0981d/catalog/Catalog.proto ---------------------------------------------------------------------- diff --git a/catalog/Catalog.proto b/catalog/Catalog.proto index ce4bc2e..8e44181 100644 --- a/catalog/Catalog.proto +++ b/catalog/Catalog.proto @@ -82,7 +82,7 @@ message IndexScheme { message CatalogRelationStatistics { optional fixed64 num_tuples = 1; - + message NumDistinctValuesEntry { required int32 attr_id = 1; required fixed64 num_distinct_values = 2; http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/30f0981d/query_optimizer/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/query_optimizer/CMakeLists.txt b/query_optimizer/CMakeLists.txt index aa2873e..1cc38d1 100644 --- a/query_optimizer/CMakeLists.txt +++ b/query_optimizer/CMakeLists.txt @@ -111,6 +111,7 @@ target_link_libraries(quickstep_queryoptimizer_ExecutionGenerator quickstep_relationaloperators_DestroyHashOperator quickstep_relationaloperators_DropTableOperator quickstep_relationaloperators_FinalizeAggregationOperator + quickstep_relationaloperators_GenerateNumRowsStatsOperator quickstep_relationaloperators_HashJoinOperator quickstep_relationaloperators_InsertOperator quickstep_relationaloperators_NestedLoopsJoinOperator http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/30f0981d/query_optimizer/ExecutionGenerator.cpp ---------------------------------------------------------------------- diff --git a/query_optimizer/ExecutionGenerator.cpp b/query_optimizer/ExecutionGenerator.cpp index c590b6e..612efd9 100644 --- a/query_optimizer/ExecutionGenerator.cpp +++ b/query_optimizer/ExecutionGenerator.cpp @@ -91,6 +91,7 @@ #include "relational_operators/DestroyHashOperator.hpp" #include "relational_operators/DropTableOperator.hpp" #include "relational_operators/FinalizeAggregationOperator.hpp" +#include "relational_operators/GenerateNumRowsStatsOperator.hpp" #include "relational_operators/HashJoinOperator.hpp" #include "relational_operators/InsertOperator.hpp" #include "relational_operators/NestedLoopsJoinOperator.hpp" @@ -947,6 +948,15 @@ void ExecutionGenerator::convertCopyFrom( execution_plan_->addDirectDependency(save_blocks_operator_index, scan_operator_index, false /* is_pipeline_breaker */); + + const QueryPlan::DAGNodeIndex num_rows_operator_index = + execution_plan_->addRelationalOperator(new GenerateNumRowsStatsOperator( + optimizer_context_->catalog_database()->getRelationByIdMutable( + output_relation->getID()))); + insert_destination_proto->set_relational_op_index(num_rows_operator_index); + execution_plan_->addDirectDependency(num_rows_operator_index, + scan_operator_index, + true /* is_pipeline_breaker */); } void ExecutionGenerator::convertCreateIndex( http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/30f0981d/relational_operators/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/relational_operators/CMakeLists.txt b/relational_operators/CMakeLists.txt index eec5300..e211630 100644 --- a/relational_operators/CMakeLists.txt +++ b/relational_operators/CMakeLists.txt @@ -34,6 +34,9 @@ add_library(quickstep_relationaloperators_DropTableOperator DropTableOperator.cp add_library(quickstep_relationaloperators_FinalizeAggregationOperator FinalizeAggregationOperator.cpp FinalizeAggregationOperator.hpp) +add_library(quickstep_relationaloperators_GenerateNumRowsStatsOperator + GenerateNumRowsStatsOperator.cpp + GenerateNumRowsStatsOperator.hpp) add_library(quickstep_relationaloperators_HashJoinOperator HashJoinOperator.cpp HashJoinOperator.hpp) add_library(quickstep_relationaloperators_InsertOperator InsertOperator.cpp InsertOperator.hpp) add_library(quickstep_relationaloperators_NestedLoopsJoinOperator @@ -159,6 +162,13 @@ target_link_libraries(quickstep_relationaloperators_FinalizeAggregationOperator quickstep_storage_AggregationOperationState quickstep_utility_Macros tmb) +target_link_libraries(quickstep_relationaloperators_GenerateNumRowsStatsOperator + glog + quickstep_catalog_CatalogRelation + quickstep_cli_PrintToScreen + quickstep_relationaloperators_RelationalOperator + quickstep_utility_Macros + tmb) target_link_libraries(quickstep_relationaloperators_HashJoinOperator gflags_nothreads-static glog @@ -446,6 +456,7 @@ target_link_libraries(quickstep_relationaloperators quickstep_relationaloperators_DestroyHashOperator quickstep_relationaloperators_DropTableOperator quickstep_relationaloperators_FinalizeAggregationOperator + quickstep_relationaloperators_GenerateNumRowsStatsOperator quickstep_relationaloperators_HashJoinOperator quickstep_relationaloperators_InsertOperator quickstep_relationaloperators_NestedLoopsJoinOperator http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/30f0981d/relational_operators/GenerateNumRowsStatsOperator.cpp ---------------------------------------------------------------------- diff --git a/relational_operators/GenerateNumRowsStatsOperator.cpp b/relational_operators/GenerateNumRowsStatsOperator.cpp new file mode 100644 index 0000000..074e1ca --- /dev/null +++ b/relational_operators/GenerateNumRowsStatsOperator.cpp @@ -0,0 +1,42 @@ +/** + * Copyright 2016, Quickstep Research Group, Computer Sciences Department, + * University of Wisconsin—Madison. + * + * Licensed 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 "relational_operators/GenerateNumRowsStatsOperator.hpp" + +#include + +#include "catalog/CatalogRelation.hpp" +#include "cli/PrintToScreen.hpp" + +#include "tmb/id_typedefs.h" + +namespace quickstep { + +bool GenerateNumRowsStatsOperator::getAllWorkOrders( + WorkOrdersContainer *container, + QueryContext *query_context, + StorageManager *storage_manager, + const tmb::client_id scheduler_client_id, + tmb::MessageBus *bus) { + std::size_t num_tuples = + PrintToScreen::GetNumTuplesInRelation(*relation_, storage_manager); + relation_->getStatisticsMutable()->setNumTuples(num_tuples); + return true; +} + +} // namespace quickstep + http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/30f0981d/relational_operators/GenerateNumRowsStatsOperator.hpp ---------------------------------------------------------------------- diff --git a/relational_operators/GenerateNumRowsStatsOperator.hpp b/relational_operators/GenerateNumRowsStatsOperator.hpp new file mode 100644 index 0000000..8622a63 --- /dev/null +++ b/relational_operators/GenerateNumRowsStatsOperator.hpp @@ -0,0 +1,79 @@ +/** + * Copyright 2016, Quickstep Research Group, Computer Sciences Department, + * University of Wisconsin—Madison. + * + * Licensed 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_RELATIONAL_OPERATORS_GENERATE_NUM_ROWS_STATS_OPERATOR_HPP_ +#define QUICKSTEP_RELATIONAL_OPERATORS_GENERATE_NUM_ROWS_STATS_OPERATOR_HPP_ + +#include + +#include "catalog/CatalogRelation.hpp" +#include "relational_operators/RelationalOperator.hpp" +#include "utility/Macros.hpp" + +#include "glog/logging.h" + +#include "tmb/id_typedefs.h" + +namespace tmb { class MessageBus; } + +namespace quickstep { + +class CatalogRelation; +class QueryContext; +class StorageManager; +class WorkOrdersContainer; + +/** \addtogroup RelationalOperators + * @{ + */ + +/** + * @brief An operator that gets the number of rows after loading a relation. + **/ +class GenerateNumRowsStatsOperator : public RelationalOperator { + public: + /** + * @brief Constructor. + * + * @param relation The relation to get the number of rows from. + * This GenNumRowStatsOperator owns relation until + * the WorkOrder it produces is successfully executed. + **/ + explicit GenerateNumRowsStatsOperator(CatalogRelation *relation) + : relation_(relation) {} + ~GenerateNumRowsStatsOperator() override {} + + /** + * @note no WorkOrder is generated for this operator. + **/ + bool getAllWorkOrders(WorkOrdersContainer *container, + QueryContext *query_context, + StorageManager *storage_manager, + const tmb::client_id scheduler_client_id, + tmb::MessageBus *bus) override; + + private: + CatalogRelation *relation_; + + DISALLOW_COPY_AND_ASSIGN(GenerateNumRowsStatsOperator); +}; + +/** @} */ + +} // namespace quickstep + +#endif // QUICKSTEP_RELATIONAL_OPERATORS_GENERATE_NUM_ROWS_STATS_OPERATOR_HPP_