Changes due to rebasing.
Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/402c99a4 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/402c99a4 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/402c99a4 Branch: refs/heads/partitioned-aggregation Commit: 402c99a4639c37bd055b7e4c1ca3e341245f0fb5 Parents: 1db46d6 Author: Harshad Deshmukh <hbdeshm...@apache.org> Authored: Tue Sep 6 15:14:16 2016 -0500 Committer: Harshad Deshmukh <hbdeshm...@apache.org> Committed: Tue Sep 20 12:57:06 2016 -0500 ---------------------------------------------------------------------- query_execution/QueryContext.hpp | 11 --------- relational_operators/CMakeLists.txt | 1 - storage/AggregationOperationState.cpp | 36 ++++++++++++++++-------------- storage/AggregationOperationState.hpp | 3 +++ storage/CMakeLists.txt | 1 + storage/StorageBlock.cpp | 8 ++++--- 6 files changed, 28 insertions(+), 32 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/402c99a4/query_execution/QueryContext.hpp ---------------------------------------------------------------------- diff --git a/query_execution/QueryContext.hpp b/query_execution/QueryContext.hpp index f6c08ba..a69f607 100644 --- a/query_execution/QueryContext.hpp +++ b/query_execution/QueryContext.hpp @@ -195,17 +195,6 @@ class QueryContext { } /** - * @brief Destroy the given aggregation state. - * - * @param id The ID of the AggregationOperationState to destroy. - **/ - inline void destroyAggregationState(const aggregation_state_id id) { - DCHECK_LT(id, aggregation_states_.size()); - DCHECK(aggregation_states_[id]); - aggregation_states_[id].reset(nullptr); - } - - /** * @brief Whether the given BloomFilter id is valid. * * @param id The BloomFilter id. http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/402c99a4/relational_operators/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/relational_operators/CMakeLists.txt b/relational_operators/CMakeLists.txt index 2632995..a87e370 100644 --- a/relational_operators/CMakeLists.txt +++ b/relational_operators/CMakeLists.txt @@ -44,7 +44,6 @@ add_library(quickstep_relationaloperators_DestroyAggregationStateOperator DestroyAggregationStateOperator.cpp DestroyAggregationStateOperator.hpp) add_library(quickstep_relationaloperators_DeleteOperator DeleteOperator.cpp DeleteOperator.hpp) -add_library(quickstep_relationaloperators_DestroyAggregationStateOperator DestroyAggregationStateOperator.cpp DestroyAggregationStateOperator.hpp) add_library(quickstep_relationaloperators_DestroyHashOperator DestroyHashOperator.cpp DestroyHashOperator.hpp) add_library(quickstep_relationaloperators_DropTableOperator DropTableOperator.cpp DropTableOperator.hpp) add_library(quickstep_relationaloperators_FinalizeAggregationOperator http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/402c99a4/storage/AggregationOperationState.cpp ---------------------------------------------------------------------- diff --git a/storage/AggregationOperationState.cpp b/storage/AggregationOperationState.cpp index 66c4a83..2e88e70 100644 --- a/storage/AggregationOperationState.cpp +++ b/storage/AggregationOperationState.cpp @@ -68,7 +68,10 @@ AggregationOperationState::AggregationOperationState( const HashTableImplType hash_table_impl_type, const std::vector<HashTableImplType> &distinctify_hash_table_impl_types, StorageManager *storage_manager) - : is_aggregate_partitioned_(estimated_num_entries > kPartitionedAggregateThreshold && !group_by.empty()), + : is_aggregate_partitioned_( + estimated_num_entries > kPartitionedAggregateThreshold && + !group_by.empty() && !aggregate_functions.empty()), + // Use partitioned aggregation only for non-distinct group by. input_relation_(input_relation), predicate_(predicate), group_by_list_(std::move(group_by)), @@ -197,13 +200,12 @@ AggregationOperationState::AggregationOperationState( if (!group_by_handles.empty()) { // Aggregation with GROUP BY: create a HashTable pool for per-group states. if (!is_aggregate_partitioned_) { - group_by_hashtable_pools_.emplace_back(std::unique_ptr<HashTablePool>( - new HashTablePool(estimated_num_entries, - hash_table_impl_type, - group_by_types, - payload_sizes, - group_by_handles, - storage_manager))); + group_by_hashtable_pool_.reset(new HashTablePool(estimated_num_entries, + hash_table_impl_type, + group_by_types, + payload_sizes, + group_by_handles, + storage_manager)); } else { partitioned_group_by_hashtable_pool_.reset( @@ -457,16 +459,16 @@ void AggregationOperationState::aggregateBlockHashTable( // Call StorageBlock::aggregateGroupBy() to aggregate this block's values // directly into the (threadsafe) shared global HashTable for this // aggregate. - DCHECK(group_by_hashtable_pools_[0] != nullptr); - AggregationStateHashTableBase *agg_hash_table = group_by_hashtable_pools_[0]->getHashTableFast(); + DCHECK(group_by_hashtable_pool_ != nullptr); + AggregationStateHashTableBase *agg_hash_table = group_by_hashtable_pool_->getHashTableFast(); DCHECK(agg_hash_table != nullptr); - block->aggregateGroupByFast(arguments_, - group_by_list_, - predicate_.get(), - agg_hash_table, - &reuse_matches, - &reuse_group_by_vectors); - group_by_hashtable_pools_[0]->returnHashTable(agg_hash_table); + block->aggregateGroupBy(arguments_, + group_by_list_, + predicate_.get(), + agg_hash_table, + &reuse_matches, + &reuse_group_by_vectors); + group_by_hashtable_pool_->returnHashTable(agg_hash_table); } else { block->aggregateGroupByPartitioned( arguments_, http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/402c99a4/storage/AggregationOperationState.hpp ---------------------------------------------------------------------- diff --git a/storage/AggregationOperationState.hpp b/storage/AggregationOperationState.hpp index ab82c2e..ca63055 100644 --- a/storage/AggregationOperationState.hpp +++ b/storage/AggregationOperationState.hpp @@ -205,6 +205,9 @@ class AggregationOperationState { } } + static void mergeGroupByHashTables(AggregationStateHashTableBase *src, + AggregationStateHashTableBase *dst); + int dflag; private: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/402c99a4/storage/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/storage/CMakeLists.txt b/storage/CMakeLists.txt index 3d6e8d4..81b4dae 100644 --- a/storage/CMakeLists.txt +++ b/storage/CMakeLists.txt @@ -981,6 +981,7 @@ target_link_libraries(quickstep_storage_StorageBlock quickstep_storage_IndexSubBlock quickstep_storage_InsertDestinationInterface quickstep_storage_PackedRowStoreTupleStorageSubBlock + quickstep_storage_PartitionedHashTablePool quickstep_storage_SMAIndexSubBlock quickstep_storage_SplitRowStoreTupleStorageSubBlock quickstep_storage_StorageBlockBase http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/402c99a4/storage/StorageBlock.cpp ---------------------------------------------------------------------- diff --git a/storage/StorageBlock.cpp b/storage/StorageBlock.cpp index 5ba2a6e..94c46a8 100644 --- a/storage/StorageBlock.cpp +++ b/storage/StorageBlock.cpp @@ -1386,7 +1386,7 @@ void StorageBlock::aggregateGroupByPartitioned( // IDs of 'arguments' as attributes in the ValueAccessor we create below. std::vector<attribute_id> arg_ids; - std::vector<std::vector<attribute_id>> argument_ids; + std::vector<attribute_id> argument_ids; // IDs of GROUP BY key element(s) in the ValueAccessor we create below. std::vector<attribute_id> key_ids; @@ -1440,9 +1440,11 @@ void StorageBlock::aggregateGroupByPartitioned( arg_ids.clear(); for (const std::unique_ptr<const Scalar> &args : argument) { temp_result.addColumn(args->getAllValues(accessor.get(), &sub_blocks_ref)); - arg_ids.push_back(attr_id++); + argument_ids.push_back(attr_id++); + } + if (argument.empty()) { + argument_ids.push_back(kInvalidAttributeID); } - argument_ids.push_back(arg_ids); } // Compute the partitions for the tuple formed by group by values.