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:45:55 UTC
[32/51] [abbrv] [partial] incubator-quickstep git commit: remove c++
files
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/expressions/window_aggregation/WindowAggregateFunctionMin.hpp
----------------------------------------------------------------------
diff --git a/expressions/window_aggregation/WindowAggregateFunctionMin.hpp b/expressions/window_aggregation/WindowAggregateFunctionMin.hpp
deleted file mode 100644
index 8bb4386..0000000
--- a/expressions/window_aggregation/WindowAggregateFunctionMin.hpp
+++ /dev/null
@@ -1,79 +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_WINDOW_AGGREGATION_WINDOW_AGGREGATE_FUNCTION_MIN_HPP_
-#define QUICKSTEP_EXPRESSIONS_WINDOW_AGGREGATION_WINDOW_AGGREGATE_FUNCTION_MIN_HPP_
-
-#include <string>
-#include <vector>
-
-#include "expressions/window_aggregation/WindowAggregateFunction.hpp"
-#include "expressions/window_aggregation/WindowAggregationID.hpp"
-#include "utility/Macros.hpp"
-
-namespace quickstep {
-
-class Type;
-class WindowAggregationHandle;
-
-/** \addtogroup Expressions
- * @{
- */
-
-/**
- * @brief WindowAggregateFunction representing SQL MIN() OVER term.
- **/
-class WindowAggregateFunctionMin : public WindowAggregateFunction {
- public:
- static const WindowAggregateFunctionMin& Instance() {
- static WindowAggregateFunctionMin instance;
- return instance;
- }
-
- std::string getName() const override {
- return "MIN";
- }
-
- bool canApplyToTypes(
- const std::vector<const Type*> &argument_types) const override;
-
- const Type* resultTypeForArgumentTypes(
- const std::vector<const Type*> &argument_types) const override;
-
- WindowAggregationHandle* createHandle(
- const std::vector<const Type*> &argument_types,
- const std::vector<std::unique_ptr<const Scalar>> &partition_by_attributes,
- const std::vector<std::unique_ptr<const Scalar>> &order_by_attributes,
- const bool is_row,
- const std::int64_t num_preceding,
- const std::int64_t num_following) const override;
-
- private:
- WindowAggregateFunctionMin()
- : WindowAggregateFunction(WindowAggregationID::kMin) {
- }
-
- DISALLOW_COPY_AND_ASSIGN(WindowAggregateFunctionMin);
-};
-
-/** @} */
-
-} // namespace quickstep
-
-#endif // QUICKSTEP_EXPRESSIONS_WINDOW_AGGREGATION_WINDOW_AGGREGATE_FUNCTION_MIN_HPP_
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/expressions/window_aggregation/WindowAggregateFunctionSum.cpp
----------------------------------------------------------------------
diff --git a/expressions/window_aggregation/WindowAggregateFunctionSum.cpp b/expressions/window_aggregation/WindowAggregateFunctionSum.cpp
deleted file mode 100644
index 14c51d8..0000000
--- a/expressions/window_aggregation/WindowAggregateFunctionSum.cpp
+++ /dev/null
@@ -1,86 +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/window_aggregation/WindowAggregateFunctionSum.hpp"
-
-#include <vector>
-
-#include "expressions/window_aggregation/WindowAggregationHandle.hpp"
-#include "types/Type.hpp"
-#include "types/TypeFactory.hpp"
-#include "types/TypeID.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 {
-
-bool WindowAggregateFunctionSum::canApplyToTypes(
- const std::vector<const Type*> &argument_types) const {
- // SUM is unary.
- if (argument_types.size() != 1) {
- return false;
- }
-
- // Argument must be addable.
- return BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kAdd)
- .canApplyToTypes(*argument_types.front(), *argument_types.front());
-}
-
-const Type* WindowAggregateFunctionSum::resultTypeForArgumentTypes(
- const std::vector<const Type*> &argument_types) const {
- if (!canApplyToTypes(argument_types)) {
- return nullptr;
- }
-
- // SUM may return NULL if there are no input rows, and we automatically widen
- // int to long and float to double to have more headroom when adding up many
- // values.
- const Type *sum_type = &(argument_types.front()->getNullableVersion());
- switch (sum_type->getTypeID()) {
- case kInt:
- sum_type = &TypeFactory::GetType(kLong, true);
- break;
- case kFloat:
- sum_type = &TypeFactory::GetType(kDouble, true);
- break;
- default:
- break;
- }
-
- return sum_type;
-}
-
-WindowAggregationHandle* WindowAggregateFunctionSum::createHandle(
- const std::vector<const Type*> &argument_types,
- const std::vector<std::unique_ptr<const Scalar>> &partition_by_attributes,
- const std::vector<std::unique_ptr<const Scalar>> &order_by_attributes,
- const bool is_row,
- const std::int64_t num_preceding,
- const std::int64_t num_following) const {
- DCHECK(canApplyToTypes(argument_types))
- << "Attempted to create a WindowAggregationHandleSum for argument Type(s) "
- << "that SUM can not be applied to.";
-
- return nullptr;
-}
-
-} // namespace quickstep
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/expressions/window_aggregation/WindowAggregateFunctionSum.hpp
----------------------------------------------------------------------
diff --git a/expressions/window_aggregation/WindowAggregateFunctionSum.hpp b/expressions/window_aggregation/WindowAggregateFunctionSum.hpp
deleted file mode 100644
index 89582dd..0000000
--- a/expressions/window_aggregation/WindowAggregateFunctionSum.hpp
+++ /dev/null
@@ -1,79 +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_WINDOW_AGGREGATION_WINDOW_AGGREGATE_FUNCTION_SUM_HPP_
-#define QUICKSTEP_EXPRESSIONS_WINDOW_AGGREGATION_WINDOW_AGGREGATE_FUNCTION_SUM_HPP_
-
-#include <string>
-#include <vector>
-
-#include "expressions/window_aggregation/WindowAggregateFunction.hpp"
-#include "expressions/window_aggregation/WindowAggregationID.hpp"
-#include "utility/Macros.hpp"
-
-namespace quickstep {
-
-class Type;
-class WindowAggregationHandle;
-
-/** \addtogroup Expressions
- * @{
- */
-
-/**
- * @brief WindowAggregateFunction representing SQL SUM() OVER term.
- **/
-class WindowAggregateFunctionSum : public WindowAggregateFunction {
- public:
- static const WindowAggregateFunctionSum& Instance() {
- static WindowAggregateFunctionSum instance;
- return instance;
- }
-
- std::string getName() const override {
- return "SUM";
- }
-
- bool canApplyToTypes(
- const std::vector<const Type*> &argument_types) const override;
-
- const Type* resultTypeForArgumentTypes(
- const std::vector<const Type*> &argument_types) const override;
-
- WindowAggregationHandle* createHandle(
- const std::vector<const Type*> &argument_types,
- const std::vector<std::unique_ptr<const Scalar>> &partition_by_attributes,
- const std::vector<std::unique_ptr<const Scalar>> &order_by_attributes,
- const bool is_row,
- const std::int64_t num_preceding,
- const std::int64_t num_following) const override;
-
- private:
- WindowAggregateFunctionSum()
- : WindowAggregateFunction(WindowAggregationID::kSum) {
- }
-
- DISALLOW_COPY_AND_ASSIGN(WindowAggregateFunctionSum);
-};
-
-/** @} */
-
-} // namespace quickstep
-
-#endif // QUICKSTEP_EXPRESSIONS_WINDOW_AGGREGATION_WINDOW_AGGREGATE_FUNCTION_SUM_HPP_
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/expressions/window_aggregation/WindowAggregationHandle.cpp
----------------------------------------------------------------------
diff --git a/expressions/window_aggregation/WindowAggregationHandle.cpp b/expressions/window_aggregation/WindowAggregationHandle.cpp
deleted file mode 100644
index f26656d..0000000
--- a/expressions/window_aggregation/WindowAggregationHandle.cpp
+++ /dev/null
@@ -1,186 +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/window_aggregation/WindowAggregationHandle.hpp"
-
-#include <cstddef>
-#include <memory>
-#include <vector>
-
-#include "catalog/CatalogTypedefs.hpp"
-#include "expressions/scalar/Scalar.hpp"
-#include "types/Type.hpp"
-#include "types/TypeFactory.hpp"
-#include "types/TypeID.hpp"
-#include "types/TypedValue.hpp"
-#include "types/containers/ColumnVectorsValueAccessor.hpp"
-#include "types/operations/binary_operations/BinaryOperation.hpp"
-#include "types/operations/binary_operations/BinaryOperationFactory.hpp"
-#include "types/operations/binary_operations/BinaryOperationID.hpp"
-#include "types/operations/comparisons/Comparison.hpp"
-
-#include "glog/logging.h"
-
-namespace quickstep {
-
-WindowAggregationHandle::WindowAggregationHandle(
- const std::vector<std::unique_ptr<const Scalar>> &partition_by_attributes,
- const std::vector<std::unique_ptr<const Scalar>> &order_by_attributes,
- const bool is_row,
- const std::int64_t num_preceding,
- const std::int64_t num_following)
- : is_row_(is_row),
- num_preceding_(num_preceding),
- num_following_(num_following) {
- // IDs and types of partition keys.
- std::vector<const Type*> partition_key_types;
- for (const std::unique_ptr<const Scalar> &partition_by_attribute : partition_by_attributes) {
- partition_key_ids_.push_back(
- partition_by_attribute->getAttributeIdForValueAccessor());
- partition_key_types.push_back(&partition_by_attribute->getType());
- }
-
- // Comparison operators for checking if two tuples belong to the same partition.
- for (const Type *partition_key_type : partition_key_types) {
- partition_equal_comparators_.emplace_back(
- ComparisonFactory::GetComparison(ComparisonID::kEqual)
- .makeUncheckedComparatorForTypes(*partition_key_type, *partition_key_type));
- }
-
- // IDs and types of order keys.
- const Type *first_order_key_type = nullptr;
- for (const std::unique_ptr<const Scalar> &order_by_attribute : order_by_attributes) {
- order_key_ids_.push_back(
- order_by_attribute->getAttributeIdForValueAccessor());
- if (first_order_key_type == nullptr) {
- first_order_key_type = &order_by_attribute->getType();
- }
- }
-
- // ID and type of the first order key if in RANGE mode.
- if (!is_row) {
- DCHECK(first_order_key_type != nullptr);
-
- // Comparators and operators to check window frame in RANGE mode.
- const Type &long_type = TypeFactory::GetType(kLong, false);
- range_compare_type_ =
- TypeFactory::GetUnifyingType(*first_order_key_type, long_type);
-
- range_add_operator_.reset(
- BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kAdd)
- .makeUncheckedBinaryOperatorForTypes(*first_order_key_type, long_type));
- range_comparator_.reset(
- ComparisonFactory::GetComparison(ComparisonID::kLessOrEqual)
- .makeUncheckedComparatorForTypes(*range_compare_type_, *range_compare_type_));
- }
-}
-
-bool WindowAggregationHandle::samePartition(
- const ColumnVectorsValueAccessor *tuple_accessor,
- const tuple_id test_tuple_id) const {
- // If test tuple does not exist.
- if (test_tuple_id < 0 ||
- test_tuple_id >= tuple_accessor->getNumTuples()) {
- return false;
- }
-
- // Check all partition by attributes.
- for (std::size_t partition_by_index = 0;
- partition_by_index < partition_key_ids_.size();
- ++partition_by_index) {
- if (!partition_equal_comparators_[partition_by_index]->compareTypedValues(
- tuple_accessor->getTypedValue(partition_key_ids_[partition_by_index]),
- tuple_accessor->getTypedValueAtAbsolutePosition(
- partition_key_ids_[partition_by_index], test_tuple_id))) {
- return false;
- }
- }
-
- return true;
-}
-
-bool WindowAggregationHandle::inWindow(
- const ColumnVectorsValueAccessor *tuple_accessor,
- const tuple_id test_tuple_id) const {
- // If test tuple does not exist.
- if (!samePartition(tuple_accessor, test_tuple_id)) {
- return false;
- }
-
- tuple_id current_tuple_id = tuple_accessor->getCurrentPosition();
-
- // If test tuple is the current tuple, then it is in the window.
- if (test_tuple_id == current_tuple_id) {
- return true;
- }
-
- // In ROWS mode, check the difference of tuple_id.
- if (is_row_) {
- if (num_preceding_ != -1 &&
- test_tuple_id < current_tuple_id - num_preceding_) {
- return false;
- }
-
- if (num_following_ != -1 &&
- test_tuple_id > current_tuple_id + num_following_) {
- return false;
- }
- } else {
- // In RANGE mode, check the difference of first order key value.
- // Get the test value.
- const Type &long_type = TypeFactory::GetType(kLong, false);
- TypedValue test_value =
- range_add_operator_->applyToTypedValues(
- tuple_accessor->getTypedValueAtAbsolutePosition(order_key_ids_[0], test_tuple_id),
- long_type.makeZeroValue());
-
- // NULL will be considered not in range.
- if (test_value.isNull() ||
- tuple_accessor->getTypedValue(order_key_ids_[0]).isNull()) {
- return false;
- }
-
- // Get the boundary value if it is not UNBOUNDED.
- if (num_preceding_ > -1) {
- // num_preceding needs to be negated for calculation.
- std::int64_t neg_num_preceding = -num_preceding_;
- TypedValue start_boundary_value =
- range_add_operator_->applyToTypedValues(
- tuple_accessor->getTypedValue(order_key_ids_[0]),
- long_type.makeValue(&neg_num_preceding));
- if (!range_comparator_->compareTypedValues(start_boundary_value, test_value)) {
- return false;
- }
- }
-
- if (num_following_ > -1) {
- TypedValue end_boundary_value =
- range_add_operator_->applyToTypedValues(
- tuple_accessor->getTypedValue(order_key_ids_[0]),
- long_type.makeValue(&num_following_));
- if (!range_comparator_->compareTypedValues(test_value, end_boundary_value)) {
- return false;
- }
- }
- }
-
- return true;
-}
-
-} // namespace quickstep
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/expressions/window_aggregation/WindowAggregationHandle.hpp
----------------------------------------------------------------------
diff --git a/expressions/window_aggregation/WindowAggregationHandle.hpp b/expressions/window_aggregation/WindowAggregationHandle.hpp
deleted file mode 100644
index 3569123..0000000
--- a/expressions/window_aggregation/WindowAggregationHandle.hpp
+++ /dev/null
@@ -1,173 +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_WINDOW_AGGREGATION_WINDOW_AGGREGATION_HANDLE_HPP_
-#define QUICKSTEP_EXPRESSIONS_WINDOW_AGGREGATION_WINDOW_AGGREGATION_HANDLE_HPP_
-
-#include <cstddef>
-#include <memory>
-#include <vector>
-
-#include "catalog/CatalogRelationSchema.hpp"
-#include "catalog/CatalogTypedefs.hpp"
-#include "storage/StorageBlockInfo.hpp"
-#include "types/Type.hpp"
-#include "types/TypeFactory.hpp"
-#include "types/TypeID.hpp"
-#include "types/TypedValue.hpp"
-#include "types/containers/ColumnVector.hpp"
-#include "types/containers/ColumnVectorsValueAccessor.hpp"
-#include "types/operations/comparisons/Comparison.hpp"
-#include "types/operations/comparisons/ComparisonFactory.hpp"
-#include "types/operations/comparisons/ComparisonID.hpp"
-#include "types/operations/binary_operations/BinaryOperation.hpp"
-#include "types/operations/binary_operations/BinaryOperationFactory.hpp"
-#include "types/operations/binary_operations/BinaryOperationID.hpp"
-#include "utility/Macros.hpp"
-
-namespace quickstep {
-
-class Scalar;
-class Type;
-class ValueAccessor;
-
-/** \addtogroup Expressions
- * @{
- */
-
-/**
- * @brief WindowAggregationHandle encapsulates logic for actually computing
- * window aggregates with particular argument(s).
- * @note See also WindowAggregateFunction, which represents a SQL aggregate
- * function in the abstract sense.
- *
- * A WindowAggregationHandle is created by calling
- * WindowAggregateFunction::createHandle(). The WindowAggregationHandle object
- * provides methods that are used to actually compute the window aggregate.
- *
- * The work flow for computing a window aggregate is:
- * 1. One thread will handle all the computation, iterating from the first
- * tuple to the last tuple. Note there will be two modes that could be
- * used upon different situations:
- * a. If the window aggregate is defined as accumulative, which are:
- * i. Functions applied to whole partition, such as rank(), ntile()
- * and dense_rank(). (Not implemented yet).
- * ii. The window frame is defined as "BETWEEN UNBOUNDED PRECEDING
- * AND CURRENT ROW" or "BETWEEN CURRENT ROW AND UNBOUNDED
- * FOLLOWING".
- * Then, for functions except median, we could store some global
- * values without keeping all the tuple values around. For simplicity,
- * in avg(), count() and sum(), we treat the accumulative one as
- * sliding window since the time complexity does not vary.
- * b. If the window frame is sliding, such as "BETWEEN 3 PRECEDING AND
- * 3 FOLLOWING", we have to store all the tuples in the state (at
- * least two pointers to the start tuple and end tuple), so that
- * we could know which values should be dropped as the window slides.
- * For each computed value, generate a TypedValue and store it into a
- * ColumnVector for window aggregate values.
- * 2. Return the result ColumnVector.
- *
- * TODO(Shixuan): Currently we don't support parallelization. The basic idea for
- * parallelization is to calculate the partial result inside each block. Each
- * block could visit the following blocks as long as the block's last partition
- * is not finished. WindowAggregationOperationState will be used for handling
- * the global state of the calculation.
- **/
-
-class WindowAggregationHandle {
- public:
- /**
- * @brief Destructor.
- **/
- virtual ~WindowAggregationHandle() {}
-
- /**
- * @brief Calculate the window aggregate result.
- *
- * @param block_accessors A pointer to the value accessor of block attributes.
- * @param arguments The ColumnVectors of arguments
- *
- * @return A ColumnVector of the calculated window aggregates.
- **/
- virtual ColumnVector* calculate(ColumnVectorsValueAccessor* block_accessors,
- const std::vector<ColumnVector*> &arguments) const = 0;
-
- protected:
- /**
- * @brief Constructor.
- *
- * @param partition_by_attributes A list of attributes used as partition key.
- * @param order_by_attributes A list of attributes used as order key.
- * @param is_row True if the frame mode is ROWS, false if RANGE.
- * @param num_preceding The number of rows/range that precedes the current row.
- * @param num_following The number of rows/range that follows the current row.
- **/
- WindowAggregationHandle(
- const std::vector<std::unique_ptr<const Scalar>> &partition_by_attributes,
- const std::vector<std::unique_ptr<const Scalar>> &order_by_attributes,
- const bool is_row,
- const std::int64_t num_preceding,
- const std::int64_t num_following);
-
- /**
- * @brief Check if test tuple is in the same partition as the current
- * tuple in the accessor.
- *
- * @param tuple_accessor The ValueAccessor for tuples.
- * @param test_tuple_id The id of the test tuple.
- *
- * @return True if test tuple is in the same partition as the current tuple in
- * the accessor, false if not.
- **/
- bool samePartition(const ColumnVectorsValueAccessor *tuple_accessor,
- const tuple_id test_tuple_id) const;
-
- /**
- * @brief Check if test tuple is in the defined range.
- *
- * @param tuple_accessor The ValueAccessor for tuples.
- * @param test_tuple_id The id of the test tuple.
- *
- * @return True if test tuple is in the defined window, false if not.
- **/
- bool inWindow(const ColumnVectorsValueAccessor *tuple_accessor,
- const tuple_id test_tuple_id) const;
-
- // IDs and comparators for partition keys.
- std::vector<attribute_id> partition_key_ids_;
- std::vector<std::unique_ptr<UncheckedComparator>> partition_equal_comparators_;
-
- // IDs, type, Comparator and operator for frame boundary check in RANGE mode.
- std::vector<attribute_id> order_key_ids_;
- std::unique_ptr<UncheckedBinaryOperator> range_add_operator_;
- std::unique_ptr<UncheckedComparator> range_comparator_; // Less than or Equal
- const Type* range_compare_type_;
-
- // Window frame information.
- const bool is_row_;
- const std::int64_t num_preceding_;
- const std::int64_t num_following_;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(WindowAggregationHandle);
-};
-
-} // namespace quickstep
-
-#endif // QUICKSTEP_EXPRESSIONS_WINDOW_AGGREGATION_WINDOW_AGGREGATION_HANDLE_HPP_
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/expressions/window_aggregation/WindowAggregationHandleAvg.cpp
----------------------------------------------------------------------
diff --git a/expressions/window_aggregation/WindowAggregationHandleAvg.cpp b/expressions/window_aggregation/WindowAggregationHandleAvg.cpp
deleted file mode 100644
index b1c6e3b..0000000
--- a/expressions/window_aggregation/WindowAggregationHandleAvg.cpp
+++ /dev/null
@@ -1,174 +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/window_aggregation/WindowAggregationHandleAvg.hpp"
-
-#include <cstddef>
-#include <memory>
-#include <vector>
-
-#include "catalog/CatalogTypedefs.hpp"
-#include "expressions/window_aggregation/WindowAggregationHandle.hpp"
-#include "storage/ValueAccessor.hpp"
-#include "types/Type.hpp"
-#include "types/TypeFactory.hpp"
-#include "types/TypeID.hpp"
-#include "types/TypedValue.hpp"
-#include "types/containers/ColumnVectorsValueAccessor.hpp"
-#include "types/operations/binary_operations/BinaryOperation.hpp"
-#include "types/operations/binary_operations/BinaryOperationFactory.hpp"
-#include "types/operations/binary_operations/BinaryOperationID.hpp"
-#include "types/operations/comparisons/Comparison.hpp"
-
-#include "glog/logging.h"
-
-namespace quickstep {
-
-WindowAggregationHandleAvg::WindowAggregationHandleAvg(
- const std::vector<std::unique_ptr<const Scalar>> &partition_by_attributes,
- const std::vector<std::unique_ptr<const Scalar>> &order_by_attributes,
- const bool is_row,
- const std::int64_t num_preceding,
- const std::int64_t num_following,
- const Type *argument_type)
- : WindowAggregationHandle(partition_by_attributes,
- order_by_attributes,
- is_row,
- num_preceding,
- num_following) {
- // We sum Int as Long and Float as Double so that we have more headroom when
- // adding many values.
- TypeID type_id;
- switch (argument_type->getTypeID()) {
- case kInt:
- case kLong:
- type_id = kLong;
- break;
- case kFloat:
- case kDouble:
- type_id = kDouble;
- break;
- default:
- type_id = argument_type->getTypeID();
- break;
- }
-
- sum_type_ = &(TypeFactory::GetType(type_id));
-
- // Result is nullable, because AVG() over 0 values (or all NULL values) is
- // NULL.
- result_type_
- = &(BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kDivide)
- .resultTypeForArgumentTypes(*sum_type_, TypeFactory::GetType(kDouble))
- ->getNullableVersion());
-
- // Make operators to do arithmetic:
- // Add operator for summing argument values.
- fast_add_operator_.reset(
- BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kAdd)
- .makeUncheckedBinaryOperatorForTypes(*sum_type_, *argument_type));
-
- // Subtract operator for dropping argument values off the window.
- fast_subtract_operator_.reset(
- BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kSubtract)
- .makeUncheckedBinaryOperatorForTypes(*sum_type_, *argument_type));
-
- // Divide operator for dividing sum by count to get final average.
- divide_operator_.reset(
- BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kDivide)
- .makeUncheckedBinaryOperatorForTypes(*sum_type_, TypeFactory::GetType(kDouble)));
-}
-
-ColumnVector* WindowAggregationHandleAvg::calculate(
- ColumnVectorsValueAccessor *tuple_accessor,
- const std::vector<ColumnVector*> &arguments) const {
- DCHECK_EQ(1u, arguments.size());
- DCHECK(arguments[0]->isNative());
- DCHECK_EQ(static_cast<std::size_t>(tuple_accessor->getNumTuples()),
- static_cast<const NativeColumnVector*>(arguments[0])->size());
-
- // Initialize the output column and argument accessor.
- NativeColumnVector *window_aggregates =
- new NativeColumnVector(*result_type_, tuple_accessor->getNumTuples());
- ColumnVectorsValueAccessor *argument_accessor = new ColumnVectorsValueAccessor();
- argument_accessor->addColumn(arguments[0]);
-
- // Initialize the information about the window.
- TypedValue sum = sum_type_->makeZeroValue();
- std::uint64_t count = 0;
- tuple_id start_tuple_id = 0; // The id of the first tuple in the window.
- tuple_id end_tuple_id = 0; // The id of the tuple that just passed the last
- // tuple in the window.
-
- // Create a window for each tuple and calculate the window aggregate.
- tuple_accessor->beginIteration();
- argument_accessor->beginIteration();
-
- while (tuple_accessor->next() && argument_accessor->next()) {
- tuple_id current_tuple_id = tuple_accessor->getCurrentPosition();
-
- // If current tuple is not in the same partition as the previous tuple,
- // reset the window.
- if (!samePartition(tuple_accessor, current_tuple_id - 1)) {
- start_tuple_id = current_tuple_id;
- end_tuple_id = current_tuple_id;
- count = 0;
- sum = sum_type_->makeZeroValue();
- }
-
- // Drop tuples that will be out of the window from the beginning.
- while (!inWindow(tuple_accessor, start_tuple_id)) {
- TypedValue start_value =
- argument_accessor->getTypedValueAtAbsolutePosition(0, start_tuple_id);
- // Ignore the value if NULL.
- if (!start_value.isNull()) {
- sum = fast_subtract_operator_->applyToTypedValues(sum, start_value);
- count--;
- }
-
- start_tuple_id++;
- }
-
- // Add tuples that will be included by the window at the end.
- while (inWindow(tuple_accessor, end_tuple_id)) {
- TypedValue end_value =
- argument_accessor->getTypedValueAtAbsolutePosition(0, end_tuple_id);
-
- // Ignore the value if NULL.
- if (!end_value.isNull()) {
- sum = fast_add_operator_->applyToTypedValues(sum, end_value);
- count++;
- }
-
- end_tuple_id++;
- }
-
- // If all values are NULLs, return NULL; Otherwise, return the quotient.
- if (count == 0) {
- window_aggregates->appendTypedValue(result_type_->makeNullValue());
- } else {
- window_aggregates->appendTypedValue(
- divide_operator_->applyToTypedValues(sum, TypedValue(static_cast<double>(count))));
- }
- }
-
- return window_aggregates;
-}
-
-} // namespace quickstep
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/expressions/window_aggregation/WindowAggregationHandleAvg.hpp
----------------------------------------------------------------------
diff --git a/expressions/window_aggregation/WindowAggregationHandleAvg.hpp b/expressions/window_aggregation/WindowAggregationHandleAvg.hpp
deleted file mode 100644
index e3885f0..0000000
--- a/expressions/window_aggregation/WindowAggregationHandleAvg.hpp
+++ /dev/null
@@ -1,92 +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_WINDOW_AGGREGATION_WINDOW_AGGREGATION_HANDLE_AVG_HPP_
-#define QUICKSTEP_EXPRESSIONS_WINDOW_AGGREGATION_WINDOW_AGGREGATION_HANDLE_AVG_HPP_
-
-#include <cstddef>
-#include <cstdint>
-#include <memory>
-#include <queue>
-#include <vector>
-
-#include "catalog/CatalogTypedefs.hpp"
-#include "expressions/window_aggregation/WindowAggregationHandle.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 ColumnVectorsValueAccessor;
-class ValueAccessor;
-
-/** \addtogroup Expressions
- * @{
- */
-
-/**
- * @brief A WindowAggregationHandle for average.
- **/
-class WindowAggregationHandleAvg : public WindowAggregationHandle {
- public:
- ~WindowAggregationHandleAvg() override {}
-
- ColumnVector* calculate(ColumnVectorsValueAccessor* block_accessors,
- const std::vector<ColumnVector*> &arguments) const override;
-
- private:
- friend class WindowAggregateFunctionAvg;
-
- /**
- * @brief Constructor.
- *
- * @param partition_by_attributes A list of attributes used as partition key.
- * @param order_by_attributes A list of attributes used as order key.
- * @param is_row True if the frame mode is ROWS, false if RANGE.
- * @param num_preceding The number of rows/range that precedes the current row.
- * @param num_following The number of rows/range that follows the current row.
- * @param argument_type Type of the argument.
- **/
- WindowAggregationHandleAvg(
- const std::vector<std::unique_ptr<const Scalar>> &partition_by_attributes,
- const std::vector<std::unique_ptr<const Scalar>> &order_by_attributes,
- const bool is_row,
- const std::int64_t num_preceding,
- const std::int64_t num_following,
- const Type *argument_type);
-
- const Type *sum_type_;
- const Type *result_type_;
- std::unique_ptr<UncheckedBinaryOperator> fast_add_operator_;
- std::unique_ptr<UncheckedBinaryOperator> fast_subtract_operator_;
- std::unique_ptr<UncheckedBinaryOperator> divide_operator_;
-
- DISALLOW_COPY_AND_ASSIGN(WindowAggregationHandleAvg);
-};
-
-/** @} */
-
-} // namespace quickstep
-
-#endif // QUICKSTEP_EXPRESSIONS_WINDOW_AGGREGATION_WINDOW_AGGREGATION_HANDLE_AVG_HPP_
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/expressions/window_aggregation/WindowAggregationID.hpp
----------------------------------------------------------------------
diff --git a/expressions/window_aggregation/WindowAggregationID.hpp b/expressions/window_aggregation/WindowAggregationID.hpp
deleted file mode 100644
index da90357..0000000
--- a/expressions/window_aggregation/WindowAggregationID.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_WINDOW_AGGREGATION_WINDOW_AGGREGATION_ID_HPP_
-#define QUICKSTEP_EXPRESSIONS_WINDOW_AGGREGATION_WINDOW_AGGREGATION_ID_HPP_
-
-namespace quickstep {
-
-/** \addtogroup Expressions
- * @{
- */
-
-/**
- * @brief The possible types of window aggregations.
- **/
-enum class WindowAggregationID {
- kAvg,
- kCount,
- kMin,
- kMax,
- kSum
-};
-
-/** @} */
-
-} // namespace quickstep
-
-#endif // QUICKSTEP_EXPRESSIONS_WINDOW_AGGREGATION_WINDOW_AGGREGATION_ID_HPP_
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/expressions/window_aggregation/tests/WindowAggregationHandleAvg_unittest.cpp
----------------------------------------------------------------------
diff --git a/expressions/window_aggregation/tests/WindowAggregationHandleAvg_unittest.cpp b/expressions/window_aggregation/tests/WindowAggregationHandleAvg_unittest.cpp
deleted file mode 100644
index 6e1364a..0000000
--- a/expressions/window_aggregation/tests/WindowAggregationHandleAvg_unittest.cpp
+++ /dev/null
@@ -1,518 +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/CatalogAttribute.hpp"
-#include "catalog/CatalogTypedefs.hpp"
-#include "expressions/scalar/Scalar.hpp"
-#include "expressions/scalar/ScalarAttribute.hpp"
-#include "expressions/window_aggregation/WindowAggregateFunction.hpp"
-#include "expressions/window_aggregation/WindowAggregateFunctionFactory.hpp"
-#include "expressions/window_aggregation/WindowAggregationHandle.hpp"
-#include "expressions/window_aggregation/WindowAggregationID.hpp"
-#include "storage/ValueAccessor.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"
-#include "types/containers/ColumnVectorsValueAccessor.hpp"
-
-#include "gtest/gtest.h"
-
-namespace quickstep {
-
-namespace {
-
- constexpr int kNumTuples = 100;
- constexpr int kNumTuplesPerPartition = 8;
- constexpr int kNullInterval = 25;
- constexpr int kNumPreceding = 2;
- constexpr int kNumFollowing = 2;
- constexpr int kPartitionKeyIndex = 0;
- constexpr int kOrderKeyIndex = 1;
- constexpr int kNumTuplesPerOrderKey = 2;
-
-} // namespace
-
-// Attribute value could be null if set true.
-class WindowAggregationHandleAvgTest : public::testing::Test {
- protected:
- // Handle initialization.
- WindowAggregationHandle* initializeHandle(const Type &argument_type,
- const bool is_row = true,
- const std::int64_t num_preceding = -1,
- const std::int64_t num_following = 0) {
- const WindowAggregateFunction &function =
- WindowAggregateFunctionFactory::Get(WindowAggregationID::kAvg);
- const Type &int_type = TypeFactory::GetType(kInt, false);
- std::vector<std::unique_ptr<const Scalar>> partition_by_attributes;
- std::vector<std::unique_ptr<const Scalar>> order_by_attributes;
- partition_by_attributes.emplace_back(
- new ScalarAttribute(CatalogAttribute(nullptr, "partition_key", int_type, kPartitionKeyIndex)));
- order_by_attributes.emplace_back(
- new ScalarAttribute(CatalogAttribute(nullptr, "order_key", int_type, kOrderKeyIndex)));
- std::vector<const Type*> partition_key_types(1, &TypeFactory::GetType(kInt, false));
-
- return function.createHandle(std::vector<const Type*>(1, &argument_type),
- partition_by_attributes,
- order_by_attributes,
- is_row,
- num_preceding,
- num_following);
- }
-
- // Test canApplyToTypes().
- static bool CanApplyToTypesTest(TypeID typeID) {
- const Type &type = (typeID == kChar || typeID == kVarChar) ?
- TypeFactory::GetType(typeID, static_cast<std::size_t>(10)) :
- TypeFactory::GetType(typeID);
-
- return WindowAggregateFunctionFactory::Get(WindowAggregationID::kAvg).canApplyToTypes(
- std::vector<const Type*>(1, &type));
- }
-
- // Test resultTypeForArgumentTypes().
- static bool ResultTypeForArgumentTypesTest(TypeID input_type_id,
- TypeID output_type_id) {
- const Type *result_type
- = WindowAggregateFunctionFactory::Get(WindowAggregationID::kAvg).resultTypeForArgumentTypes(
- std::vector<const Type*>(1, &TypeFactory::GetType(input_type_id)));
- return (result_type->getTypeID() == output_type_id);
- }
-
- template <typename CppType>
- static void CheckAvgValues(
- const std::vector<CppType*> &expected,
- const ColumnVector *actual) {
- EXPECT_TRUE(actual->isNative());
- const NativeColumnVector *native = static_cast<const NativeColumnVector*>(actual);
-
- EXPECT_EQ(expected.size(), native->size());
- for (std::size_t i = 0; i < expected.size(); ++i) {
- if (expected[i] == nullptr) {
- EXPECT_TRUE(native->getTypedValue(i).isNull());
- } else {
- EXPECT_EQ(*expected[i], native->getTypedValue(i).getLiteral<CppType>());
- }
- }
- }
-
- // Static templated methods 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 checkWindowAggregationAvgGeneric() {
- // Create argument, partition key and cpptype vectors.
- std::vector<typename GenericType::cpptype*> argument_cpp_vector;
- argument_cpp_vector.reserve(kNumTuples);
- ColumnVector *argument_type_vector =
- createArgumentGeneric<GenericType>(&argument_cpp_vector);
- NativeColumnVector *partition_key_vector =
- new NativeColumnVector(IntType::InstanceNonNullable(), kNumTuples);
- NativeColumnVector *order_key_vector =
- new NativeColumnVector(IntType::InstanceNonNullable(), kNumTuples);
-
- for (int i = 0; i < kNumTuples; ++i) {
- partition_key_vector->appendTypedValue(TypedValue(i / kNumTuplesPerPartition));
- order_key_vector->appendTypedValue(TypedValue(i / kNumTuplesPerOrderKey));
- }
-
- // Create tuple ValueAccessor.
- ColumnVectorsValueAccessor *tuple_accessor = new ColumnVectorsValueAccessor();
- tuple_accessor->addColumn(partition_key_vector);
- tuple_accessor->addColumn(order_key_vector);
- tuple_accessor->addColumn(argument_type_vector);
-
- // Test UNBOUNDED PRECEDING AND CURRENT ROW.
- checkAccumulate<GenericType, OutputType>(tuple_accessor,
- argument_type_vector,
- argument_cpp_vector);
- // Test kNumPreceding PRECEDING AND kNumFollowing FOLLOWING.
- checkSlidingWindow<GenericType, OutputType>(tuple_accessor,
- argument_type_vector,
- argument_cpp_vector);
- }
-
- template <typename GenericType>
- ColumnVector *createArgumentGeneric(
- std::vector<typename GenericType::cpptype*> *argument_cpp_vector) {
- const GenericType &type = GenericType::Instance(true);
- NativeColumnVector *column = new NativeColumnVector(type, kNumTuples);
-
- for (int i = 0; i < kNumTuples; ++i) {
- // Insert a NULL every kNullInterval tuples.
- if (i % kNullInterval == 0) {
- argument_cpp_vector->push_back(nullptr);
- column->appendTypedValue(type.makeNullValue());
- continue;
- }
-
- typename GenericType::cpptype *val = new typename GenericType::cpptype;
-
- 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));
- argument_cpp_vector->push_back(val);
- }
-
- return column;
- }
-
- template <typename GenericType, typename OutputType>
- void checkAccumulate(ColumnVectorsValueAccessor *tuple_accessor,
- ColumnVector *argument_type_vector,
- const std::vector<typename GenericType::cpptype*> &argument_cpp_vector) {
- std::vector<ColumnVector*> arguments;
- arguments.push_back(argument_type_vector);
-
- // Check ROWS mode.
- WindowAggregationHandle *rows_handle =
- initializeHandle(GenericType::Instance(true),
- true /* is_row */,
- -1 /* num_preceding: UNBOUNDED PRECEDING */,
- 0 /* num_following: CURRENT ROW */);
- ColumnVector *rows_result =
- rows_handle->calculate(tuple_accessor, arguments);
-
- // Get the cpptype result.
- std::vector<typename OutputType::cpptype*> rows_result_cpp_vector;
- typename GenericType::cpptype rows_sum;
- int rows_count;
- for (std::size_t i = 0; i < argument_cpp_vector.size(); ++i) {
- // Start of new partition
- if (i % kNumTuplesPerPartition == 0) {
- SetDataType(0, &rows_sum);
- rows_count = 0;
- }
-
- typename GenericType::cpptype *value = argument_cpp_vector[i];
- if (value != nullptr) {
- rows_sum += *value;
- rows_count++;
- }
-
- if (rows_count == 0) {
- rows_result_cpp_vector.push_back(nullptr);
- } else {
- typename OutputType::cpptype *result_cpp_value =
- new typename OutputType::cpptype;
- *result_cpp_value = static_cast<typename OutputType::cpptype>(rows_sum) / rows_count;
- rows_result_cpp_vector.push_back(result_cpp_value);
- }
- }
-
- CheckAvgValues(rows_result_cpp_vector, rows_result);
-
- // Check RANGE mode.
- WindowAggregationHandle *range_handle =
- initializeHandle(GenericType::Instance(true),
- false /* is_row */,
- -1 /* num_preceding: UNBOUNDED PRECEDING */,
- 0 /* num_following: CURRENT ROW */);
- ColumnVector *range_result =
- range_handle->calculate(tuple_accessor, arguments);
-
- // Get the cpptype result.
- std::vector<typename OutputType::cpptype*> range_result_cpp_vector;
- typename GenericType::cpptype range_sum;
- int range_count;
- std::size_t current_tuple = 0;
- while (current_tuple < kNumTuples) {
- // Start of new partition
- if (current_tuple % kNumTuplesPerPartition == 0) {
- SetDataType(0, &range_sum);
- range_count = 0;
- }
-
- // We have to consider following tuples with the same order key value.
- std::size_t next_tuple = current_tuple;
- while (next_tuple < kNumTuples &&
- next_tuple / kNumTuplesPerPartition == current_tuple / kNumTuplesPerPartition &&
- next_tuple / kNumTuplesPerOrderKey == current_tuple / kNumTuplesPerOrderKey) {
- typename GenericType::cpptype *value = argument_cpp_vector[next_tuple];
- if (value != nullptr) {
- range_sum += *value;
- range_count++;
- }
-
- next_tuple++;
- }
-
- // Calculate the result cpp value.
- typename OutputType::cpptype *result_cpp_value = nullptr;
- if (range_count != 0) {
- result_cpp_value = new typename OutputType::cpptype;
- *result_cpp_value = static_cast<typename OutputType::cpptype>(range_sum) / range_count;
- }
-
- // Add the result values to the tuples with in the same order key value.
- while (current_tuple != next_tuple) {
- range_result_cpp_vector.push_back(result_cpp_value);
- current_tuple++;
- }
- }
-
- CheckAvgValues(range_result_cpp_vector, range_result);
- }
-
- template <typename GenericType, typename OutputType>
- void checkSlidingWindow(ColumnVectorsValueAccessor *tuple_accessor,
- ColumnVector *argument_type_vector,
- const std::vector<typename GenericType::cpptype*> &argument_cpp_vector) {
- std::vector<ColumnVector*> arguments;
- arguments.push_back(argument_type_vector);
-
- // Check ROWS mode.
- WindowAggregationHandle *rows_handle =
- initializeHandle(GenericType::Instance(true),
- true /* is_row */,
- kNumPreceding,
- kNumFollowing);
- ColumnVector *rows_result =
- rows_handle->calculate(tuple_accessor, arguments);
-
- // Get the cpptype result.
- // For each value, calculate all surrounding values in the window.
- std::vector<typename OutputType::cpptype*> rows_result_cpp_vector;
-
- for (std::size_t i = 0; i < argument_cpp_vector.size(); ++i) {
- typename GenericType::cpptype sum;
- SetDataType(0, &sum);
- int count = 0;
-
- if (argument_cpp_vector[i] != nullptr) {
- sum += *argument_cpp_vector[i];
- count++;
- }
-
- for (std::size_t precede = 1; precede <= kNumPreceding; ++precede) {
- // Not the same partition.
- if (i / kNumTuplesPerPartition != (i - precede) / kNumTuplesPerPartition ||
- i < precede) {
- break;
- }
-
- if (argument_cpp_vector[i - precede] != nullptr) {
- sum += *argument_cpp_vector[i - precede];
- count++;
- }
- }
-
- for (int follow = 1; follow <= kNumPreceding; ++follow) {
- // Not the same partition.
- if (i / kNumTuplesPerPartition != (i + follow) / kNumTuplesPerPartition ||
- i + follow >= kNumTuples) {
- break;
- }
-
- if (argument_cpp_vector[i + follow] != nullptr) {
- sum += *argument_cpp_vector[i + follow];
- count++;
- }
- }
-
- if (count == 0) {
- rows_result_cpp_vector.push_back(nullptr);
- } else {
- typename OutputType::cpptype *result_cpp_value =
- new typename OutputType::cpptype;
- *result_cpp_value = static_cast<typename OutputType::cpptype>(sum) / count;
- rows_result_cpp_vector.push_back(result_cpp_value);
- }
- }
-
- CheckAvgValues(rows_result_cpp_vector, rows_result);
-
- // Check RANGE mode.
- WindowAggregationHandle *range_handle =
- initializeHandle(GenericType::Instance(true),
- false /* is_row */,
- kNumPreceding,
- kNumFollowing);
- ColumnVector *range_result =
- range_handle->calculate(tuple_accessor, arguments);
-
- // Get the cpptype result.
- // For each value, calculate all surrounding values in the window.
- std::vector<typename OutputType::cpptype*> range_result_cpp_vector;
-
- for (std::size_t i = 0; i < argument_cpp_vector.size(); ++i) {
- typename GenericType::cpptype sum;
- SetDataType(0, &sum);
- int count = 0;
-
- if (argument_cpp_vector[i] != nullptr) {
- sum += *argument_cpp_vector[i];
- count++;
- }
-
- int preceding_bound = i / kNumTuplesPerOrderKey - kNumPreceding;
- for (std::size_t precede = 1; precede <= kNumTuples; ++precede) {
- // Not in range or the same partition.
- if (i / kNumTuplesPerPartition != (i - precede) / kNumTuplesPerPartition ||
- static_cast<int>((i - precede) / kNumTuplesPerOrderKey) < preceding_bound) {
- break;
- }
-
- if (argument_cpp_vector[i - precede] != nullptr) {
- sum += *argument_cpp_vector[i - precede];
- count++;
- }
- }
-
- int following_bound = i / kNumTuplesPerOrderKey + kNumFollowing;
- for (int follow = 1; follow <= kNumTuples; ++follow) {
- // Not in range or the same partition.
- if (i + follow >= kNumTuples ||
- i / kNumTuplesPerPartition != (i + follow) / kNumTuplesPerPartition ||
- static_cast<int>((i + follow) / kNumTuplesPerOrderKey) > following_bound) {
- break;
- }
-
- if (argument_cpp_vector[i + follow] != nullptr) {
- sum += *argument_cpp_vector[i + follow];
- count++;
- }
- }
-
- if (count == 0) {
- rows_result_cpp_vector.push_back(nullptr);
- } else {
- typename OutputType::cpptype *result_cpp_value =
- new typename OutputType::cpptype;
- *result_cpp_value = static_cast<typename OutputType::cpptype>(sum) / count;
- range_result_cpp_vector.push_back(result_cpp_value);
- }
- }
-
- CheckAvgValues(range_result_cpp_vector, range_result);
- }
-};
-
-template <>
-void WindowAggregationHandleAvgTest::CheckAvgValues<double>(
- const std::vector<double*> &expected,
- const ColumnVector *actual) {
- EXPECT_TRUE(actual->isNative());
- const NativeColumnVector *native = static_cast<const NativeColumnVector*>(actual);
-
- EXPECT_EQ(expected.size(), native->size());
- for (std::size_t i = 0; i < expected.size(); ++i) {
- if (expected[i] == nullptr) {
- EXPECT_TRUE(native->getTypedValue(i).isNull());
- } else {
- EXPECT_EQ(*expected[i], native->getTypedValue(i).getLiteral<double>());
- }
- }
-}
-
-template <>
-void WindowAggregationHandleAvgTest::SetDataType<DatetimeIntervalLit>(
- int value, DatetimeIntervalLit *data) {
- data->interval_ticks = value;
-}
-
-template <>
-void WindowAggregationHandleAvgTest::SetDataType<YearMonthIntervalLit>(
- int value, YearMonthIntervalLit *data) {
- data->months = value;
-}
-
-typedef WindowAggregationHandleAvgTest WindowAggregationHandleAvgDeathTest;
-
-TEST_F(WindowAggregationHandleAvgTest, IntTypeTest) {
- checkWindowAggregationAvgGeneric<IntType>();
-}
-
-TEST_F(WindowAggregationHandleAvgTest, LongTypeTest) {
- checkWindowAggregationAvgGeneric<LongType>();
-}
-
-TEST_F(WindowAggregationHandleAvgTest, FloatTypeTest) {
- checkWindowAggregationAvgGeneric<FloatType>();
-}
-
-TEST_F(WindowAggregationHandleAvgTest, DoubleTypeTest) {
- checkWindowAggregationAvgGeneric<DoubleType>();
-}
-
-TEST_F(WindowAggregationHandleAvgTest, DatetimeIntervalTypeTest) {
- checkWindowAggregationAvgGeneric<DatetimeIntervalType, DatetimeIntervalType>();
-}
-
-TEST_F(WindowAggregationHandleAvgTest, YearMonthIntervalTypeTest) {
- checkWindowAggregationAvgGeneric<YearMonthIntervalType, YearMonthIntervalType>();
-}
-
-#ifdef QUICKSTEP_DEBUG
-TEST_F(WindowAggregationHandleAvgDeathTest, CharTypeTest) {
- const Type &type = CharType::Instance(true, 10);
- EXPECT_DEATH(initializeHandle(type), "");
-}
-
-TEST_F(WindowAggregationHandleAvgDeathTest, VarTypeTest) {
- const Type &type = VarCharType::Instance(true, 10);
- EXPECT_DEATH(initializeHandle(type), "");
-}
-#endif
-
-TEST_F(WindowAggregationHandleAvgDeathTest, canApplyToTypeTest) {
- EXPECT_TRUE(CanApplyToTypesTest(kInt));
- EXPECT_TRUE(CanApplyToTypesTest(kLong));
- EXPECT_TRUE(CanApplyToTypesTest(kFloat));
- EXPECT_TRUE(CanApplyToTypesTest(kDouble));
- EXPECT_FALSE(CanApplyToTypesTest(kChar));
- EXPECT_FALSE(CanApplyToTypesTest(kVarChar));
- EXPECT_FALSE(CanApplyToTypesTest(kDatetime));
- EXPECT_TRUE(CanApplyToTypesTest(kDatetimeInterval));
- EXPECT_TRUE(CanApplyToTypesTest(kYearMonthInterval));
-}
-
-TEST_F(WindowAggregationHandleAvgDeathTest, ResultTypeForArgumentTypeTest) {
- EXPECT_TRUE(ResultTypeForArgumentTypesTest(kInt, kDouble));
- EXPECT_TRUE(ResultTypeForArgumentTypesTest(kLong, kDouble));
- EXPECT_TRUE(ResultTypeForArgumentTypesTest(kFloat, kDouble));
- EXPECT_TRUE(ResultTypeForArgumentTypesTest(kDouble, kDouble));
- EXPECT_TRUE(ResultTypeForArgumentTypesTest(kDatetimeInterval, kDatetimeInterval));
- EXPECT_TRUE(ResultTypeForArgumentTypesTest(kYearMonthInterval, kYearMonthInterval));
-}
-
-} // namespace quickstep
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/parser/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/parser/CMakeLists.txt b/parser/CMakeLists.txt
deleted file mode 100644
index b1bd870..0000000
--- a/parser/CMakeLists.txt
+++ /dev/null
@@ -1,440 +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.
-
-# Although flex option nounistd works fine for the generated cpp file, we need
-# to make sure this is also set for the header.
-set_property(
- DIRECTORY
- APPEND PROPERTY COMPILE_DEFINITIONS YY_NO_UNISTD_H
-)
-
-find_package(BISON)
-if (BISON_FOUND)
- if (BISON_VERSION VERSION_GREATER 2.4 OR BISON_VERSION VERSION_EQUAL 2.4)
- set(RUN_BISON TRUE)
- else()
- set(RUN_BISON FALSE)
- message(WARNING "You are using a version of bison which is too old to build quickstep's "
- "parser. A preprocessed copy of the parser sources will be used.")
- endif()
-else()
- set(RUN_BISON FALSE)
- message(WARNING "Unable to find bison. A preprocessed copy of the parser sources will be used.")
-endif()
-
-find_package(FLEX)
-if (FLEX_FOUND)
- # TODO(chasseur): This might not be the exact version to test for.
- if (FLEX_VERSION VERSION_GREATER 2.5.38)
- set(RUN_FLEX TRUE)
- else()
- set(RUN_FLEX FALSE)
- message(WARNING "You are using a version of flex which is too old to build quickstep's lexer. "
- "A preprocessed copy of the lexer sources will be used.")
- endif()
-else()
- set(RUN_FLEX FALSE)
- message(WARNING "Unable to find flex. A preprocessed copy of the lexer sources will be used.")
-endif()
-
-
-if (RUN_BISON)
- BISON_TARGET(SqlParser SqlParser.ypp ${CMAKE_CURRENT_BINARY_DIR}/SqlParser_gen.cpp)
-else()
- file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/preprocessed/SqlParser_gen.hpp DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
- file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/preprocessed/SqlParser_gen.cpp DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
- set(BISON_SqlParser_OUTPUTS
- ${CMAKE_CURRENT_BINARY_DIR}/SqlParser_gen.cpp
- ${CMAKE_CURRENT_BINARY_DIR}/SqlParser_gen.hpp)
-endif()
-
-if (RUN_FLEX)
- FILE(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}/SqlLexer_gen.hpp" LEXER_HEADER_FILE)
- FLEX_TARGET(SqlLexer SqlLexer.lpp ${CMAKE_CURRENT_BINARY_DIR}/SqlLexer_gen.cpp
- COMPILE_FLAGS "-i -I --header-file=${LEXER_HEADER_FILE}")
- if (RUN_BISON)
- ADD_FLEX_BISON_DEPENDENCY(SqlLexer SqlParser)
- endif()
-else()
- file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/preprocessed/SqlLexer_gen.hpp DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
- file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/preprocessed/SqlLexer_gen.cpp DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
- set(FLEX_SqlLexer_OUTPUTS
- ${CMAKE_CURRENT_BINARY_DIR}/SqlLexer_gen.cpp
- ${CMAKE_CURRENT_BINARY_DIR}/SqlLexer_gen.hpp)
- if (RUN_BISON)
- set_source_files_properties(
- ${CMAKE_CURRENT_BINARY_DIR}/SqlLexer_gen.hpp
- ${CMAKE_CURRENT_BINARY_DIR}/SqlLexer_gen.cpp
- PROPERTIES OBJECT_DEPENDS ${BISON_SqlParser_OUTPUT_HEADER})
- endif()
-endif()
-
-# Declare micro-libs:
-add_library(quickstep_parser_ParseAssignment ../empty_src.cpp ParseAssignment.hpp)
-add_library(quickstep_parser_ParseAttributeDefinition ParseAttributeDefinition.cpp ParseAttributeDefinition.hpp)
-add_library(quickstep_parser_ParseBasicExpressions ParseBasicExpressions.cpp ParseBasicExpressions.hpp)
-add_library(quickstep_parser_ParseBlockProperties ParseBlockProperties.cpp ParseBlockProperties.hpp)
-add_library(quickstep_parser_ParseCaseExpressions ParseCaseExpressions.cpp ParseCaseExpressions.hpp)
-add_library(quickstep_parser_ParseExpression ../empty_src.cpp ParseExpression.hpp)
-add_library(quickstep_parser_ParseGeneratorTableReference ParseGeneratorTableReference.cpp ParseGeneratorTableReference.hpp)
-add_library(quickstep_parser_ParseGroupBy ParseGroupBy.cpp ParseGroupBy.hpp)
-add_library(quickstep_parser_ParseHaving ParseHaving.cpp ParseHaving.hpp)
-add_library(quickstep_parser_ParseIndexProperties ParseIndexProperties.cpp ParseIndexProperties.hpp)
-add_library(quickstep_parser_ParseJoinedTableReference ParseJoinedTableReference.cpp ParseJoinedTableReference.hpp)
-add_library(quickstep_parser_ParseKeyValue ../empty_src.cpp ParseKeyValue.hpp)
-add_library(quickstep_parser_ParseLimit ParseLimit.cpp ParseLimit.hpp)
-add_library(quickstep_parser_ParseLiteralValue ParseLiteralValue.cpp ParseLiteralValue.hpp)
-add_library(quickstep_parser_ParseOrderBy ParseOrderBy.cpp ParseOrderBy.hpp)
-add_library(quickstep_parser_ParsePartitionClause ../empty_src.cpp ParsePartitionClause.hpp)
-add_library(quickstep_parser_ParsePredicate ParsePredicate.cpp ParsePredicate.hpp)
-add_library(quickstep_parser_ParsePredicateExists ../empty_src.cpp ParsePredicateExists.hpp)
-add_library(quickstep_parser_ParsePredicateInTableQuery ../empty_src.cpp ParsePredicateInTableQuery.hpp)
-add_library(quickstep_parser_ParsePriority ../empty_src.cpp ParsePriority.hpp)
-add_library(quickstep_parser_ParseSample ParseSample.cpp ParseSample.hpp)
-add_library(quickstep_parser_ParseSelect ../empty_src.cpp ParseSelect.hpp)
-add_library(quickstep_parser_ParseSelectionClause ParseSelectionClause.cpp ParseSelectionClause.hpp)
-add_library(quickstep_parser_ParseSimpleTableReference ParseSimpleTableReference.cpp ParseSimpleTableReference.hpp)
-add_library(quickstep_parser_ParseStatement ../empty_src.cpp ParseStatement.hpp)
-add_library(quickstep_parser_ParseString ParseString.cpp ParseString.hpp)
-add_library(quickstep_parser_ParseSubqueryExpression ParseSubqueryExpression.cpp ParseSubqueryExpression.hpp)
-add_library(quickstep_parser_ParseSubqueryTableReference ParseSubqueryTableReference.cpp ParseSubqueryTableReference.hpp)
-add_library(quickstep_parser_ParseTableReference ParseTableReference.cpp ParseTableReference.hpp)
-add_library(quickstep_parser_ParseTreeNode ../empty_src.cpp ParseTreeNode.hpp)
-add_library(quickstep_parser_ParseWindow ../empty_src.cpp ParseWindow.hpp)
-add_library(quickstep_parser_ParserUtil ParserUtil.cpp ParserUtil.hpp)
-add_library(quickstep_parser_SqlParserWrapper SqlParserWrapper.cpp SqlParserWrapper.hpp)
-add_library(quickstep_parser_SqlParser ${BISON_SqlParser_OUTPUTS})
-add_library(quickstep_parser_SqlLexer ${FLEX_SqlLexer_OUTPUTS})
-
-# Link dependencies:
-target_link_libraries(quickstep_parser_ParseAssignment
- quickstep_parser_ParseExpression
- quickstep_parser_ParseString
- quickstep_parser_ParseTreeNode
- quickstep_utility_Macros)
-target_link_libraries(quickstep_parser_ParseAttributeDefinition
- quickstep_parser_ParseString
- quickstep_parser_ParseTreeNode
- quickstep_types_Type
- quickstep_utility_Macros
- quickstep_utility_PtrList)
-target_link_libraries(quickstep_parser_ParseBasicExpressions
- quickstep_parser_ParseExpression
- quickstep_parser_ParseLiteralValue
- quickstep_parser_ParseString
- quickstep_parser_ParseTreeNode
- quickstep_parser_ParseWindow
- quickstep_types_operations_binaryoperations_BinaryOperation
- quickstep_types_operations_unaryoperations_UnaryOperation
- quickstep_utility_Macros
- quickstep_utility_PtrList)
-target_link_libraries(quickstep_parser_ParseBlockProperties
- glog
- quickstep_parser_ParseKeyValue
- quickstep_parser_ParseString
- quickstep_parser_ParseTreeNode
- quickstep_utility_Macros
- quickstep_utility_PtrList
- quickstep_utility_StringUtil)
-target_link_libraries(quickstep_parser_ParseCaseExpressions
- quickstep_parser_ParseExpression
- quickstep_parser_ParsePredicate
- quickstep_parser_ParseTreeNode
- quickstep_utility_Macros
- quickstep_utility_PtrVector)
-target_link_libraries(quickstep_parser_ParseExpression
- quickstep_parser_ParseTreeNode
- quickstep_utility_Macros)
-target_link_libraries(quickstep_parser_ParseGeneratorTableReference
- quickstep_parser_ParseBasicExpressions
- quickstep_parser_ParseTableReference
- quickstep_utility_Macros)
-target_link_libraries(quickstep_parser_ParseGroupBy
- quickstep_parser_ParseExpression
- quickstep_parser_ParseTreeNode
- quickstep_utility_Macros
- quickstep_utility_PtrList)
-target_link_libraries(quickstep_parser_ParseHaving
- quickstep_parser_ParsePredicate
- quickstep_parser_ParseTreeNode
- quickstep_utility_Macros)
-target_link_libraries(quickstep_parser_ParseIndexProperties
- glog
- quickstep_parser_ParseKeyValue
- quickstep_parser_ParseString
- quickstep_parser_ParseTreeNode
- quickstep_storage_StorageBlockLayout_proto
- quickstep_utility_Macros
- quickstep_utility_PtrList
- quickstep_utility_StringUtil)
-target_link_libraries(quickstep_parser_ParseJoinedTableReference
- quickstep_parser_ParsePredicate
- quickstep_parser_ParseTableReference
- quickstep_utility_Macros)
-target_link_libraries(quickstep_parser_ParseLimit
- quickstep_parser_ParseLiteralValue
- quickstep_parser_ParseTreeNode
- quickstep_utility_Macros)
-target_link_libraries(quickstep_parser_ParseLiteralValue
- glog
- quickstep_parser_ParseString
- quickstep_parser_ParseTreeNode
- quickstep_types_DatetimeIntervalType
- quickstep_types_DoubleType
- quickstep_types_IntType
- quickstep_types_LongType
- quickstep_types_NullType
- quickstep_types_Type
- quickstep_types_TypedValue
- quickstep_types_VarCharType
- quickstep_types_YearMonthIntervalType
- quickstep_utility_Macros
- quickstep_utility_SqlError)
-target_link_libraries(quickstep_parser_ParseOrderBy
- quickstep_parser_ParseExpression
- quickstep_parser_ParseTreeNode
- quickstep_utility_Macros
- quickstep_utility_PtrList)
-target_link_libraries(quickstep_parser_ParsePartitionClause
- quickstep_parser_ParseLiteralValue
- quickstep_parser_ParseString
- quickstep_parser_ParseTreeNode
- quickstep_utility_Macros
- quickstep_utility_PtrList)
-target_link_libraries(quickstep_parser_ParsePredicate
- quickstep_parser_ParseExpression
- quickstep_parser_ParseTreeNode
- quickstep_types_operations_comparisons_Comparison
- quickstep_utility_Macros
- quickstep_utility_PtrList)
-target_link_libraries(quickstep_parser_ParsePredicateExists
- quickstep_parser_ParsePredicate
- quickstep_parser_ParseSubqueryExpression
- quickstep_utility_Macros)
-target_link_libraries(quickstep_parser_ParsePredicateInTableQuery
- quickstep_parser_ParseExpression
- quickstep_parser_ParsePredicate
- quickstep_parser_ParseSubqueryExpression
- quickstep_utility_Macros)
-target_link_libraries(quickstep_parser_ParsePriority
- quickstep_parser_ParseLiteralValue
- quickstep_parser_ParseTreeNode
- quickstep_utility_Macros)
-target_link_libraries(quickstep_parser_ParseSample
- quickstep_parser_ParseLiteralValue
- quickstep_parser_ParseTreeNode
- quickstep_utility_Macros)
-target_link_libraries(quickstep_parser_ParseSelect
- glog
- quickstep_parser_ParseGroupBy
- quickstep_parser_ParseHaving
- quickstep_parser_ParseLimit
- quickstep_parser_ParseOrderBy
- quickstep_parser_ParsePredicate
- quickstep_parser_ParseSelectionClause
- quickstep_parser_ParseTableReference
- quickstep_parser_ParseTreeNode
- quickstep_parser_ParseWindow
- quickstep_utility_Macros
- quickstep_utility_PtrList)
-target_link_libraries(quickstep_parser_ParseSelectionClause
- quickstep_parser_ParseExpression
- quickstep_parser_ParseString
- quickstep_parser_ParseTreeNode
- quickstep_utility_Macros
- quickstep_utility_PtrList)
-target_link_libraries(quickstep_parser_ParseSimpleTableReference
- quickstep_parser_ParseSample
- quickstep_parser_ParseString
- quickstep_parser_ParseTableReference
- quickstep_utility_Macros)
-target_link_libraries(quickstep_parser_ParseStatement
- glog
- quickstep_parser_ParseAssignment
- quickstep_parser_ParseAttributeDefinition
- quickstep_parser_ParseBasicExpressions
- quickstep_parser_ParseBlockProperties
- quickstep_parser_ParseIndexProperties
- quickstep_parser_ParseKeyValue
- quickstep_parser_ParsePartitionClause
- quickstep_parser_ParsePredicate
- quickstep_parser_ParsePriority
- quickstep_parser_ParseSelect
- quickstep_parser_ParseString
- quickstep_parser_ParseSubqueryTableReference
- quickstep_parser_ParseTreeNode
- quickstep_storage_StorageBlockInfo
- quickstep_utility_Macros
- quickstep_utility_PtrList
- quickstep_utility_PtrVector)
-target_link_libraries(quickstep_parser_ParseString
- quickstep_parser_ParseTreeNode
- quickstep_utility_Macros)
-target_link_libraries(quickstep_parser_ParseKeyValue
- quickstep_parser_ParseLiteralValue
- quickstep_parser_ParseString
- quickstep_parser_ParseTreeNode
- quickstep_utility_Macros
- quickstep_utility_PtrList)
-target_link_libraries(quickstep_parser_ParseSubqueryExpression
- glog
- quickstep_parser_ParseExpression
- quickstep_parser_ParseSelect
- quickstep_utility_Macros)
-target_link_libraries(quickstep_parser_ParseSubqueryTableReference
- quickstep_parser_ParseSubqueryExpression
- quickstep_parser_ParseTableReference
- quickstep_utility_Macros)
-target_link_libraries(quickstep_parser_ParseTableReference
- quickstep_parser_ParseString
- quickstep_parser_ParseTreeNode
- quickstep_utility_Macros
- quickstep_utility_PtrList)
-target_link_libraries(quickstep_parser_ParseTreeNode
- quickstep_utility_Macros
- quickstep_utility_TreeStringSerializable)
-target_link_libraries(quickstep_parser_ParserUtil
- quickstep_utility_SqlError)
-target_link_libraries(quickstep_parser_ParseWindow
- quickstep_parser_ParseExpression
- quickstep_parser_ParseOrderBy
- quickstep_parser_ParseString
- quickstep_parser_ParseTreeNode
- quickstep_utility_PtrList)
-target_link_libraries(quickstep_parser_SqlLexer
- quickstep_parser_ParseJoinedTableReference
- quickstep_parser_ParseLiteralValue
- quickstep_parser_ParserUtil
- quickstep_parser_ParseString
- quickstep_parser_SqlParser
- quickstep_utility_PtrList
- quickstep_utility_PtrVector)
-target_link_libraries(quickstep_parser_SqlParser
- quickstep_catalog_PartitionSchemeHeader
- quickstep_parser_ParseAssignment
- quickstep_parser_ParseAttributeDefinition
- quickstep_parser_ParseBasicExpressions
- quickstep_parser_ParseBlockProperties
- quickstep_parser_ParseCaseExpressions
- quickstep_parser_ParseExpression
- quickstep_parser_ParseGeneratorTableReference
- quickstep_parser_ParseGroupBy
- quickstep_parser_ParseHaving
- quickstep_parser_ParseJoinedTableReference
- quickstep_parser_ParseKeyValue
- quickstep_parser_ParseLimit
- quickstep_parser_ParseLiteralValue
- quickstep_parser_ParseOrderBy
- quickstep_parser_ParsePartitionClause
- quickstep_parser_ParsePredicate
- quickstep_parser_ParsePredicateExists
- quickstep_parser_ParsePredicateInTableQuery
- quickstep_parser_ParsePriority
- quickstep_parser_ParseSample
- quickstep_parser_ParseSelect
- quickstep_parser_ParseSelectionClause
- quickstep_parser_ParseSimpleTableReference
- quickstep_parser_ParseStatement
- quickstep_parser_ParseString
- quickstep_parser_ParseSubqueryExpression
- quickstep_parser_ParseSubqueryTableReference
- quickstep_parser_ParseTableReference
- quickstep_parser_ParseWindow
- quickstep_parser_ParserUtil
- quickstep_storage_StorageBlockInfo
- 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_types_operations_comparisons_Comparison
- quickstep_types_operations_comparisons_ComparisonFactory
- quickstep_types_operations_comparisons_ComparisonID
- quickstep_types_operations_unaryoperations_UnaryOperation
- quickstep_types_operations_unaryoperations_UnaryOperationFactory
- quickstep_types_operations_unaryoperations_UnaryOperationID
- quickstep_utility_PtrList
- quickstep_utility_PtrVector)
-target_link_libraries(quickstep_parser_SqlParserWrapper
- glog
- quickstep_parser_ParseJoinedTableReference
- quickstep_parser_ParseStatement
- quickstep_parser_SqlLexer
- quickstep_parser_SqlParser
- quickstep_utility_Macros
- quickstep_utility_SqlError)
-
-# Dependencies on generated sources.
-set_property(SOURCE SqlParserWrapper.cpp APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/SqlParser_gen.hpp)
-# The dependency is on the header, but this picks up the generated sources
-# from the CMake environment.
-set_property(SOURCE SqlParserWrapper.cpp APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/SqlLexer_gen.cpp)
-set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/SqlParser_gen.cpp APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/SqlLexer_gen.cpp)
-
-# Lexers generated by some versions of Flex use the C "register" keyword. This
-# supresses warnings about that for the lexer ONLY.
-include(CheckCXXCompilerFlag)
-CHECK_CXX_COMPILER_FLAG("-Wno-deprecated-register" COMPILER_HAS_WNO_DEPRECATED_REGISTER)
-if (COMPILER_HAS_WNO_DEPRECATED_REGISTER)
- set_target_properties(quickstep_parser_SqlLexer PROPERTIES COMPILE_FLAGS "-Wno-deprecated-register")
-endif()
-
-# GCC will make a warning for unsigned-signed comparisons which are inherent
-# in the lexer. For this, we turn off the sign compare.
-set_target_properties(quickstep_parser_SqlLexer PROPERTIES COMPILE_FLAGS "-Wno-sign-compare")
-
-add_subdirectory(tests)
-
-# Module all-in-one library:
-add_library(quickstep_parser ../empty_src.cpp ParserModule.hpp)
-target_link_libraries(quickstep_parser
- quickstep_parser_ParseAssignment
- quickstep_parser_ParseAttributeDefinition
- quickstep_parser_ParseBasicExpressions
- quickstep_parser_ParseBlockProperties
- quickstep_parser_ParseCaseExpressions
- quickstep_parser_ParseExpression
- quickstep_parser_ParseGeneratorTableReference
- quickstep_parser_ParseGroupBy
- quickstep_parser_ParseHaving
- quickstep_parser_ParseIndexProperties
- quickstep_parser_ParseJoinedTableReference
- quickstep_parser_ParseLimit
- quickstep_parser_ParseLiteralValue
- quickstep_parser_ParseOrderBy
- quickstep_parser_ParsePartitionClause
- quickstep_parser_ParsePredicate
- quickstep_parser_ParsePredicateExists
- quickstep_parser_ParsePredicateInTableQuery
- quickstep_parser_ParsePriority
- quickstep_parser_ParserUtil
- quickstep_parser_ParseSample
- quickstep_parser_ParseSelect
- quickstep_parser_ParseSelectionClause
- quickstep_parser_ParseSimpleTableReference
- quickstep_parser_ParseStatement
- quickstep_parser_ParseString
- quickstep_parser_ParseKeyValue
- quickstep_parser_ParseSubqueryExpression
- quickstep_parser_ParseSubqueryTableReference
- quickstep_parser_ParseTableReference
- quickstep_parser_ParseTreeNode
- quickstep_parser_ParseWindow
- quickstep_parser_SqlLexer
- quickstep_parser_SqlParser
- quickstep_parser_SqlParserWrapper)
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/parser/ParseAssignment.hpp
----------------------------------------------------------------------
diff --git a/parser/ParseAssignment.hpp b/parser/ParseAssignment.hpp
deleted file mode 100644
index eea0a7c..0000000
--- a/parser/ParseAssignment.hpp
+++ /dev/null
@@ -1,110 +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_PARSER_PARSE_ASSIGNMENT_HPP_
-#define QUICKSTEP_PARSER_PARSE_ASSIGNMENT_HPP_
-
-#include <memory>
-#include <string>
-#include <vector>
-
-#include "parser/ParseExpression.hpp"
-#include "parser/ParseString.hpp"
-#include "parser/ParseTreeNode.hpp"
-#include "utility/Macros.hpp"
-
-namespace quickstep {
-
-/** \addtogroup Parser
- * @{
- */
-
-/**
- * @brief Parsed representation of an assignment of a value to an attribute.
- **/
-class ParseAssignment : public ParseTreeNode {
- public:
- /**
- * @brief Constructor
- *
- * @param line_number The line number of the first token of this parser node.
- * @param column_number The column number of the first token of this parser node.
- * @param attr_name The name of the attribute in the assignment.
- * @param value The scalar value of the assignment (becomes owned by this
- * ParseAssignment).
- **/
- ParseAssignment(const int line_number, const int column_number, ParseString *attr_name, ParseExpression *value)
- : ParseTreeNode(line_number, column_number), attr_name_(attr_name), value_(value) {
- }
-
- /**
- * @brief Destructor.
- **/
- ~ParseAssignment() override {
- }
-
- std::string getName() const override {
- return "AttributeAssignment";
- }
-
- /**
- * @brief Get the name of the attribute in the assignment.
- *
- * @return The attribute name.
- **/
- const ParseString* attr_name() const {
- return attr_name_.get();
- }
-
- /**
- * @brief Get the scalar in the assignment.
- *
- * @return The scalar value.
- **/
- const ParseExpression& value() const {
- return *value_;
- }
-
- protected:
- void getFieldStringItems(
- std::vector<std::string> *inline_field_names,
- std::vector<std::string> *inline_field_values,
- std::vector<std::string> *non_container_child_field_names,
- std::vector<const ParseTreeNode*> *non_container_child_fields,
- std::vector<std::string> *container_child_field_names,
- std::vector<std::vector<const ParseTreeNode*>> *container_child_fields) const override {
- inline_field_names->push_back("attribute_name");
- inline_field_values->push_back(attr_name_->value());
-
- non_container_child_field_names->push_back("value");
- non_container_child_fields->push_back(value_.get());
- }
-
- private:
- std::unique_ptr<ParseString> attr_name_;
- std::unique_ptr<ParseExpression> value_;
-
- DISALLOW_COPY_AND_ASSIGN(ParseAssignment);
-};
-
-/** @} */
-
-} // namespace quickstep
-
-#endif // QUICKSTEP_PARSER_PARSE_ASSIGNMENT_HPP_