You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@quickstep.apache.org by sp...@apache.org on 2016/12/11 17:46:02 UTC

[39/51] [abbrv] [partial] incubator-quickstep git commit: remove c++ files

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/expressions/aggregation/AggregationHandleMax.hpp
----------------------------------------------------------------------
diff --git a/expressions/aggregation/AggregationHandleMax.hpp b/expressions/aggregation/AggregationHandleMax.hpp
deleted file mode 100644
index d851a0c..0000000
--- a/expressions/aggregation/AggregationHandleMax.hpp
+++ /dev/null
@@ -1,251 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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_EXPRESSIONS_AGGREGATION_AGGREGATION_HANDLE_MAX_HPP_
-#define QUICKSTEP_EXPRESSIONS_AGGREGATION_AGGREGATION_HANDLE_MAX_HPP_
-
-#include <cstddef>
-#include <memory>
-#include <utility>
-#include <vector>
-
-#include "catalog/CatalogTypedefs.hpp"
-#include "expressions/aggregation/AggregationConcreteHandle.hpp"
-#include "expressions/aggregation/AggregationHandle.hpp"
-#include "storage/FastHashTable.hpp"
-#include "storage/HashTableBase.hpp"
-#include "threading/SpinMutex.hpp"
-#include "types/Type.hpp"
-#include "types/TypedValue.hpp"
-#include "types/operations/comparisons/Comparison.hpp"
-#include "utility/Macros.hpp"
-
-#include "glog/logging.h"
-
-namespace quickstep {
-
-class ColumnVector;
-class StorageManager;
-class ValueAccessor;
-
-/** \addtogroup Expressions
- *  @{
- */
-
-/**
- * @brief Aggregation state for max.
- */
-class AggregationStateMax : public AggregationState {
- public:
-  /**
-   * @brief Copy constructor (ignores mutex).
-   */
-  AggregationStateMax(const AggregationStateMax &orig) : max_(orig.max_) {}
-
-  /**
-   * @brief Destructor.
-   */
-  ~AggregationStateMax() override{};
-
-  const std::uint8_t* getPayloadAddress() const {
-    return reinterpret_cast<const uint8_t *>(&max_);
-  }
-
- private:
-  friend class AggregationHandleMax;
-
-  explicit AggregationStateMax(const Type &type)
-      : max_(type.getNullableVersion().makeNullValue()) {}
-
-  explicit AggregationStateMax(TypedValue &&value) : max_(std::move(value)) {}
-
-  TypedValue max_;
-  SpinMutex mutex_;
-};
-
-/**
- * @brief An aggregationhandle for max.
- **/
-class AggregationHandleMax : public AggregationConcreteHandle {
- public:
-  ~AggregationHandleMax() override {}
-
-  AggregationState* createInitialState() const override {
-    return new AggregationStateMax(type_);
-  }
-
-  AggregationStateHashTableBase* createGroupByHashTable(
-      const HashTableImplType hash_table_impl,
-      const std::vector<const Type *> &group_by_types,
-      const std::size_t estimated_num_groups,
-      StorageManager *storage_manager) const override;
-
-  /**
-   * @brief Iterate with max aggregation state.
-   */
-  inline void iterateUnaryInl(AggregationStateMax *state,
-                              const TypedValue &value) const {
-    DCHECK(value.isPlausibleInstanceOf(type_.getSignature()));
-    compareAndUpdate(static_cast<AggregationStateMax *>(state), value);
-  }
-
-  inline void iterateUnaryInlFast(const TypedValue &value,
-                                  std::uint8_t *byte_ptr) const {
-    DCHECK(value.isPlausibleInstanceOf(type_.getSignature()));
-    TypedValue *max_ptr = reinterpret_cast<TypedValue *>(byte_ptr);
-    compareAndUpdateFast(max_ptr, value);
-  }
-
-  inline void updateStateUnary(const TypedValue &argument,
-                               std::uint8_t *byte_ptr) const override {
-    if (!block_update_) {
-      iterateUnaryInlFast(argument, byte_ptr);
-    }
-  }
-
-  void blockUpdate() override { block_update_ = true; }
-
-  void allowUpdate() override { block_update_ = false; }
-
-  void initPayload(std::uint8_t *byte_ptr) const override {
-    TypedValue *max_ptr = reinterpret_cast<TypedValue *>(byte_ptr);
-    TypedValue t1 = (type_.getNullableVersion().makeNullValue());
-    *max_ptr = t1;
-  }
-
-  void destroyPayload(std::uint8_t *byte_ptr) const override {
-    TypedValue *max_ptr = reinterpret_cast<TypedValue *>(byte_ptr);
-    if (max_ptr != nullptr) {
-      max_ptr->~TypedValue();
-    }
-  }
-
-  AggregationState* accumulateColumnVectors(
-      const std::vector<std::unique_ptr<ColumnVector>> &column_vectors)
-      const override;
-
-#ifdef QUICKSTEP_ENABLE_VECTOR_COPY_ELISION_SELECTION
-  AggregationState* accumulateValueAccessor(
-      ValueAccessor *accessor,
-      const std::vector<attribute_id> &accessor_ids) const override;
-#endif
-
-  void aggregateValueAccessorIntoHashTable(
-      ValueAccessor *accessor,
-      const std::vector<attribute_id> &argument_ids,
-      const std::vector<attribute_id> &group_by_key_ids,
-      AggregationStateHashTableBase *hash_table) const override;
-
-  void mergeStates(const AggregationState &source,
-                   AggregationState *destination) const override;
-
-  void mergeStatesFast(const std::uint8_t *source,
-                       std::uint8_t *destination) const override;
-
-  TypedValue finalize(const AggregationState &state) const override {
-    return TypedValue(static_cast<const AggregationStateMax &>(state).max_);
-  }
-
-  inline TypedValue finalizeHashTableEntry(
-      const AggregationState &state) const {
-    return TypedValue(static_cast<const AggregationStateMax &>(state).max_);
-  }
-
-  inline TypedValue finalizeHashTableEntryFast(
-      const std::uint8_t *byte_ptr) const {
-    const TypedValue *max_ptr = reinterpret_cast<const TypedValue *>(byte_ptr);
-    return TypedValue(*max_ptr);
-  }
-
-  ColumnVector* finalizeHashTable(
-      const AggregationStateHashTableBase &hash_table,
-      std::vector<std::vector<TypedValue>> *group_by_keys,
-      int index) const override;
-
-  /**
-   * @brief Implementation of
-   *        AggregationHandle::aggregateOnDistinctifyHashTableForSingle()
-   *        for MAX aggregation.
-   */
-  AggregationState* aggregateOnDistinctifyHashTableForSingle(
-      const AggregationStateHashTableBase &distinctify_hash_table)
-      const override;
-
-  /**
-   * @brief Implementation of
-   *        AggregationHandle::aggregateOnDistinctifyHashTableForGroupBy()
-   *        for MAX aggregation.
-   */
-  void aggregateOnDistinctifyHashTableForGroupBy(
-      const AggregationStateHashTableBase &distinctify_hash_table,
-      AggregationStateHashTableBase *aggregation_hash_table,
-      std::size_t index) const override;
-
-  std::size_t getPayloadSize() const override { return sizeof(TypedValue); }
-
- private:
-  friend class AggregateFunctionMax;
-
-  /**
-   * @brief Constructor.
-   *
-   * @param type Type of the data set.
-   **/
-  explicit AggregationHandleMax(const Type &type);
-
-  /**
-   * @brief compare the value with max_ and update it if the value is larger
-   *        than current maximum. NULLs are ignored.
-   *
-   * @param value A TypedValue to compare
-   **/
-  inline void compareAndUpdate(AggregationStateMax *state,
-                               const TypedValue &value) const {
-    // TODO(chasseur): Avoid null-checks when aggregating a non-nullable Type.
-    if (value.isNull()) return;
-
-    SpinMutexLock lock(state->mutex_);
-    if (state->max_.isNull() ||
-        fast_comparator_->compareTypedValues(value, state->max_)) {
-      state->max_ = value;
-    }
-  }
-
-  inline void compareAndUpdateFast(TypedValue *max_ptr,
-                                   const TypedValue &value) const {
-    if (value.isNull()) return;
-    if (max_ptr->isNull() ||
-        fast_comparator_->compareTypedValues(value, *max_ptr)) {
-      *max_ptr = value;
-    }
-  }
-
-  const Type &type_;
-  std::unique_ptr<UncheckedComparator> fast_comparator_;
-
-  bool block_update_;
-
-  DISALLOW_COPY_AND_ASSIGN(AggregationHandleMax);
-};
-
-/** @} */
-
-}  // namespace quickstep
-
-#endif  // QUICKSTEP_EXPRESSIONS_AGGREGATION_AGGREGATION_HANDLE_MAX_HPP_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/expressions/aggregation/AggregationHandleMin.cpp
----------------------------------------------------------------------
diff --git a/expressions/aggregation/AggregationHandleMin.cpp b/expressions/aggregation/AggregationHandleMin.cpp
deleted file mode 100644
index a07f299..0000000
--- a/expressions/aggregation/AggregationHandleMin.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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 "expressions/aggregation/AggregationHandleMin.hpp"
-
-#include <memory>
-#include <vector>
-
-#include "catalog/CatalogTypedefs.hpp"
-#include "storage/HashTable.hpp"
-#include "storage/HashTableFactory.hpp"
-#include "types/Type.hpp"
-#include "types/TypedValue.hpp"
-#include "types/containers/ColumnVector.hpp"
-#include "types/operations/comparisons/Comparison.hpp"
-#include "types/operations/comparisons/ComparisonFactory.hpp"
-#include "types/operations/comparisons/ComparisonID.hpp"
-
-#include "glog/logging.h"
-
-namespace quickstep {
-
-class StorageManager;
-
-AggregationHandleMin::AggregationHandleMin(const Type &type)
-    : type_(type), block_update_(false) {
-  fast_comparator_.reset(
-      ComparisonFactory::GetComparison(ComparisonID::kLess)
-          .makeUncheckedComparatorForTypes(type, type.getNonNullableVersion()));
-}
-
-AggregationStateHashTableBase* AggregationHandleMin::createGroupByHashTable(
-    const HashTableImplType hash_table_impl,
-    const std::vector<const Type *> &group_by_types,
-    const std::size_t estimated_num_groups,
-    StorageManager *storage_manager) const {
-  return AggregationStateHashTableFactory<AggregationStateMin>::CreateResizable(
-      hash_table_impl, group_by_types, estimated_num_groups, storage_manager);
-}
-
-AggregationState* AggregationHandleMin::accumulateColumnVectors(
-    const std::vector<std::unique_ptr<ColumnVector>> &column_vectors) const {
-  DCHECK_EQ(1u, column_vectors.size())
-      << "Got wrong number of ColumnVectors for MIN: " << column_vectors.size();
-
-  return new AggregationStateMin(fast_comparator_->accumulateColumnVector(
-      type_.getNullableVersion().makeNullValue(), *column_vectors.front()));
-}
-
-#ifdef QUICKSTEP_ENABLE_VECTOR_COPY_ELISION_SELECTION
-AggregationState* AggregationHandleMin::accumulateValueAccessor(
-    ValueAccessor *accessor,
-    const std::vector<attribute_id> &accessor_ids) const {
-  DCHECK_EQ(1u, accessor_ids.size())
-      << "Got wrong number of attributes for MIN: " << accessor_ids.size();
-
-  return new AggregationStateMin(fast_comparator_->accumulateValueAccessor(
-      type_.getNullableVersion().makeNullValue(),
-      accessor,
-      accessor_ids.front()));
-}
-#endif  // QUICKSTEP_ENABLE_VECTOR_COPY_ELISION_SELECTION
-
-void AggregationHandleMin::aggregateValueAccessorIntoHashTable(
-    ValueAccessor *accessor,
-    const std::vector<attribute_id> &argument_ids,
-    const std::vector<attribute_id> &group_by_key_ids,
-    AggregationStateHashTableBase *hash_table) const {
-  DCHECK_EQ(1u, argument_ids.size())
-      << "Got wrong number of arguments for MIN: " << argument_ids.size();
-}
-
-void AggregationHandleMin::mergeStates(const AggregationState &source,
-                                       AggregationState *destination) const {
-  const AggregationStateMin &min_source =
-      static_cast<const AggregationStateMin &>(source);
-  AggregationStateMin *min_destination =
-      static_cast<AggregationStateMin *>(destination);
-
-  if (!min_source.min_.isNull()) {
-    compareAndUpdate(min_destination, min_source.min_);
-  }
-}
-
-void AggregationHandleMin::mergeStatesFast(const std::uint8_t *source,
-                                           std::uint8_t *destination) const {
-  const TypedValue *src_min_ptr = reinterpret_cast<const TypedValue *>(source);
-  TypedValue *dst_min_ptr = reinterpret_cast<TypedValue *>(destination);
-
-  if (!(src_min_ptr->isNull())) {
-    compareAndUpdateFast(dst_min_ptr, *src_min_ptr);
-  }
-}
-
-ColumnVector* AggregationHandleMin::finalizeHashTable(
-    const AggregationStateHashTableBase &hash_table,
-    std::vector<std::vector<TypedValue>> *group_by_keys,
-    int index) const {
-  return finalizeHashTableHelperFast<AggregationHandleMin,
-                                     AggregationStateFastHashTable>(
-      type_.getNonNullableVersion(), hash_table, group_by_keys, index);
-}
-
-AggregationState*
-AggregationHandleMin::aggregateOnDistinctifyHashTableForSingle(
-    const AggregationStateHashTableBase &distinctify_hash_table) const {
-  return aggregateOnDistinctifyHashTableForSingleUnaryHelperFast<
-      AggregationHandleMin,
-      AggregationStateMin>(distinctify_hash_table);
-}
-
-void AggregationHandleMin::aggregateOnDistinctifyHashTableForGroupBy(
-    const AggregationStateHashTableBase &distinctify_hash_table,
-    AggregationStateHashTableBase *aggregation_hash_table,
-    std::size_t index) const {
-  aggregateOnDistinctifyHashTableForGroupByUnaryHelperFast<
-      AggregationHandleMin,
-      AggregationStateFastHashTable>(
-      distinctify_hash_table, aggregation_hash_table, index);
-}
-
-}  // namespace quickstep

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/expressions/aggregation/AggregationHandleMin.hpp
----------------------------------------------------------------------
diff --git a/expressions/aggregation/AggregationHandleMin.hpp b/expressions/aggregation/AggregationHandleMin.hpp
deleted file mode 100644
index e3472ec..0000000
--- a/expressions/aggregation/AggregationHandleMin.hpp
+++ /dev/null
@@ -1,252 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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_EXPRESSIONS_AGGREGATION_AGGREGATION_HANDLE_MIN_HPP_
-#define QUICKSTEP_EXPRESSIONS_AGGREGATION_AGGREGATION_HANDLE_MIN_HPP_
-
-#include <cstddef>
-#include <memory>
-#include <utility>
-#include <vector>
-
-#include "catalog/CatalogTypedefs.hpp"
-#include "expressions/aggregation/AggregationConcreteHandle.hpp"
-#include "expressions/aggregation/AggregationHandle.hpp"
-#include "storage/FastHashTable.hpp"
-#include "storage/HashTableBase.hpp"
-#include "threading/SpinMutex.hpp"
-#include "types/Type.hpp"
-#include "types/TypedValue.hpp"
-#include "types/operations/comparisons/Comparison.hpp"
-#include "utility/Macros.hpp"
-
-#include "glog/logging.h"
-
-namespace quickstep {
-
-class ColumnVector;
-class StorageManager;
-class ValueAccessor;
-
-/** \addtogroup Expressions
- *  @{
- */
-
-/**
- * @brief Aggregation state for min.
- */
-class AggregationStateMin : public AggregationState {
- public:
-  /**
-   * @brief Copy constructor (ignores mutex).
-   */
-  AggregationStateMin(const AggregationStateMin &orig) : min_(orig.min_) {}
-
-  /**
-   * @brief Destructor.
-   */
-  ~AggregationStateMin() override {}
-
-  std::size_t getPayloadSize() const { return sizeof(TypedValue); }
-
-  const std::uint8_t *getPayloadAddress() const {
-    return reinterpret_cast<const uint8_t *>(&min_);
-  }
-
- private:
-  friend class AggregationHandleMin;
-
-  explicit AggregationStateMin(const Type &type)
-      : min_(type.getNullableVersion().makeNullValue()) {}
-
-  explicit AggregationStateMin(TypedValue &&value) : min_(std::move(value)) {}
-
-  TypedValue min_;
-  SpinMutex mutex_;
-};
-
-/**
- * @brief An aggregationhandle for min.
- **/
-class AggregationHandleMin : public AggregationConcreteHandle {
- public:
-  ~AggregationHandleMin() override {}
-
-  AggregationState* createInitialState() const override {
-    return new AggregationStateMin(type_);
-  }
-
-  AggregationStateHashTableBase* createGroupByHashTable(
-      const HashTableImplType hash_table_impl,
-      const std::vector<const Type *> &group_by_types,
-      const std::size_t estimated_num_groups,
-      StorageManager *storage_manager) const override;
-
-  /**
-   * @brief Iterate with min aggregation state.
-   */
-  inline void iterateUnaryInl(AggregationStateMin *state,
-                              const TypedValue &value) const {
-    DCHECK(value.isPlausibleInstanceOf(type_.getSignature()));
-    compareAndUpdate(state, value);
-  }
-
-  inline void iterateUnaryInlFast(const TypedValue &value,
-                                  std::uint8_t *byte_ptr) const {
-    DCHECK(value.isPlausibleInstanceOf(type_.getSignature()));
-    TypedValue *min_ptr = reinterpret_cast<TypedValue *>(byte_ptr);
-    compareAndUpdateFast(min_ptr, value);
-  }
-
-  inline void updateStateUnary(const TypedValue &argument,
-                               std::uint8_t *byte_ptr) const override {
-    if (!block_update_) {
-      iterateUnaryInlFast(argument, byte_ptr);
-    }
-  }
-
-  void blockUpdate() override { block_update_ = true; }
-
-  void allowUpdate() override { block_update_ = false; }
-
-  void initPayload(std::uint8_t *byte_ptr) const override {
-    TypedValue *min_ptr = reinterpret_cast<TypedValue *>(byte_ptr);
-    TypedValue t1 = (type_.getNullableVersion().makeNullValue());
-    *min_ptr = t1;
-  }
-
-  void destroyPayload(std::uint8_t *byte_ptr) const override {
-    TypedValue *min_ptr = reinterpret_cast<TypedValue *>(byte_ptr);
-    if (min_ptr != nullptr) {
-      min_ptr->~TypedValue();
-    }
-  }
-
-  AggregationState* accumulateColumnVectors(
-      const std::vector<std::unique_ptr<ColumnVector>> &column_vectors)
-      const override;
-
-#ifdef QUICKSTEP_ENABLE_VECTOR_COPY_ELISION_SELECTION
-  AggregationState* accumulateValueAccessor(
-      ValueAccessor *accessor,
-      const std::vector<attribute_id> &accessor_ids) const override;
-#endif
-
-  void aggregateValueAccessorIntoHashTable(
-      ValueAccessor *accessor,
-      const std::vector<attribute_id> &argument_ids,
-      const std::vector<attribute_id> &group_by_key_ids,
-      AggregationStateHashTableBase *hash_table) const override;
-
-  void mergeStates(const AggregationState &source,
-                   AggregationState *destination) const override;
-
-  void mergeStatesFast(const std::uint8_t *source,
-                       std::uint8_t *destination) const override;
-
-  TypedValue finalize(const AggregationState &state) const override {
-    return static_cast<const AggregationStateMin &>(state).min_;
-  }
-
-  inline TypedValue finalizeHashTableEntry(
-      const AggregationState &state) const {
-    return static_cast<const AggregationStateMin &>(state).min_;
-  }
-
-  inline TypedValue finalizeHashTableEntryFast(
-      const std::uint8_t *byte_ptr) const {
-    const TypedValue *min_ptr = reinterpret_cast<const TypedValue *>(byte_ptr);
-    return TypedValue(*min_ptr);
-  }
-
-  ColumnVector* finalizeHashTable(
-      const AggregationStateHashTableBase &hash_table,
-      std::vector<std::vector<TypedValue>> *group_by_keys,
-      int index) const override;
-
-  /**
-   * @brief Implementation of
-   * AggregationHandle::aggregateOnDistinctifyHashTableForSingle()
-   *        for MIN aggregation.
-   */
-  AggregationState* aggregateOnDistinctifyHashTableForSingle(
-      const AggregationStateHashTableBase &distinctify_hash_table)
-      const override;
-
-  /**
-   * @brief Implementation of
-   *        AggregationHandle::aggregateOnDistinctifyHashTableForGroupBy()
-   *        for MIN aggregation.
-   */
-  void aggregateOnDistinctifyHashTableForGroupBy(
-      const AggregationStateHashTableBase &distinctify_hash_table,
-      AggregationStateHashTableBase *aggregation_hash_table,
-      std::size_t index) const override;
-
-  std::size_t getPayloadSize() const override { return sizeof(TypedValue); }
-
- private:
-  friend class AggregateFunctionMin;
-
-  /**
-   * @brief Constructor.
-   *
-   * @param type Type of the data set.
-   **/
-  explicit AggregationHandleMin(const Type &type);
-
-  /**
-   * @brief compare the value with min_ and update it if the value is smaller
-   *        than current minimum. NULLs are ignored.
-   *
-   * @param value A TypedValue to compare.
-   **/
-  inline void compareAndUpdate(AggregationStateMin *state,
-                               const TypedValue &value) const {
-    if (value.isNull()) return;
-
-    SpinMutexLock lock(state->mutex_);
-    if (state->min_.isNull() ||
-        fast_comparator_->compareTypedValues(value, state->min_)) {
-      state->min_ = value;
-    }
-  }
-
-  inline void compareAndUpdateFast(TypedValue *min_ptr,
-                                   const TypedValue &value) const {
-    if (value.isNull()) return;
-    if (min_ptr->isNull() ||
-        fast_comparator_->compareTypedValues(value, *min_ptr)) {
-      *min_ptr = value;
-    }
-  }
-
-  const Type &type_;
-  std::unique_ptr<UncheckedComparator> fast_comparator_;
-
-  bool block_update_;
-
-  DISALLOW_COPY_AND_ASSIGN(AggregationHandleMin);
-};
-
-/** @} */
-
-}  // namespace quickstep
-
-#endif  // QUICKSTEP_EXPRESSIONS_AGGREGATION_AGGREGATION_HANDLE_MIN_HPP_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/expressions/aggregation/AggregationHandleSum.cpp
----------------------------------------------------------------------
diff --git a/expressions/aggregation/AggregationHandleSum.cpp b/expressions/aggregation/AggregationHandleSum.cpp
deleted file mode 100644
index 642d88d..0000000
--- a/expressions/aggregation/AggregationHandleSum.cpp
+++ /dev/null
@@ -1,190 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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 "expressions/aggregation/AggregationHandleSum.hpp"
-
-#include <cstddef>
-#include <memory>
-#include <utility>
-#include <vector>
-
-#include "catalog/CatalogTypedefs.hpp"
-#include "storage/HashTable.hpp"
-#include "storage/HashTableFactory.hpp"
-#include "threading/SpinMutex.hpp"
-#include "types/Type.hpp"
-#include "types/TypeFactory.hpp"
-#include "types/TypeID.hpp"
-#include "types/TypedValue.hpp"
-#include "types/operations/binary_operations/BinaryOperation.hpp"
-#include "types/operations/binary_operations/BinaryOperationFactory.hpp"
-#include "types/operations/binary_operations/BinaryOperationID.hpp"
-
-#include "glog/logging.h"
-
-namespace quickstep {
-
-class StorageManager;
-
-AggregationHandleSum::AggregationHandleSum(const Type &type)
-    : argument_type_(type), block_update_(false) {
-  // We sum Int as Long and Float as Double so that we have more headroom when
-  // adding many values.
-  TypeID type_precision_id;
-  switch (argument_type_.getTypeID()) {
-    case kInt:
-    case kLong:
-      type_precision_id = kLong;
-      break;
-    case kFloat:
-    case kDouble:
-      type_precision_id = kDouble;
-      break;
-    default:
-      type_precision_id = type.getTypeID();
-      break;
-  }
-
-  const Type &sum_type = TypeFactory::GetType(type_precision_id);
-  blank_state_.sum_ = sum_type.makeZeroValue();
-
-  // Make operators to do arithmetic:
-  // Add operator for summing argument values.
-  fast_operator_.reset(
-      BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kAdd)
-          .makeUncheckedBinaryOperatorForTypes(sum_type, argument_type_));
-  // Add operator for merging states.
-  merge_operator_.reset(
-      BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kAdd)
-          .makeUncheckedBinaryOperatorForTypes(sum_type, sum_type));
-
-  // Result is nullable, because SUM() over 0 values (or all NULL values) is
-  // NULL.
-  result_type_ = &sum_type.getNullableVersion();
-}
-
-AggregationStateHashTableBase* AggregationHandleSum::createGroupByHashTable(
-    const HashTableImplType hash_table_impl,
-    const std::vector<const Type *> &group_by_types,
-    const std::size_t estimated_num_groups,
-    StorageManager *storage_manager) const {
-  return AggregationStateHashTableFactory<AggregationStateSum>::CreateResizable(
-      hash_table_impl, group_by_types, estimated_num_groups, storage_manager);
-}
-
-AggregationState* AggregationHandleSum::accumulateColumnVectors(
-    const std::vector<std::unique_ptr<ColumnVector>> &column_vectors) const {
-  DCHECK_EQ(1u, column_vectors.size())
-      << "Got wrong number of ColumnVectors for SUM: " << column_vectors.size();
-  std::size_t num_tuples = 0;
-  TypedValue cv_sum = fast_operator_->accumulateColumnVector(
-      blank_state_.sum_, *column_vectors.front(), &num_tuples);
-  return new AggregationStateSum(std::move(cv_sum), num_tuples == 0);
-}
-
-#ifdef QUICKSTEP_ENABLE_VECTOR_COPY_ELISION_SELECTION
-AggregationState* AggregationHandleSum::accumulateValueAccessor(
-    ValueAccessor *accessor,
-    const std::vector<attribute_id> &accessor_ids) const {
-  DCHECK_EQ(1u, accessor_ids.size())
-      << "Got wrong number of attributes for SUM: " << accessor_ids.size();
-
-  std::size_t num_tuples = 0;
-  TypedValue va_sum = fast_operator_->accumulateValueAccessor(
-      blank_state_.sum_, accessor, accessor_ids.front(), &num_tuples);
-  return new AggregationStateSum(std::move(va_sum), num_tuples == 0);
-}
-#endif
-
-void AggregationHandleSum::aggregateValueAccessorIntoHashTable(
-    ValueAccessor *accessor,
-    const std::vector<attribute_id> &argument_ids,
-    const std::vector<attribute_id> &group_by_key_ids,
-    AggregationStateHashTableBase *hash_table) const {
-  DCHECK_EQ(1u, argument_ids.size())
-      << "Got wrong number of arguments for SUM: " << argument_ids.size();
-}
-
-void AggregationHandleSum::mergeStates(const AggregationState &source,
-                                       AggregationState *destination) const {
-  const AggregationStateSum &sum_source =
-      static_cast<const AggregationStateSum &>(source);
-  AggregationStateSum *sum_destination =
-      static_cast<AggregationStateSum *>(destination);
-
-  SpinMutexLock lock(sum_destination->mutex_);
-  sum_destination->sum_ = merge_operator_->applyToTypedValues(
-      sum_destination->sum_, sum_source.sum_);
-  sum_destination->null_ = sum_destination->null_ && sum_source.null_;
-}
-
-void AggregationHandleSum::mergeStatesFast(const std::uint8_t *source,
-                                           std::uint8_t *destination) const {
-  const TypedValue *src_sum_ptr =
-      reinterpret_cast<const TypedValue *>(source + blank_state_.sum_offset_);
-  const bool *src_null_ptr =
-      reinterpret_cast<const bool *>(source + blank_state_.null_offset_);
-  TypedValue *dst_sum_ptr =
-      reinterpret_cast<TypedValue *>(destination + blank_state_.sum_offset_);
-  bool *dst_null_ptr =
-      reinterpret_cast<bool *>(destination + blank_state_.null_offset_);
-  *dst_sum_ptr =
-      merge_operator_->applyToTypedValues(*dst_sum_ptr, *src_sum_ptr);
-  *dst_null_ptr = (*dst_null_ptr) && (*src_null_ptr);
-}
-
-TypedValue AggregationHandleSum::finalize(const AggregationState &state) const {
-  const AggregationStateSum &agg_state =
-      static_cast<const AggregationStateSum &>(state);
-  if (agg_state.null_) {
-    // SUM() over no values is NULL.
-    return result_type_->makeNullValue();
-  } else {
-    return agg_state.sum_;
-  }
-}
-
-ColumnVector* AggregationHandleSum::finalizeHashTable(
-    const AggregationStateHashTableBase &hash_table,
-    std::vector<std::vector<TypedValue>> *group_by_keys,
-    int index) const {
-  return finalizeHashTableHelperFast<AggregationHandleSum,
-                                     AggregationStateFastHashTable>(
-      *result_type_, hash_table, group_by_keys, index);
-}
-
-AggregationState*
-AggregationHandleSum::aggregateOnDistinctifyHashTableForSingle(
-    const AggregationStateHashTableBase &distinctify_hash_table) const {
-  return aggregateOnDistinctifyHashTableForSingleUnaryHelperFast<
-      AggregationHandleSum,
-      AggregationStateSum>(distinctify_hash_table);
-}
-
-void AggregationHandleSum::aggregateOnDistinctifyHashTableForGroupBy(
-    const AggregationStateHashTableBase &distinctify_hash_table,
-    AggregationStateHashTableBase *aggregation_hash_table,
-    std::size_t index) const {
-  aggregateOnDistinctifyHashTableForGroupByUnaryHelperFast<
-      AggregationHandleSum,
-      AggregationStateFastHashTable>(
-      distinctify_hash_table, aggregation_hash_table, index);
-}
-
-}  // namespace quickstep

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/expressions/aggregation/AggregationHandleSum.hpp
----------------------------------------------------------------------
diff --git a/expressions/aggregation/AggregationHandleSum.hpp b/expressions/aggregation/AggregationHandleSum.hpp
deleted file mode 100644
index f0d23e1..0000000
--- a/expressions/aggregation/AggregationHandleSum.hpp
+++ /dev/null
@@ -1,254 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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_EXPRESSIONS_AGGREGATION_AGGREGATION_HANDLE_SUM_HPP_
-#define QUICKSTEP_EXPRESSIONS_AGGREGATION_AGGREGATION_HANDLE_SUM_HPP_
-
-#include <cstddef>
-#include <memory>
-#include <utility>
-#include <vector>
-
-#include "catalog/CatalogTypedefs.hpp"
-#include "expressions/aggregation/AggregationConcreteHandle.hpp"
-#include "expressions/aggregation/AggregationHandle.hpp"
-#include "storage/FastHashTable.hpp"
-#include "storage/HashTableBase.hpp"
-#include "threading/SpinMutex.hpp"
-#include "types/Type.hpp"
-#include "types/TypedValue.hpp"
-#include "types/operations/binary_operations/BinaryOperation.hpp"
-#include "utility/Macros.hpp"
-
-#include "glog/logging.h"
-
-namespace quickstep {
-
-class ColumnVector;
-class StorageManager;
-class ValueAccessor;
-
-/** \addtogroup Expressions
- *  @{
- */
-
-/**
- * @brief Aggregation state for sum.
- */
-class AggregationStateSum : public AggregationState {
- public:
-  /**
-   * @brief Copy constructor (ignores mutex).
-   */
-  AggregationStateSum(const AggregationStateSum &orig)
-      : sum_(orig.sum_),
-        null_(orig.null_),
-        sum_offset_(orig.sum_offset_),
-        null_offset_(orig.null_offset_) {}
-
-  std::size_t getPayloadSize() const {
-    std::size_t p1 = reinterpret_cast<std::size_t>(&sum_);
-    std::size_t p2 = reinterpret_cast<std::size_t>(&mutex_);
-    return (p2 - p1);
-  }
-
-  const std::uint8_t* getPayloadAddress() const {
-    return reinterpret_cast<const uint8_t *>(&sum_);
-  }
-
- private:
-  friend class AggregationHandleSum;
-
-  AggregationStateSum()
-      : sum_(0),
-        null_(true),
-        sum_offset_(0),
-        null_offset_(reinterpret_cast<std::uint8_t *>(&null_) -
-                     reinterpret_cast<std::uint8_t *>(&sum_)) {}
-
-  AggregationStateSum(TypedValue &&sum, const bool is_null)
-      : sum_(std::move(sum)), null_(is_null) {}
-
-  // TODO(shoban): We might want to specialize sum_ to use atomics for int types
-  // similar to in AggregationStateCount.
-  TypedValue sum_;
-  bool null_;
-  SpinMutex mutex_;
-
-  int sum_offset_, null_offset_;
-};
-
-/**
- * @brief An aggregationhandle for sum.
- **/
-class AggregationHandleSum : public AggregationConcreteHandle {
- public:
-  ~AggregationHandleSum() override {}
-
-  AggregationState* createInitialState() const override {
-    return new AggregationStateSum(blank_state_);
-  }
-
-  AggregationStateHashTableBase* createGroupByHashTable(
-      const HashTableImplType hash_table_impl,
-      const std::vector<const Type *> &group_by_types,
-      const std::size_t estimated_num_groups,
-      StorageManager *storage_manager) const override;
-
-  inline void iterateUnaryInl(AggregationStateSum *state,
-                              const TypedValue &value) const {
-    DCHECK(value.isPlausibleInstanceOf(argument_type_.getSignature()));
-    if (value.isNull()) return;
-
-    SpinMutexLock lock(state->mutex_);
-    state->sum_ = fast_operator_->applyToTypedValues(state->sum_, value);
-    state->null_ = false;
-  }
-
-  inline void iterateUnaryInlFast(const TypedValue &value,
-                                  std::uint8_t *byte_ptr) const {
-    DCHECK(value.isPlausibleInstanceOf(argument_type_.getSignature()));
-    if (value.isNull()) return;
-    TypedValue *sum_ptr =
-        reinterpret_cast<TypedValue *>(byte_ptr + blank_state_.sum_offset_);
-    bool *null_ptr =
-        reinterpret_cast<bool *>(byte_ptr + blank_state_.null_offset_);
-    *sum_ptr = fast_operator_->applyToTypedValues(*sum_ptr, value);
-    *null_ptr = false;
-  }
-
-  inline void updateStateUnary(const TypedValue &argument,
-                               std::uint8_t *byte_ptr) const override {
-    if (!block_update_) {
-      iterateUnaryInlFast(argument, byte_ptr);
-    }
-  }
-
-  void blockUpdate() override { block_update_ = true; }
-
-  void allowUpdate() override { block_update_ = false; }
-
-  void initPayload(std::uint8_t *byte_ptr) const override {
-    TypedValue *sum_ptr =
-        reinterpret_cast<TypedValue *>(byte_ptr + blank_state_.sum_offset_);
-    bool *null_ptr =
-        reinterpret_cast<bool *>(byte_ptr + blank_state_.null_offset_);
-    *sum_ptr = blank_state_.sum_;
-    *null_ptr = true;
-  }
-
-  void destroyPayload(std::uint8_t *byte_ptr) const override {
-    TypedValue *sum_ptr =
-        reinterpret_cast<TypedValue *>(byte_ptr + blank_state_.sum_offset_);
-    if (sum_ptr != nullptr) {
-      sum_ptr->~TypedValue();
-    }
-  }
-
-  AggregationState* accumulateColumnVectors(
-      const std::vector<std::unique_ptr<ColumnVector>> &column_vectors)
-      const override;
-
-#ifdef QUICKSTEP_ENABLE_VECTOR_COPY_ELISION_SELECTION
-  AggregationState* accumulateValueAccessor(
-      ValueAccessor *accessor,
-      const std::vector<attribute_id> &accessor_id) const override;
-#endif
-
-  void aggregateValueAccessorIntoHashTable(
-      ValueAccessor *accessor,
-      const std::vector<attribute_id> &argument_ids,
-      const std::vector<attribute_id> &group_by_key_ids,
-      AggregationStateHashTableBase *hash_table) const override;
-
-  void mergeStates(const AggregationState &source,
-                   AggregationState *destination) const override;
-
-  void mergeStatesFast(const std::uint8_t *source,
-                       std::uint8_t *destination) const override;
-
-  TypedValue finalize(const AggregationState &state) const override;
-
-  inline TypedValue finalizeHashTableEntry(
-      const AggregationState &state) const {
-    return static_cast<const AggregationStateSum &>(state).sum_;
-  }
-
-  inline TypedValue finalizeHashTableEntryFast(
-      const std::uint8_t *byte_ptr) const {
-    std::uint8_t *value_ptr = const_cast<std::uint8_t *>(byte_ptr);
-    TypedValue *sum_ptr =
-        reinterpret_cast<TypedValue *>(value_ptr + blank_state_.sum_offset_);
-    return *sum_ptr;
-  }
-
-  ColumnVector* finalizeHashTable(
-      const AggregationStateHashTableBase &hash_table,
-      std::vector<std::vector<TypedValue>> *group_by_keys,
-      int index) const override;
-
-  /**
-   * @brief Implementation of
-   *        AggregationHandle::aggregateOnDistinctifyHashTableForSingle()
-   *        for SUM aggregation.
-   */
-  AggregationState* aggregateOnDistinctifyHashTableForSingle(
-      const AggregationStateHashTableBase &distinctify_hash_table)
-      const override;
-
-  /**
-   * @brief Implementation of
-   *        AggregationHandle::aggregateOnDistinctifyHashTableForGroupBy()
-   *        for SUM aggregation.
-   */
-  void aggregateOnDistinctifyHashTableForGroupBy(
-      const AggregationStateHashTableBase &distinctify_hash_table,
-      AggregationStateHashTableBase *aggregation_hash_table,
-      std::size_t index) const override;
-
-  std::size_t getPayloadSize() const override {
-    return blank_state_.getPayloadSize();
-  }
-
- private:
-  friend class AggregateFunctionSum;
-
-  /**
-   * @brief Initialize handle for type.
-   *
-   * @param type Type of the sum value.
-   **/
-  explicit AggregationHandleSum(const Type &type);
-
-  const Type &argument_type_;
-  const Type *result_type_;
-  AggregationStateSum blank_state_;
-  std::unique_ptr<UncheckedBinaryOperator> fast_operator_;
-  std::unique_ptr<UncheckedBinaryOperator> merge_operator_;
-
-  bool block_update_;
-
-  DISALLOW_COPY_AND_ASSIGN(AggregationHandleSum);
-};
-
-/** @} */
-
-}  // namespace quickstep
-
-#endif  // QUICKSTEP_EXPRESSIONS_AGGREGATION_AGGREGATION_HANDLE_SUM_HPP_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/expressions/aggregation/AggregationID.hpp
----------------------------------------------------------------------
diff --git a/expressions/aggregation/AggregationID.hpp b/expressions/aggregation/AggregationID.hpp
deleted file mode 100644
index 1efb35c..0000000
--- a/expressions/aggregation/AggregationID.hpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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_EXPRESSIONS_AGGREGATION_AGGREGATION_ID_HPP_
-#define QUICKSTEP_EXPRESSIONS_AGGREGATION_AGGREGATION_ID_HPP_
-
-namespace quickstep {
-
-/** \addtogroup Expressions
- *  @{
- */
-
-/**
- * @brief The possible types of aggregations.
- **/
-enum class AggregationID {
-  kAvg = 0,
-  kCount,
-  kMax,
-  kMin,
-  kSum
-};
-
-/** @} */
-
-}  // namespace quickstep
-
-#endif  // QUICKSTEP_EXPRESSIONS_AGGREGATION_AGGREGATION_ID_HPP_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/expressions/aggregation/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/expressions/aggregation/CMakeLists.txt b/expressions/aggregation/CMakeLists.txt
deleted file mode 100644
index e9503f7..0000000
--- a/expressions/aggregation/CMakeLists.txt
+++ /dev/null
@@ -1,325 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you 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.
-
-QS_PROTOBUF_GENERATE_CPP(expressions_aggregation_AggregateFunction_proto_srcs
-                         expressions_aggregation_AggregateFunction_proto_hdrs
-                         AggregateFunction.proto)
-
-# Declare micro-libs:
-add_library(quickstep_expressions_aggregation_AggregateFunction
-            AggregateFunction.cpp
-            AggregateFunction.hpp)
-add_library(quickstep_expressions_aggregation_AggregateFunction_proto
-            ${expressions_aggregation_AggregateFunction_proto_srcs})
-add_library(quickstep_expressions_aggregation_AggregateFunctionAvg
-            AggregateFunctionAvg.cpp
-            AggregateFunctionAvg.hpp)
-add_library(quickstep_expressions_aggregation_AggregateFunctionCount
-            AggregateFunctionCount.cpp
-            AggregateFunctionCount.hpp)
-add_library(quickstep_expressions_aggregation_AggregateFunctionFactory
-            AggregateFunctionFactory.cpp
-            AggregateFunctionFactory.hpp)
-add_library(quickstep_expressions_aggregation_AggregateFunctionMax
-            AggregateFunctionMax.cpp
-            AggregateFunctionMax.hpp)
-add_library(quickstep_expressions_aggregation_AggregateFunctionMin
-            AggregateFunctionMin.cpp
-            AggregateFunctionMin.hpp)
-add_library(quickstep_expressions_aggregation_AggregateFunctionSum
-            AggregateFunctionSum.cpp
-            AggregateFunctionSum.hpp)
-add_library(quickstep_expressions_aggregation_AggregationConcreteHandle
-            AggregationConcreteHandle.cpp
-            AggregationConcreteHandle.hpp)
-add_library(quickstep_expressions_aggregation_AggregationHandle
-            ../../empty_src.cpp
-            AggregationHandle.hpp)
-add_library(quickstep_expressions_aggregation_AggregationHandleAvg
-            AggregationHandleAvg.cpp
-            AggregationHandleAvg.hpp)
-add_library(quickstep_expressions_aggregation_AggregationHandleCount
-            AggregationHandleCount.cpp
-            AggregationHandleCount.hpp)
-add_library(quickstep_expressions_aggregation_AggregationHandleDistinct
-            AggregationHandleDistinct.cpp
-            AggregationHandleDistinct.hpp)
-add_library(quickstep_expressions_aggregation_AggregationHandleMax
-            AggregationHandleMax.cpp
-            AggregationHandleMax.hpp)
-add_library(quickstep_expressions_aggregation_AggregationHandleMin
-            AggregationHandleMin.cpp
-            AggregationHandleMin.hpp)
-add_library(quickstep_expressions_aggregation_AggregationHandleSum
-            AggregationHandleSum.cpp
-            AggregationHandleSum.hpp)
-add_library(quickstep_expressions_aggregation_AggregationID
-            ../../empty_src.cpp
-            AggregationID.hpp)
-
-# Link dependencies:
-target_link_libraries(quickstep_expressions_aggregation_AggregateFunction
-                      glog
-                      quickstep_expressions_aggregation_AggregateFunction_proto
-                      quickstep_expressions_aggregation_AggregationID
-                      quickstep_utility_Macros)
-target_link_libraries(quickstep_expressions_aggregation_AggregateFunction_proto
-                      ${PROTOBUF_LIBRARY})
-target_link_libraries(quickstep_expressions_aggregation_AggregateFunctionAvg
-                      glog
-                      quickstep_expressions_aggregation_AggregateFunction
-                      quickstep_expressions_aggregation_AggregationHandleAvg
-                      quickstep_expressions_aggregation_AggregationID
-                      quickstep_types_Type
-                      quickstep_types_TypeFactory
-                      quickstep_types_TypeID
-                      quickstep_types_operations_binaryoperations_BinaryOperation
-                      quickstep_types_operations_binaryoperations_BinaryOperationFactory
-                      quickstep_types_operations_binaryoperations_BinaryOperationID
-                      quickstep_utility_Macros)
-target_link_libraries(quickstep_expressions_aggregation_AggregateFunctionCount
-                      glog
-                      quickstep_expressions_aggregation_AggregateFunction
-                      quickstep_expressions_aggregation_AggregationHandleCount
-                      quickstep_expressions_aggregation_AggregationID
-                      quickstep_types_Type
-                      quickstep_types_TypeFactory
-                      quickstep_types_TypeID
-                      quickstep_utility_Macros)
-target_link_libraries(quickstep_expressions_aggregation_AggregateFunctionFactory
-                      glog
-                      quickstep_expressions_aggregation_AggregateFunction_proto
-                      quickstep_expressions_aggregation_AggregateFunctionAvg
-                      quickstep_expressions_aggregation_AggregateFunctionCount
-                      quickstep_expressions_aggregation_AggregateFunctionMax
-                      quickstep_expressions_aggregation_AggregateFunctionMin
-                      quickstep_expressions_aggregation_AggregateFunctionSum
-                      quickstep_expressions_aggregation_AggregationID
-                      quickstep_utility_Macros)
-target_link_libraries(quickstep_expressions_aggregation_AggregateFunctionMax
-                      glog
-                      quickstep_expressions_aggregation_AggregateFunction
-                      quickstep_expressions_aggregation_AggregationHandleMax
-                      quickstep_expressions_aggregation_AggregationID
-                      quickstep_types_Type
-                      quickstep_types_operations_comparisons_Comparison
-                      quickstep_types_operations_comparisons_ComparisonFactory
-                      quickstep_types_operations_comparisons_ComparisonID
-                      quickstep_utility_Macros)
-target_link_libraries(quickstep_expressions_aggregation_AggregateFunctionMin
-                      glog
-                      quickstep_expressions_aggregation_AggregateFunction
-                      quickstep_expressions_aggregation_AggregationHandleMin
-                      quickstep_expressions_aggregation_AggregationID
-                      quickstep_types_Type
-                      quickstep_types_operations_comparisons_Comparison
-                      quickstep_types_operations_comparisons_ComparisonFactory
-                      quickstep_types_operations_comparisons_ComparisonID
-                      quickstep_utility_Macros)
-target_link_libraries(quickstep_expressions_aggregation_AggregateFunctionSum
-                      glog
-                      quickstep_expressions_aggregation_AggregateFunction
-                      quickstep_expressions_aggregation_AggregationHandleSum
-                      quickstep_expressions_aggregation_AggregationID
-                      quickstep_types_Type
-                      quickstep_types_TypeFactory
-                      quickstep_types_TypeID
-                      quickstep_types_operations_binaryoperations_BinaryOperation
-                      quickstep_types_operations_binaryoperations_BinaryOperationFactory
-                      quickstep_types_operations_binaryoperations_BinaryOperationID
-                      quickstep_utility_Macros)
-target_link_libraries(quickstep_expressions_aggregation_AggregationConcreteHandle
-                      glog
-                      quickstep_catalog_CatalogTypedefs
-                      quickstep_expressions_aggregation_AggregationHandle
-                      quickstep_storage_FastHashTable
-                      quickstep_storage_HashTable
-                      quickstep_storage_HashTableBase
-                      quickstep_storage_HashTableFactory
-                      quickstep_threading_SpinMutex
-                      quickstep_types_TypedValue
-                      quickstep_types_containers_ColumnVector
-                      quickstep_utility_Macros)
-target_link_libraries(quickstep_expressions_aggregation_AggregationHandle
-                      glog
-                      quickstep_catalog_CatalogTypedefs
-                      quickstep_storage_HashTableBase
-                      quickstep_types_TypedValue
-                      quickstep_utility_Macros)
-target_link_libraries(quickstep_expressions_aggregation_AggregationHandleAvg
-                      glog
-                      quickstep_catalog_CatalogTypedefs
-                      quickstep_expressions_aggregation_AggregationConcreteHandle
-                      quickstep_expressions_aggregation_AggregationHandle
-                      quickstep_storage_FastHashTable
-                      quickstep_storage_HashTable
-                      quickstep_storage_HashTableBase
-                      quickstep_storage_HashTableFactory
-                      quickstep_threading_SpinMutex
-                      quickstep_types_Type
-                      quickstep_types_TypeFactory
-                      quickstep_types_TypeID
-                      quickstep_types_TypedValue
-                      quickstep_types_operations_binaryoperations_BinaryOperation
-                      quickstep_types_operations_binaryoperations_BinaryOperationFactory
-                      quickstep_types_operations_binaryoperations_BinaryOperationID
-                      quickstep_utility_Macros)
-target_link_libraries(quickstep_expressions_aggregation_AggregationHandleCount
-                      glog
-                      quickstep_catalog_CatalogTypedefs
-                      quickstep_expressions_aggregation_AggregationConcreteHandle
-                      quickstep_expressions_aggregation_AggregationHandle
-                      quickstep_storage_FastHashTable
-                      quickstep_storage_HashTable
-                      quickstep_storage_HashTableBase
-                      quickstep_storage_HashTableFactory
-                      quickstep_storage_ValueAccessor
-                      quickstep_storage_ValueAccessorUtil
-                      quickstep_types_TypeFactory
-                      quickstep_types_TypeID
-                      quickstep_types_TypedValue
-                      quickstep_types_containers_ColumnVector
-                      quickstep_types_containers_ColumnVectorUtil
-                      quickstep_utility_Macros)
-target_link_libraries(quickstep_expressions_aggregation_AggregationHandleDistinct
-                      glog
-                      quickstep_catalog_CatalogTypedefs
-                      quickstep_expressions_aggregation_AggregationConcreteHandle
-                      quickstep_storage_HashTable
-                      quickstep_storage_HashTableBase
-                      quickstep_types_TypedValue
-                      quickstep_utility_Macros)
-target_link_libraries(quickstep_expressions_aggregation_AggregationHandleMax
-                      glog
-                      quickstep_catalog_CatalogTypedefs
-                      quickstep_expressions_aggregation_AggregationConcreteHandle
-                      quickstep_expressions_aggregation_AggregationHandle
-                      quickstep_storage_FastHashTable
-                      quickstep_storage_HashTable
-                      quickstep_storage_HashTableBase
-                      quickstep_storage_HashTableFactory
-                      quickstep_threading_SpinMutex
-                      quickstep_types_Type
-                      quickstep_types_TypedValue
-                      quickstep_types_containers_ColumnVector
-                      quickstep_types_operations_comparisons_Comparison
-                      quickstep_types_operations_comparisons_ComparisonFactory
-                      quickstep_types_operations_comparisons_ComparisonID
-                      quickstep_utility_Macros)
-target_link_libraries(quickstep_expressions_aggregation_AggregationHandleMin
-                      glog
-                      quickstep_catalog_CatalogTypedefs
-                      quickstep_expressions_aggregation_AggregationConcreteHandle
-                      quickstep_expressions_aggregation_AggregationHandle
-                      quickstep_storage_FastHashTable
-                      quickstep_storage_HashTable
-                      quickstep_storage_HashTableBase
-                      quickstep_storage_HashTableFactory
-                      quickstep_threading_SpinMutex
-                      quickstep_types_Type
-                      quickstep_types_TypedValue
-                      quickstep_types_containers_ColumnVector
-                      quickstep_types_operations_comparisons_Comparison
-                      quickstep_types_operations_comparisons_ComparisonFactory
-                      quickstep_types_operations_comparisons_ComparisonID
-                      quickstep_utility_Macros)
-target_link_libraries(quickstep_expressions_aggregation_AggregationHandleSum
-                      glog
-                      quickstep_catalog_CatalogTypedefs
-                      quickstep_expressions_aggregation_AggregationConcreteHandle
-                      quickstep_expressions_aggregation_AggregationHandle
-                      quickstep_storage_FastHashTable
-                      quickstep_storage_HashTable
-                      quickstep_storage_HashTableBase
-                      quickstep_storage_HashTableFactory
-                      quickstep_threading_SpinMutex
-                      quickstep_types_Type
-                      quickstep_types_TypeFactory
-                      quickstep_types_TypeID
-                      quickstep_types_TypedValue
-                      quickstep_types_operations_binaryoperations_BinaryOperation
-                      quickstep_types_operations_binaryoperations_BinaryOperationFactory
-                      quickstep_types_operations_binaryoperations_BinaryOperationID
-                      quickstep_utility_Macros)
-
-# Submodule all-in-one library:
-add_library(quickstep_expressions_aggregation ../../empty_src.cpp)
-target_link_libraries(quickstep_expressions_aggregation
-                      quickstep_expressions_aggregation_AggregateFunction
-                      quickstep_expressions_aggregation_AggregateFunction_proto
-                      quickstep_expressions_aggregation_AggregateFunctionAvg
-                      quickstep_expressions_aggregation_AggregateFunctionCount
-                      quickstep_expressions_aggregation_AggregateFunctionFactory
-                      quickstep_expressions_aggregation_AggregateFunctionMax
-                      quickstep_expressions_aggregation_AggregateFunctionMin
-                      quickstep_expressions_aggregation_AggregateFunctionSum
-                      quickstep_expressions_aggregation_AggregationConcreteHandle
-                      quickstep_expressions_aggregation_AggregationHandle
-                      quickstep_expressions_aggregation_AggregationHandleAvg
-                      quickstep_expressions_aggregation_AggregationHandleCount
-                      quickstep_expressions_aggregation_AggregationHandleDistinct
-                      quickstep_expressions_aggregation_AggregationHandleMax
-                      quickstep_expressions_aggregation_AggregationHandleMin
-                      quickstep_expressions_aggregation_AggregationHandleSum
-                      quickstep_expressions_aggregation_AggregationID)
-
-# Tests:
-
-# Unified executable to ammortize cost of linking.
-add_executable(AggregationHandle_tests
-               "${CMAKE_CURRENT_SOURCE_DIR}/tests/AggregationHandleAvg_unittest.cpp"
-               "${CMAKE_CURRENT_SOURCE_DIR}/tests/AggregationHandleCount_unittest.cpp"
-               "${CMAKE_CURRENT_SOURCE_DIR}/tests/AggregationHandleMax_unittest.cpp"
-               "${CMAKE_CURRENT_SOURCE_DIR}/tests/AggregationHandleMin_unittest.cpp"
-               "${CMAKE_CURRENT_SOURCE_DIR}/tests/AggregationHandleSum_unittest.cpp")
-target_link_libraries(AggregationHandle_tests
-                      gtest
-                      gtest_main
-                      quickstep_catalog_CatalogTypedefs
-                      quickstep_expressions_aggregation_AggregateFunction
-                      quickstep_expressions_aggregation_AggregateFunctionFactory
-                      quickstep_expressions_aggregation_AggregationHandle
-                      quickstep_expressions_aggregation_AggregationHandleAvg
-                      quickstep_expressions_aggregation_AggregationHandleCount
-                      quickstep_expressions_aggregation_AggregationHandleMax
-                      quickstep_expressions_aggregation_AggregationHandleMin
-                      quickstep_expressions_aggregation_AggregationHandleSum
-                      quickstep_expressions_aggregation_AggregationID
-                      quickstep_storage_AggregationOperationState
-                      quickstep_storage_HashTableBase
-                      quickstep_storage_StorageManager
-                      quickstep_types_CharType
-                      quickstep_types_DateOperatorOverloads
-                      quickstep_types_DatetimeIntervalType
-                      quickstep_types_DatetimeType
-                      quickstep_types_DoubleType
-                      quickstep_types_FloatType
-                      quickstep_types_IntType
-                      quickstep_types_IntervalLit
-                      quickstep_types_LongType
-                      quickstep_types_Type
-                      quickstep_types_TypeFactory
-                      quickstep_types_TypeID
-                      quickstep_types_TypedValue
-                      quickstep_types_VarCharType
-                      quickstep_types_YearMonthIntervalType
-                      quickstep_types_containers_ColumnVector
-                      quickstep_types_containers_ColumnVectorsValueAccessor
-                      quickstep_types_operations_comparisons_Comparison
-                      quickstep_types_operations_comparisons_ComparisonFactory
-                      quickstep_types_operations_comparisons_ComparisonID)
-add_test(AggregationHandle_tests AggregationHandle_tests)

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/expressions/aggregation/tests/AggregationHandleAvg_unittest.cpp
----------------------------------------------------------------------
diff --git a/expressions/aggregation/tests/AggregationHandleAvg_unittest.cpp b/expressions/aggregation/tests/AggregationHandleAvg_unittest.cpp
deleted file mode 100644
index 79d4448..0000000
--- a/expressions/aggregation/tests/AggregationHandleAvg_unittest.cpp
+++ /dev/null
@@ -1,596 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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 <cstddef>
-#include <cstdint>
-#include <memory>
-#include <vector>
-
-#include "catalog/CatalogTypedefs.hpp"
-#include "expressions/aggregation/AggregateFunction.hpp"
-#include "expressions/aggregation/AggregateFunctionFactory.hpp"
-#include "expressions/aggregation/AggregationHandle.hpp"
-#include "expressions/aggregation/AggregationHandleAvg.hpp"
-#include "expressions/aggregation/AggregationID.hpp"
-#include "storage/AggregationOperationState.hpp"
-#include "storage/FastHashTableFactory.hpp"
-#include "storage/StorageManager.hpp"
-#include "types/CharType.hpp"
-#include "types/DateOperatorOverloads.hpp"
-#include "types/DatetimeIntervalType.hpp"
-#include "types/DoubleType.hpp"
-#include "types/FloatType.hpp"
-#include "types/IntType.hpp"
-#include "types/IntervalLit.hpp"
-#include "types/LongType.hpp"
-#include "types/Type.hpp"
-#include "types/TypeFactory.hpp"
-#include "types/TypeID.hpp"
-#include "types/TypedValue.hpp"
-#include "types/VarCharType.hpp"
-#include "types/YearMonthIntervalType.hpp"
-#include "types/containers/ColumnVector.hpp"
-
-#ifdef QUICKSTEP_ENABLE_VECTOR_COPY_ELISION_SELECTION
-#include "types/containers/ColumnVectorsValueAccessor.hpp"
-#endif
-
-#include "gtest/gtest.h"
-
-namespace quickstep {
-
-class AggregationHandleAvgTest : public ::testing::Test {
- protected:
-  static const int kNumSamples = 100;
-
-  // Helper method that calls AggregationHandleAvg::iterateUnaryInl() to
-  // aggregate 'value' into '*state'.
-  void iterateHandle(AggregationState *state, const TypedValue &value) {
-    static_cast<const AggregationHandleAvg &>(*aggregation_handle_avg_)
-        .iterateUnaryInl(static_cast<AggregationStateAvg *>(state), value);
-  }
-
-  void initializeHandle(const Type &type) {
-    aggregation_handle_avg_.reset(
-        AggregateFunctionFactory::Get(AggregationID::kAvg)
-            .createHandle(std::vector<const Type *>(1, &type)));
-    aggregation_handle_avg_state_.reset(
-        aggregation_handle_avg_->createInitialState());
-  }
-
-  static bool ApplyToTypesTest(TypeID typeID) {
-    const Type &type =
-        (typeID == kChar || typeID == kVarChar)
-            ? TypeFactory::GetType(typeID, static_cast<std::size_t>(10))
-            : TypeFactory::GetType(typeID);
-
-    return AggregateFunctionFactory::Get(AggregationID::kAvg)
-        .canApplyToTypes(std::vector<const Type *>(1, &type));
-  }
-
-  static bool ResultTypeForArgumentTypeTest(TypeID input_type_id,
-                                            TypeID output_type_id) {
-    const Type *result_type =
-        AggregateFunctionFactory::Get(AggregationID::kAvg)
-            .resultTypeForArgumentTypes(std::vector<const Type *>(
-                1, &TypeFactory::GetType(input_type_id)));
-    return (result_type->getTypeID() == output_type_id);
-  }
-
-  template <typename CppType>
-  static void CheckAvgValue(CppType expected,
-                            const AggregationHandle &handle,
-                            const AggregationState &state) {
-    EXPECT_EQ(expected, handle.finalize(state).getLiteral<CppType>());
-  }
-
-  template <typename CppType>
-  static void CheckAvgValue(CppType expected, const TypedValue &value) {
-    EXPECT_EQ(expected, value.getLiteral<CppType>());
-  }
-
-  // Static templated method for set a meaningful value to data types.
-  template <typename CppType>
-  static void SetDataType(int value, CppType *data) {
-    *data = value;
-  }
-
-  template <typename GenericType, typename OutputType = DoubleType>
-  void checkAggregationAvgGeneric() {
-    const GenericType &type = GenericType::Instance(true);
-    initializeHandle(type);
-    EXPECT_TRUE(
-        aggregation_handle_avg_->finalize(*aggregation_handle_avg_state_)
-            .isNull());
-
-    typename GenericType::cpptype val;
-    typename GenericType::cpptype sum;
-    SetDataType(0, &sum);
-
-    iterateHandle(aggregation_handle_avg_state_.get(), type.makeNullValue());
-    for (int i = 0; i < kNumSamples; ++i) {
-      if (type.getTypeID() == kInt || type.getTypeID() == kLong) {
-        SetDataType(i - 10, &val);
-      } else {
-        SetDataType(static_cast<float>(i - 10) / 10, &val);
-      }
-      iterateHandle(aggregation_handle_avg_state_.get(), type.makeValue(&val));
-      sum += val;
-    }
-    iterateHandle(aggregation_handle_avg_state_.get(), type.makeNullValue());
-    CheckAvgValue<typename OutputType::cpptype>(
-        static_cast<typename OutputType::cpptype>(sum) / kNumSamples,
-        *aggregation_handle_avg_,
-        *aggregation_handle_avg_state_);
-
-    // Test mergeStates().
-    std::unique_ptr<AggregationState> merge_state(
-        aggregation_handle_avg_->createInitialState());
-    aggregation_handle_avg_->mergeStates(*merge_state,
-                                         aggregation_handle_avg_state_.get());
-
-    iterateHandle(merge_state.get(), type.makeNullValue());
-    for (int i = 0; i < kNumSamples; ++i) {
-      if (type.getTypeID() == kInt || type.getTypeID() == kLong) {
-        SetDataType(i - 10, &val);
-      } else {
-        SetDataType(static_cast<float>(i - 10) / 10, &val);
-      }
-      iterateHandle(merge_state.get(), type.makeValue(&val));
-      sum += val;
-    }
-
-    aggregation_handle_avg_->mergeStates(*merge_state,
-                                         aggregation_handle_avg_state_.get());
-    CheckAvgValue<typename OutputType::cpptype>(
-        static_cast<typename OutputType::cpptype>(sum) / (2 * kNumSamples),
-        *aggregation_handle_avg_,
-        *aggregation_handle_avg_state_);
-  }
-
-  template <typename GenericType>
-  ColumnVector* createColumnVectorGeneric(const Type &type,
-                                          typename GenericType::cpptype *sum) {
-    NativeColumnVector *column = new NativeColumnVector(type, kNumSamples + 3);
-
-    typename GenericType::cpptype val;
-    SetDataType(0, sum);
-
-    column->appendTypedValue(type.makeNullValue());
-    for (int i = 0; i < kNumSamples; ++i) {
-      if (type.getTypeID() == kInt || type.getTypeID() == kLong) {
-        SetDataType(i - 10, &val);
-      } else {
-        SetDataType(static_cast<float>(i - 10) / 10, &val);
-      }
-      column->appendTypedValue(type.makeValue(&val));
-      *sum += val;
-      // One NULL in the middle.
-      if (i == kNumSamples / 2) {
-        column->appendTypedValue(type.makeNullValue());
-      }
-    }
-    column->appendTypedValue(type.makeNullValue());
-
-    return column;
-  }
-
-  template <typename GenericType, typename OutputType = DoubleType>
-  void checkAggregationAvgGenericColumnVector() {
-    const GenericType &type = GenericType::Instance(true);
-    initializeHandle(type);
-    EXPECT_TRUE(
-        aggregation_handle_avg_->finalize(*aggregation_handle_avg_state_)
-            .isNull());
-
-    typename GenericType::cpptype sum;
-    SetDataType(0, &sum);
-    std::vector<std::unique_ptr<ColumnVector>> column_vectors;
-    column_vectors.emplace_back(
-        createColumnVectorGeneric<GenericType>(type, &sum));
-
-    std::unique_ptr<AggregationState> cv_state(
-        aggregation_handle_avg_->accumulateColumnVectors(column_vectors));
-
-    // Test the state generated directly by accumulateColumnVectors(), and also
-    // test after merging back.
-    CheckAvgValue<typename OutputType::cpptype>(
-        static_cast<typename OutputType::cpptype>(sum) / kNumSamples,
-        *aggregation_handle_avg_,
-        *cv_state);
-
-    aggregation_handle_avg_->mergeStates(*cv_state,
-                                         aggregation_handle_avg_state_.get());
-    CheckAvgValue<typename OutputType::cpptype>(
-        static_cast<typename OutputType::cpptype>(sum) / kNumSamples,
-        *aggregation_handle_avg_,
-        *aggregation_handle_avg_state_);
-  }
-
-#ifdef QUICKSTEP_ENABLE_VECTOR_COPY_ELISION_SELECTION
-  template <typename GenericType, typename OutputType = DoubleType>
-  void checkAggregationAvgGenericValueAccessor() {
-    const GenericType &type = GenericType::Instance(true);
-    initializeHandle(type);
-    EXPECT_TRUE(
-        aggregation_handle_avg_->finalize(*aggregation_handle_avg_state_)
-            .isNull());
-
-    typename GenericType::cpptype sum;
-    SetDataType(0, &sum);
-    std::unique_ptr<ColumnVectorsValueAccessor> accessor(
-        new ColumnVectorsValueAccessor());
-    accessor->addColumn(createColumnVectorGeneric<GenericType>(type, &sum));
-
-    std::unique_ptr<AggregationState> va_state(
-        aggregation_handle_avg_->accumulateValueAccessor(
-            accessor.get(), std::vector<attribute_id>(1, 0)));
-
-    // Test the state generated directly by accumulateValueAccessor(), and also
-    // test after merging back.
-    CheckAvgValue<typename OutputType::cpptype>(
-        static_cast<typename OutputType::cpptype>(sum) / kNumSamples,
-        *aggregation_handle_avg_,
-        *va_state);
-
-    aggregation_handle_avg_->mergeStates(*va_state,
-                                         aggregation_handle_avg_state_.get());
-    CheckAvgValue<typename OutputType::cpptype>(
-        static_cast<typename OutputType::cpptype>(sum) / kNumSamples,
-        *aggregation_handle_avg_,
-        *aggregation_handle_avg_state_);
-  }
-#endif  // QUICKSTEP_ENABLE_VECTOR_COPY_ELISION_SELECTION
-
-  std::unique_ptr<AggregationHandle> aggregation_handle_avg_;
-  std::unique_ptr<AggregationState> aggregation_handle_avg_state_;
-  std::unique_ptr<StorageManager> storage_manager_;
-};
-
-const int AggregationHandleAvgTest::kNumSamples;
-
-template <>
-void AggregationHandleAvgTest::CheckAvgValue<double>(
-    double expected,
-    const AggregationHandle &handle,
-    const AggregationState &state) {
-  EXPECT_DOUBLE_EQ(expected, handle.finalize(state).getLiteral<double>());
-}
-
-template <>
-void AggregationHandleAvgTest::SetDataType<DatetimeIntervalLit>(
-    int value, DatetimeIntervalLit *data) {
-  data->interval_ticks = value;
-}
-
-template <>
-void AggregationHandleAvgTest::SetDataType<YearMonthIntervalLit>(
-    int value, YearMonthIntervalLit *data) {
-  data->months = value;
-}
-
-typedef AggregationHandleAvgTest AggregationHandleAvgDeathTest;
-
-TEST_F(AggregationHandleAvgTest, IntTypeTest) {
-  checkAggregationAvgGeneric<IntType>();
-}
-
-TEST_F(AggregationHandleAvgTest, LongTypeTest) {
-  checkAggregationAvgGeneric<LongType>();
-}
-
-TEST_F(AggregationHandleAvgTest, FloatTypeTest) {
-  checkAggregationAvgGeneric<FloatType>();
-}
-
-TEST_F(AggregationHandleAvgTest, DoubleTypeTest) {
-  checkAggregationAvgGeneric<DoubleType>();
-}
-
-TEST_F(AggregationHandleAvgTest, DatetimeIntervalTypeTest) {
-  checkAggregationAvgGeneric<DatetimeIntervalType, DatetimeIntervalType>();
-}
-
-TEST_F(AggregationHandleAvgTest, YearMonthIntervalTypeTest) {
-  checkAggregationAvgGeneric<YearMonthIntervalType, YearMonthIntervalType>();
-}
-
-TEST_F(AggregationHandleAvgTest, IntTypeColumnVectorTest) {
-  checkAggregationAvgGenericColumnVector<IntType>();
-}
-
-TEST_F(AggregationHandleAvgTest, LongTypeColumnVectorTest) {
-  checkAggregationAvgGenericColumnVector<LongType>();
-}
-
-TEST_F(AggregationHandleAvgTest, FloatTypeColumnVectorTest) {
-  checkAggregationAvgGenericColumnVector<FloatType>();
-}
-
-TEST_F(AggregationHandleAvgTest, DoubleTypeColumnVectorTest) {
-  checkAggregationAvgGenericColumnVector<DoubleType>();
-}
-
-TEST_F(AggregationHandleAvgTest, DatetimeIntervalTypeColumnVectorTest) {
-  checkAggregationAvgGenericColumnVector<DatetimeIntervalType,
-                                         DatetimeIntervalType>();
-}
-
-TEST_F(AggregationHandleAvgTest, YearMonthIntervalTypeColumnVectorTest) {
-  checkAggregationAvgGenericColumnVector<YearMonthIntervalType,
-                                         YearMonthIntervalType>();
-}
-
-#ifdef QUICKSTEP_ENABLE_VECTOR_COPY_ELISION_SELECTION
-TEST_F(AggregationHandleAvgTest, IntTypeValueAccessorTest) {
-  checkAggregationAvgGenericValueAccessor<IntType>();
-}
-
-TEST_F(AggregationHandleAvgTest, LongTypeValueAccessorTest) {
-  checkAggregationAvgGenericValueAccessor<LongType>();
-}
-
-TEST_F(AggregationHandleAvgTest, FloatTypeValueAccessorTest) {
-  checkAggregationAvgGenericValueAccessor<FloatType>();
-}
-
-TEST_F(AggregationHandleAvgTest, DoubleTypeValueAccessorTest) {
-  checkAggregationAvgGenericValueAccessor<DoubleType>();
-}
-
-TEST_F(AggregationHandleAvgTest, DatetimeIntervalTypeValueAccessorTest) {
-  checkAggregationAvgGenericValueAccessor<DatetimeIntervalType,
-                                          DatetimeIntervalType>();
-}
-
-TEST_F(AggregationHandleAvgTest, YearMonthIntervalTypeValueAccessorTest) {
-  checkAggregationAvgGenericValueAccessor<YearMonthIntervalType,
-                                          YearMonthIntervalType>();
-}
-#endif  // QUICKSTEP_ENABLE_VECTOR_COPY_ELISION_SELECTION
-
-#ifdef QUICKSTEP_DEBUG
-TEST_F(AggregationHandleAvgDeathTest, CharTypeTest) {
-  const Type &type = CharType::Instance(true, 10);
-  EXPECT_DEATH(initializeHandle(type), "");
-}
-
-TEST_F(AggregationHandleAvgDeathTest, VarTypeTest) {
-  const Type &type = VarCharType::Instance(true, 10);
-  EXPECT_DEATH(initializeHandle(type), "");
-}
-
-TEST_F(AggregationHandleAvgDeathTest, WrongTypeTest) {
-  const Type &int_non_null_type = IntType::Instance(false);
-  const Type &long_type = LongType::Instance(true);
-  const Type &double_type = DoubleType::Instance(true);
-  const Type &float_type = FloatType::Instance(true);
-  const Type &char_type = CharType::Instance(true, 10);
-  const Type &varchar_type = VarCharType::Instance(true, 10);
-
-  initializeHandle(IntType::Instance(true));
-  int int_val = 0;
-  std::int64_t long_val = 0;
-  double double_val = 0;
-  float float_val = 0;
-
-  iterateHandle(aggregation_handle_avg_state_.get(),
-                int_non_null_type.makeValue(&int_val));
-
-  EXPECT_DEATH(iterateHandle(aggregation_handle_avg_state_.get(),
-                             long_type.makeValue(&long_val)),
-               "");
-  EXPECT_DEATH(iterateHandle(aggregation_handle_avg_state_.get(),
-                             double_type.makeValue(&double_val)),
-               "");
-  EXPECT_DEATH(iterateHandle(aggregation_handle_avg_state_.get(),
-                             float_type.makeValue(&float_val)),
-               "");
-  EXPECT_DEATH(iterateHandle(aggregation_handle_avg_state_.get(),
-                             char_type.makeValue("asdf", 5)),
-               "");
-  EXPECT_DEATH(iterateHandle(aggregation_handle_avg_state_.get(),
-                             varchar_type.makeValue("asdf", 5)),
-               "");
-
-  // Test mergeStates() with incorrectly typed handles.
-  std::unique_ptr<AggregationHandle> aggregation_handle_avg_double(
-      AggregateFunctionFactory::Get(AggregationID::kAvg)
-          .createHandle(std::vector<const Type *>(1, &double_type)));
-  std::unique_ptr<AggregationState> aggregation_state_avg_merge_double(
-      aggregation_handle_avg_double->createInitialState());
-  static_cast<const AggregationHandleAvg &>(*aggregation_handle_avg_double)
-      .iterateUnaryInl(static_cast<AggregationStateAvg *>(
-                           aggregation_state_avg_merge_double.get()),
-                       double_type.makeValue(&double_val));
-  EXPECT_DEATH(
-      aggregation_handle_avg_->mergeStates(*aggregation_state_avg_merge_double,
-                                           aggregation_handle_avg_state_.get()),
-      "");
-
-  std::unique_ptr<AggregationHandle> aggregation_handle_avg_float(
-      AggregateFunctionFactory::Get(AggregationID::kAvg)
-          .createHandle(std::vector<const Type *>(1, &float_type)));
-  std::unique_ptr<AggregationState> aggregation_state_avg_merge_float(
-      aggregation_handle_avg_float->createInitialState());
-  static_cast<const AggregationHandleAvg &>(*aggregation_handle_avg_float)
-      .iterateUnaryInl(static_cast<AggregationStateAvg *>(
-                           aggregation_state_avg_merge_float.get()),
-                       float_type.makeValue(&float_val));
-  EXPECT_DEATH(
-      aggregation_handle_avg_->mergeStates(*aggregation_state_avg_merge_float,
-                                           aggregation_handle_avg_state_.get()),
-      "");
-}
-#endif
-
-TEST_F(AggregationHandleAvgTest, canApplyToTypeTest) {
-  EXPECT_TRUE(ApplyToTypesTest(kInt));
-  EXPECT_TRUE(ApplyToTypesTest(kLong));
-  EXPECT_TRUE(ApplyToTypesTest(kFloat));
-  EXPECT_TRUE(ApplyToTypesTest(kDouble));
-  EXPECT_FALSE(ApplyToTypesTest(kChar));
-  EXPECT_FALSE(ApplyToTypesTest(kVarChar));
-  EXPECT_FALSE(ApplyToTypesTest(kDatetime));
-  EXPECT_TRUE(ApplyToTypesTest(kDatetimeInterval));
-  EXPECT_TRUE(ApplyToTypesTest(kYearMonthInterval));
-}
-
-TEST_F(AggregationHandleAvgTest, ResultTypeForArgumentTypeTest) {
-  EXPECT_TRUE(ResultTypeForArgumentTypeTest(kInt, kDouble));
-  EXPECT_TRUE(ResultTypeForArgumentTypeTest(kLong, kDouble));
-  EXPECT_TRUE(ResultTypeForArgumentTypeTest(kFloat, kDouble));
-  EXPECT_TRUE(ResultTypeForArgumentTypeTest(kDouble, kDouble));
-  EXPECT_TRUE(
-      ResultTypeForArgumentTypeTest(kDatetimeInterval, kDatetimeInterval));
-  EXPECT_TRUE(
-      ResultTypeForArgumentTypeTest(kYearMonthInterval, kYearMonthInterval));
-}
-
-TEST_F(AggregationHandleAvgTest, GroupByTableMergeTestAvg) {
-  const Type &long_non_null_type = LongType::Instance(false);
-  initializeHandle(long_non_null_type);
-  storage_manager_.reset(new StorageManager("./test_avg_data"));
-  std::unique_ptr<AggregationStateHashTableBase> source_hash_table(
-      AggregationStateFastHashTableFactory::CreateResizable(
-          HashTableImplType::kSeparateChaining,
-          std::vector<const Type *>(1, &long_non_null_type),
-          10,
-          {aggregation_handle_avg_.get()->getPayloadSize()},
-          {aggregation_handle_avg_.get()},
-          storage_manager_.get()));
-  std::unique_ptr<AggregationStateHashTableBase> destination_hash_table(
-      AggregationStateFastHashTableFactory::CreateResizable(
-          HashTableImplType::kSeparateChaining,
-          std::vector<const Type *>(1, &long_non_null_type),
-          10,
-          {aggregation_handle_avg_.get()->getPayloadSize()},
-          {aggregation_handle_avg_.get()},
-          storage_manager_.get()));
-
-  AggregationStateFastHashTable *destination_hash_table_derived =
-      static_cast<AggregationStateFastHashTable *>(
-          destination_hash_table.get());
-
-  AggregationStateFastHashTable *source_hash_table_derived =
-      static_cast<AggregationStateFastHashTable *>(source_hash_table.get());
-
-  AggregationHandleAvg *aggregation_handle_avg_derived =
-      static_cast<AggregationHandleAvg *>(aggregation_handle_avg_.get());
-  // We create three keys: first is present in both the hash tables, second key
-  // is present only in the source hash table while the third key is present
-  // the destination hash table only.
-  std::vector<TypedValue> common_key;
-  common_key.emplace_back(static_cast<std::int64_t>(0));
-  std::vector<TypedValue> exclusive_source_key, exclusive_destination_key;
-  exclusive_source_key.emplace_back(static_cast<std::int64_t>(1));
-  exclusive_destination_key.emplace_back(static_cast<std::int64_t>(2));
-
-  const std::int64_t common_key_source_avg = 355;
-  TypedValue common_key_source_avg_val(common_key_source_avg);
-
-  const std::int64_t common_key_destination_avg = 295;
-  TypedValue common_key_destination_avg_val(common_key_destination_avg);
-
-  const std::int64_t exclusive_key_source_avg = 1;
-  TypedValue exclusive_key_source_avg_val(exclusive_key_source_avg);
-
-  const std::int64_t exclusive_key_destination_avg = 1;
-  TypedValue exclusive_key_destination_avg_val(exclusive_key_destination_avg);
-
-  std::unique_ptr<AggregationStateAvg> common_key_source_state(
-      static_cast<AggregationStateAvg *>(
-          aggregation_handle_avg_->createInitialState()));
-  std::unique_ptr<AggregationStateAvg> common_key_destination_state(
-      static_cast<AggregationStateAvg *>(
-          aggregation_handle_avg_->createInitialState()));
-  std::unique_ptr<AggregationStateAvg> exclusive_key_source_state(
-      static_cast<AggregationStateAvg *>(
-          aggregation_handle_avg_->createInitialState()));
-  std::unique_ptr<AggregationStateAvg> exclusive_key_destination_state(
-      static_cast<AggregationStateAvg *>(
-          aggregation_handle_avg_->createInitialState()));
-
-  // Create avg value states for keys.
-  aggregation_handle_avg_derived->iterateUnaryInl(common_key_source_state.get(),
-                                                  common_key_source_avg_val);
-
-  aggregation_handle_avg_derived->iterateUnaryInl(
-      common_key_destination_state.get(), common_key_destination_avg_val);
-
-  aggregation_handle_avg_derived->iterateUnaryInl(
-      exclusive_key_destination_state.get(), exclusive_key_destination_avg_val);
-
-  aggregation_handle_avg_derived->iterateUnaryInl(
-      exclusive_key_source_state.get(), exclusive_key_source_avg_val);
-
-  // Add the key-state pairs to the hash tables.
-  unsigned char buffer[100];
-  buffer[0] = '\0';
-  memcpy(buffer + 1,
-         common_key_source_state.get()->getPayloadAddress(),
-         aggregation_handle_avg_.get()->getPayloadSize());
-  source_hash_table_derived->putCompositeKey(common_key, buffer);
-
-  memcpy(buffer + 1,
-         common_key_destination_state.get()->getPayloadAddress(),
-         aggregation_handle_avg_.get()->getPayloadSize());
-  destination_hash_table_derived->putCompositeKey(common_key, buffer);
-
-  memcpy(buffer + 1,
-         exclusive_key_source_state.get()->getPayloadAddress(),
-         aggregation_handle_avg_.get()->getPayloadSize());
-  source_hash_table_derived->putCompositeKey(exclusive_source_key, buffer);
-
-  memcpy(buffer + 1,
-         exclusive_key_destination_state.get()->getPayloadAddress(),
-         aggregation_handle_avg_.get()->getPayloadSize());
-  destination_hash_table_derived->putCompositeKey(exclusive_destination_key,
-                                                      buffer);
-
-  EXPECT_EQ(2u, destination_hash_table_derived->numEntries());
-  EXPECT_EQ(2u, source_hash_table_derived->numEntries());
-
-  AggregationOperationState::mergeGroupByHashTables(
-      source_hash_table.get(), destination_hash_table.get());
-
-  EXPECT_EQ(3u, destination_hash_table_derived->numEntries());
-
-  CheckAvgValue<double>(
-      (common_key_destination_avg_val.getLiteral<std::int64_t>() +
-       common_key_source_avg_val.getLiteral<std::int64_t>()) /
-          static_cast<double>(2),
-      aggregation_handle_avg_derived->finalizeHashTableEntryFast(
-          destination_hash_table_derived->getSingleCompositeKey(common_key) +
-          1));
-  CheckAvgValue<double>(
-      exclusive_key_destination_avg_val.getLiteral<std::int64_t>(),
-      aggregation_handle_avg_derived->finalizeHashTableEntryFast(
-          destination_hash_table_derived->getSingleCompositeKey(
-              exclusive_destination_key) +
-          1));
-  CheckAvgValue<double>(
-      exclusive_key_source_avg_val.getLiteral<std::int64_t>(),
-      aggregation_handle_avg_derived->finalizeHashTableEntryFast(
-          source_hash_table_derived->getSingleCompositeKey(
-              exclusive_source_key) +
-          1));
-}
-
-}  // namespace quickstep