[5/6] incubator-quickstep git commit: Updates

2016-11-01 Thread hbdeshmukh
Updates


Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/584461ab
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/584461ab
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/584461ab

Branch: refs/heads/delay-hashtable-memory-alloc
Commit: 584461ab9539a13c316f928419842b2e60660b34
Parents: f54d1a2
Author: Harshad Deshmukh 
Authored: Tue Nov 1 16:17:03 2016 -0500
Committer: Harshad Deshmukh 
Committed: Tue Nov 1 16:56:38 2016 -0500

--
 query_execution/QueryContext.hpp   | 9 +
 query_execution/QueryContext.proto | 2 ++
 query_optimizer/ExecutionGenerator.cpp | 3 +++
 3 files changed, 14 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/584461ab/query_execution/QueryContext.hpp
--
diff --git a/query_execution/QueryContext.hpp b/query_execution/QueryContext.hpp
index 7ad8fa1..820cbb6 100644
--- a/query_execution/QueryContext.hpp
+++ b/query_execution/QueryContext.hpp
@@ -133,6 +133,11 @@ class QueryContext {
   typedef std::uint32_t window_aggregation_state_id;
 
   /**
+   * @brief A unique identifier of a relational operator in the DAG.
+   **/
+  typedef std::uint32_t dag_operator_id;
+
+  /**
* @brief Constructor.
*
* @param proto A serialized Protocol Buffer representation of a
@@ -575,6 +580,10 @@ class QueryContext {
   std::vector>> 
update_groups_;
   std::vector> 
window_aggregation_states_;
 
+  // The IDs of the BuildHashOperator nodes in the query plan DAG.
+  // This vector has a 1-1 correspondence with join_hash_tables_ vector.
+  std::vector build_hash_operator_ids_;
+
   DISALLOW_COPY_AND_ASSIGN(QueryContext);
 };
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/584461ab/query_execution/QueryContext.proto
--
diff --git a/query_execution/QueryContext.proto 
b/query_execution/QueryContext.proto
index ab0f520..f8831db 100644
--- a/query_execution/QueryContext.proto
+++ b/query_execution/QueryContext.proto
@@ -62,4 +62,6 @@ message QueryContext {
   repeated WindowAggregationOperationState window_aggregation_states = 12;
 
   required uint64 query_id = 13;
+
+  repeated uint32 build_hash_operator_ids = 14;
 }

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/584461ab/query_optimizer/ExecutionGenerator.cpp
--
diff --git a/query_optimizer/ExecutionGenerator.cpp 
b/query_optimizer/ExecutionGenerator.cpp
index 2e0d8f3..545f539 100644
--- a/query_optimizer/ExecutionGenerator.cpp
+++ b/query_optimizer/ExecutionGenerator.cpp
@@ -729,6 +729,9 @@ void ExecutionGenerator::convertHashJoin(const 
P::HashJoinPtr &physical_plan) {
   any_build_attributes_nullable,
   join_hash_table_index));
 
+  // Add the index of build operator to QueryContext.
+  query_context_proto_->add_build_hash_operator_ids(build_operator_index);
+
   // Create InsertDestination proto.
   const CatalogRelation *output_relation = nullptr;
   const QueryContext::insert_destination_id insert_destination_index =



[5/6] incubator-quickstep git commit: Updates

2016-10-17 Thread jianqiao
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/9ccd5a31/expressions/aggregation/AggregationHandleMax.cpp
--
diff --git a/expressions/aggregation/AggregationHandleMax.cpp 
b/expressions/aggregation/AggregationHandleMax.cpp
index c2d571b..d40ae9f 100644
--- a/expressions/aggregation/AggregationHandleMax.cpp
+++ b/expressions/aggregation/AggregationHandleMax.cpp
@@ -38,100 +38,100 @@ namespace quickstep {
 
 class StorageManager;
 
-AggregationHandleMax::AggregationHandleMax(const Type &type)
-: type_(type), block_update_(false) {
-  fast_comparator_.reset(
-  ComparisonFactory::GetComparison(ComparisonID::kGreater)
-  .makeUncheckedComparatorForTypes(type, 
type.getNonNullableVersion()));
-}
-
-AggregationStateHashTableBase* AggregationHandleMax::createGroupByHashTable(
-const HashTableImplType hash_table_impl,
-const std::vector &group_by_types,
-const std::size_t estimated_num_groups,
-StorageManager *storage_manager) const {
-  return 
AggregationStateHashTableFactory::CreateResizable(
-  hash_table_impl, group_by_types, estimated_num_groups, storage_manager);
-}
-
-AggregationState* AggregationHandleMax::accumulateColumnVectors(
-const std::vector> &column_vectors) const {
-  DCHECK_EQ(1u, column_vectors.size())
-  << "Got wrong number of ColumnVectors for MAX: " << 
column_vectors.size();
-
-  return new AggregationStateMax(fast_comparator_->accumulateColumnVector(
-  type_.getNullableVersion().makeNullValue(), *column_vectors.front()));
-}
-
-#ifdef QUICKSTEP_ENABLE_VECTOR_COPY_ELISION_SELECTION
-AggregationState* AggregationHandleMax::accumulateValueAccessor(
-ValueAccessor *accessor,
-const std::vector &accessor_ids) const {
-  DCHECK_EQ(1u, accessor_ids.size())
-  << "Got wrong number of attributes for MAX: " << accessor_ids.size();
-
-  return new AggregationStateMax(fast_comparator_->accumulateValueAccessor(
-  type_.getNullableVersion().makeNullValue(),
-  accessor,
-  accessor_ids.front()));
-}
-#endif  // QUICKSTEP_ENABLE_VECTOR_COPY_ELISION_SELECTION
-
-void AggregationHandleMax::aggregateValueAccessorIntoHashTable(
-ValueAccessor *accessor,
-const std::vector &argument_ids,
-const std::vector &group_by_key_ids,
-AggregationStateHashTableBase *hash_table) const {
-  DCHECK_EQ(1u, argument_ids.size())
-  << "Got wrong number of arguments for MAX: " << argument_ids.size();
-}
-
-void AggregationHandleMax::mergeStates(const AggregationState &source,
-   AggregationState *destination) const {
-  const AggregationStateMax &max_source =
-  static_cast(source);
-  AggregationStateMax *max_destination =
-  static_cast(destination);
-
-  if (!max_source.max_.isNull()) {
-compareAndUpdate(max_destination, max_source.max_);
-  }
-}
-
-void AggregationHandleMax::mergeStatesFast(const std::uint8_t *source,
-   std::uint8_t *destination) const {
-  const TypedValue *src_max_ptr = reinterpret_cast(source);
-  TypedValue *dst_max_ptr = reinterpret_cast(destination);
-  if (!(src_max_ptr->isNull())) {
-compareAndUpdateFast(dst_max_ptr, *src_max_ptr);
-  }
-}
-
-ColumnVector* AggregationHandleMax::finalizeHashTable(
-const AggregationStateHashTableBase &hash_table,
-std::vector> *group_by_keys,
-int index) const {
-  return finalizeHashTableHelperFast(
-  type_.getNullableVersion(), hash_table, group_by_keys, index);
-}
-
-AggregationState*
-AggregationHandleMax::aggregateOnDistinctifyHashTableForSingle(
-const AggregationStateHashTableBase &distinctify_hash_table) const {
-  return aggregateOnDistinctifyHashTableForSingleUnaryHelperFast<
-  AggregationHandleMax,
-  AggregationStateMax>(distinctify_hash_table);
-}
-
-void AggregationHandleMax::aggregateOnDistinctifyHashTableForGroupBy(
-const AggregationStateHashTableBase &distinctify_hash_table,
-AggregationStateHashTableBase *aggregation_hash_table,
-std::size_t index) const {
-  aggregateOnDistinctifyHashTableForGroupByUnaryHelperFast<
-  AggregationHandleMax,
-  AggregationStateFastHashTable>(
-  distinctify_hash_table, aggregation_hash_table, index);
-}
+AggregationHandleMax::AggregationHandleMax(const Type &type) {}
+//: type_(type), block_update_(false) {
+//  fast_comparator_.reset(
+//  ComparisonFactory::GetComparison(ComparisonID::kGreater)
+//  .makeUncheckedComparatorForTypes(type, 
type.getNonNullableVersion()));
+//}
+//
+//AggregationStateHashTableBase* AggregationHandleMax::createGroupByHashTable(
+//const HashTableImplType hash_table_impl,
+//const std::vector &group_by_types,
+//const std::size_t estimated_num_groups,
+//StorageManager *storage_manager) const {
+//  return 
AggregationStateHashTableFactory::CreateResizable(
+//  hash_table_impl, group_by_types, estimated_num_groups, 
storage_