http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/02005508/parser/preprocessed/SqlParser_gen.hpp ---------------------------------------------------------------------- diff --git a/parser/preprocessed/SqlParser_gen.hpp b/parser/preprocessed/SqlParser_gen.hpp index ff73cc7..035e325 100644 --- a/parser/preprocessed/SqlParser_gen.hpp +++ b/parser/preprocessed/SqlParser_gen.hpp @@ -98,88 +98,89 @@ extern int quickstep_yydebug; TOKEN_DESC = 308, TOKEN_DISTINCT = 309, TOKEN_DOUBLE = 310, - TOKEN_DROP = 311, - TOKEN_ELSE = 312, - TOKEN_END = 313, - TOKEN_EXISTS = 314, - TOKEN_EXTRACT = 315, - TOKEN_FALSE = 316, - TOKEN_FIRST = 317, - TOKEN_FLOAT = 318, - TOKEN_FOLLOWING = 319, - TOKEN_FOR = 320, - TOKEN_FOREIGN = 321, - TOKEN_FROM = 322, - TOKEN_FULL = 323, - TOKEN_GROUP = 324, - TOKEN_HASH = 325, - TOKEN_HAVING = 326, - TOKEN_HOUR = 327, - TOKEN_IN = 328, - TOKEN_INDEX = 329, - TOKEN_INNER = 330, - TOKEN_INSERT = 331, - TOKEN_INTEGER = 332, - TOKEN_INTERVAL = 333, - TOKEN_INTO = 334, - TOKEN_JOIN = 335, - TOKEN_KEY = 336, - TOKEN_LAST = 337, - TOKEN_LEFT = 338, - TOKEN_LIMIT = 339, - TOKEN_LONG = 340, - TOKEN_MINUTE = 341, - TOKEN_MONTH = 342, - TOKEN_NULL = 343, - TOKEN_NULLS = 344, - TOKEN_OFF = 345, - TOKEN_ON = 346, - TOKEN_ORDER = 347, - TOKEN_OUTER = 348, - TOKEN_OVER = 349, - TOKEN_PARTITION = 350, - TOKEN_PARTITIONS = 351, - TOKEN_PERCENT = 352, - TOKEN_PRECEDING = 353, - TOKEN_PRIMARY = 354, - TOKEN_PRIORITY = 355, - TOKEN_QUIT = 356, - TOKEN_RANGE = 357, - TOKEN_REAL = 358, - TOKEN_REFERENCES = 359, - TOKEN_RIGHT = 360, - TOKEN_ROW = 361, - TOKEN_ROW_DELIMITER = 362, - TOKEN_ROWS = 363, - TOKEN_SECOND = 364, - TOKEN_SELECT = 365, - TOKEN_SET = 366, - TOKEN_SMA = 367, - TOKEN_SMALLINT = 368, - TOKEN_STDERR = 369, - TOKEN_STDOUT = 370, - TOKEN_SUBSTRING = 371, - TOKEN_TABLE = 372, - TOKEN_THEN = 373, - TOKEN_TIME = 374, - TOKEN_TIMESTAMP = 375, - TOKEN_TO = 376, - TOKEN_TRUE = 377, - TOKEN_TUPLESAMPLE = 378, - TOKEN_UNBOUNDED = 379, - TOKEN_UNIQUE = 380, - TOKEN_UPDATE = 381, - TOKEN_USING = 382, - TOKEN_VALUES = 383, - TOKEN_VARCHAR = 384, - TOKEN_WHEN = 385, - TOKEN_WHERE = 386, - TOKEN_WINDOW = 387, - TOKEN_WITH = 388, - TOKEN_YEAR = 389, - TOKEN_YEARMONTH = 390, - TOKEN_EOF = 391, - TOKEN_LEX_ERROR = 392 + TOKEN_DOUBLECOLON = 311, + TOKEN_DROP = 312, + TOKEN_ELSE = 313, + TOKEN_END = 314, + TOKEN_EXISTS = 315, + TOKEN_EXTRACT = 316, + TOKEN_FALSE = 317, + TOKEN_FIRST = 318, + TOKEN_FLOAT = 319, + TOKEN_FOLLOWING = 320, + TOKEN_FOR = 321, + TOKEN_FOREIGN = 322, + TOKEN_FROM = 323, + TOKEN_FULL = 324, + TOKEN_GROUP = 325, + TOKEN_HASH = 326, + TOKEN_HAVING = 327, + TOKEN_HOUR = 328, + TOKEN_IN = 329, + TOKEN_INDEX = 330, + TOKEN_INNER = 331, + TOKEN_INSERT = 332, + TOKEN_INTEGER = 333, + TOKEN_INTERVAL = 334, + TOKEN_INTO = 335, + TOKEN_JOIN = 336, + TOKEN_KEY = 337, + TOKEN_LAST = 338, + TOKEN_LEFT = 339, + TOKEN_LIMIT = 340, + TOKEN_LONG = 341, + TOKEN_MINUTE = 342, + TOKEN_MONTH = 343, + TOKEN_NULL = 344, + TOKEN_NULLS = 345, + TOKEN_OFF = 346, + TOKEN_ON = 347, + TOKEN_ORDER = 348, + TOKEN_OUTER = 349, + TOKEN_OVER = 350, + TOKEN_PARTITION = 351, + TOKEN_PARTITIONS = 352, + TOKEN_PERCENT = 353, + TOKEN_PRECEDING = 354, + TOKEN_PRIMARY = 355, + TOKEN_PRIORITY = 356, + TOKEN_QUIT = 357, + TOKEN_RANGE = 358, + TOKEN_REAL = 359, + TOKEN_REFERENCES = 360, + TOKEN_RIGHT = 361, + TOKEN_ROW = 362, + TOKEN_ROW_DELIMITER = 363, + TOKEN_ROWS = 364, + TOKEN_SECOND = 365, + TOKEN_SELECT = 366, + TOKEN_SET = 367, + TOKEN_SMA = 368, + TOKEN_SMALLINT = 369, + TOKEN_STDERR = 370, + TOKEN_STDOUT = 371, + TOKEN_SUBSTRING = 372, + TOKEN_TABLE = 373, + TOKEN_THEN = 374, + TOKEN_TIME = 375, + TOKEN_TIMESTAMP = 376, + TOKEN_TO = 377, + TOKEN_TRUE = 378, + TOKEN_TUPLESAMPLE = 379, + TOKEN_UNBOUNDED = 380, + TOKEN_UNIQUE = 381, + TOKEN_UPDATE = 382, + TOKEN_USING = 383, + TOKEN_VALUES = 384, + TOKEN_VARCHAR = 385, + TOKEN_WHEN = 386, + TOKEN_WHERE = 387, + TOKEN_WINDOW = 388, + TOKEN_WITH = 389, + TOKEN_YEAR = 390, + TOKEN_YEARMONTH = 391, + TOKEN_EOF = 392, + TOKEN_LEX_ERROR = 393 }; #endif @@ -289,7 +290,7 @@ union YYSTYPE quickstep::ParsePriority *opt_priority_clause_; -#line 293 "SqlParser_gen.hpp" /* yacc.c:1915 */ +#line 294 "SqlParser_gen.hpp" /* yacc.c:1915 */ }; typedef union YYSTYPE YYSTYPE;
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/02005508/query_optimizer/rules/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/query_optimizer/rules/CMakeLists.txt b/query_optimizer/rules/CMakeLists.txt index f578bb8..b7f384c 100644 --- a/query_optimizer/rules/CMakeLists.txt +++ b/query_optimizer/rules/CMakeLists.txt @@ -186,9 +186,9 @@ target_link_libraries(quickstep_queryoptimizer_rules_Partition quickstep_queryoptimizer_physical_TableReference quickstep_queryoptimizer_physical_TopLevelPlan quickstep_queryoptimizer_rules_BottomUpRule + quickstep_types_operations_OperationFactory + quickstep_types_operations_OperationSignature quickstep_types_operations_binaryoperations_BinaryOperation - quickstep_types_operations_binaryoperations_BinaryOperationFactory - quickstep_types_operations_binaryoperations_BinaryOperationID quickstep_utility_Cast quickstep_utility_EqualsAnyConstant quickstep_utility_Macros http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/02005508/query_optimizer/rules/Partition.cpp ---------------------------------------------------------------------- diff --git a/query_optimizer/rules/Partition.cpp b/query_optimizer/rules/Partition.cpp index 5f68cd3..d55d296 100644 --- a/query_optimizer/rules/Partition.cpp +++ b/query_optimizer/rules/Partition.cpp @@ -49,9 +49,8 @@ #include "query_optimizer/physical/Sort.hpp" #include "query_optimizer/physical/TableReference.hpp" #include "query_optimizer/physical/TopLevelPlan.hpp" +#include "types/operations/OperationFactory.hpp" #include "types/operations/binary_operations/BinaryOperation.hpp" -#include "types/operations/binary_operations/BinaryOperationFactory.hpp" -#include "types/operations/binary_operations/BinaryOperationID.hpp" #include "utility/Cast.hpp" #include "utility/EqualsAnyConstant.hpp" @@ -410,10 +409,17 @@ P::PhysicalPtr Partition::applyToNode(const P::PhysicalPtr &node) { for (const auto &avg_recompute_expression : avg_recompute_expressions) { const auto &avg_expr = get<0>(avg_recompute_expression); // Obtain AVG by evaluating SUM/COUNT in Selection. - const BinaryOperation ÷_op = - BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kDivide); + const OperationSignaturePtr op_sig = + OperationSignature::Create( + "+", + { get<1>(avg_recompute_expression)->getValueType().getTypeID(), + get<2>(avg_recompute_expression)->getValueType().getTypeID() }, + 0); + const BinaryOperationPtr divide_op = + OperationFactory::Instance().getBinaryOperation(op_sig); const E::BinaryExpressionPtr new_avg_expr = - E::BinaryExpression::Create(divide_op, + E::BinaryExpression::Create(op_sig, + divide_op, get<1>(avg_recompute_expression), get<2>(avg_recompute_expression)); project_expressions.emplace_back( http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/02005508/types/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/types/CMakeLists.txt b/types/CMakeLists.txt index df4462f..325c6ea 100644 --- a/types/CMakeLists.txt +++ b/types/CMakeLists.txt @@ -47,6 +47,7 @@ add_library(quickstep_types_IntervalLit ../empty_src.cpp IntervalLit.hpp) add_library(quickstep_types_IntervalParser IntervalParser.cpp IntervalParser.hpp) add_library(quickstep_types_LongType LongType.cpp LongType.hpp) add_library(quickstep_types_NullCoercibilityCheckMacro ../empty_src.cpp NullCoercibilityCheckMacro.hpp) +add_library(quickstep_types_NullLit ../empty_src.cpp NullLit.hpp) add_library(quickstep_types_NullType ../empty_src.cpp NullType.hpp) add_library(quickstep_types_NumericSuperType ../empty_src.cpp NumericSuperType.hpp) add_library(quickstep_types_NumericTypeSafeCoercibility ../empty_src.cpp NumericTypeSafeCoercibility.hpp) http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/02005508/types/NullLit.hpp ---------------------------------------------------------------------- diff --git a/types/NullLit.hpp b/types/NullLit.hpp new file mode 100644 index 0000000..8713c72 --- /dev/null +++ b/types/NullLit.hpp @@ -0,0 +1,38 @@ +/** + * 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_TYPES_NULL_LIT_HPP_ +#define QUICKSTEP_TYPES_NULL_LIT_HPP_ + +namespace quickstep { + +/** \addtogroup Types + * @{ + */ + +/** + * @brief An empty struct representing the null value. + **/ +struct NullLit {}; + +/** @} */ + +} // namespace quickstep + +#endif // QUICKSTEP_TYPES_NULL_LIT_HPP_ http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/02005508/types/NullType.hpp ---------------------------------------------------------------------- diff --git a/types/NullType.hpp b/types/NullType.hpp index c416a05..7491ca7 100644 --- a/types/NullType.hpp +++ b/types/NullType.hpp @@ -88,7 +88,7 @@ class NullType : public TypeSynthesizer<kNullType> { // NOTE(chasseur): NullType requires 0 bytes of inherent storage. It does, // however, require a bit in NULL bitmaps. NullType(const bool nullable) - : TypeSynthesizer<kNullType>(nullable, 0, 0) { + : TypeSynthesizer<kNullType>(nullable) { DCHECK(nullable); } http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/02005508/types/TypeFactory.cpp ---------------------------------------------------------------------- diff --git a/types/TypeFactory.cpp b/types/TypeFactory.cpp index 66efc92..223d487 100644 --- a/types/TypeFactory.cpp +++ b/types/TypeFactory.cpp @@ -33,7 +33,7 @@ namespace quickstep { bool TypeFactory::TypeRequiresLengthParameter(const TypeID id) { - return TypeUtil::IsParameterized(id); + return TypeUtil::IsParameterizedPod(id); } const Type& TypeFactory::GetType(const TypeID id, http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/02005508/types/TypeID.hpp ---------------------------------------------------------------------- diff --git a/types/TypeID.hpp b/types/TypeID.hpp index d27368c..ecbdc9b 100644 --- a/types/TypeID.hpp +++ b/types/TypeID.hpp @@ -49,11 +49,11 @@ enum TypeID : int { kNumTypeIDs // Not a real TypeID, exists for counting purposes. }; -enum TypeStorageLayout { - kNativeEmbedded, - kNativeInline, - kNonNativeInline, - kOutOfLine +enum MemoryLayout { + kCxxNativePod, + kParNativePod, + kParIndirectPod, + kGeneric }; /** http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/02005508/types/TypeRegistrar.hpp ---------------------------------------------------------------------- diff --git a/types/TypeRegistrar.hpp b/types/TypeRegistrar.hpp index f4c9fb9..ffe2b7e 100644 --- a/types/TypeRegistrar.hpp +++ b/types/TypeRegistrar.hpp @@ -25,6 +25,7 @@ #include "types/DatetimeLit.hpp" #include "types/IntervalLit.hpp" +#include "types/NullLit.hpp" #include "types/Type.hpp" #include "types/TypeID.hpp" #include "types/TypeIDSelectors.hpp" @@ -41,41 +42,42 @@ namespace quickstep { template <TypeID type_id> struct TypeIDTrait; -#define REGISTER_TYPE(T, type_id, super_type_id, parameterized, layout, CppType) \ - class T; \ +#define REGISTER_TYPE(type_class, type_id, super_type_id, memory_layout, cpp_type) \ + class type_class; \ template <> struct TypeIDTrait<type_id> { \ - typedef T TypeClass; \ - typedef CppType cpptype; \ + typedef type_class TypeClass; \ + typedef cpp_type cpptype; \ static constexpr TypeID kStaticTypeID = type_id; \ static constexpr Type::SuperTypeID kStaticSuperTypeID = super_type_id; \ - static constexpr bool kParameterized = parameterized; \ - static constexpr TypeStorageLayout kLayout = layout; \ + static constexpr MemoryLayout kMemoryLayout = memory_layout; \ + static constexpr bool kIsParameterizedPod = \ + (memory_layout == kParNativePod || memory_layout == kParIndirectPod); \ }; REGISTER_TYPE(BoolType, kBool, \ - Type::kNumeric, false, kNativeEmbedded, bool); + Type::kNumeric, kCxxNativePod, bool); REGISTER_TYPE(IntType, kInt, \ - Type::kNumeric, false, kNativeEmbedded, int); + Type::kNumeric, kCxxNativePod, int); REGISTER_TYPE(LongType, kLong, \ - Type::kNumeric, false, kNativeEmbedded, std::int64_t); + Type::kNumeric, kCxxNativePod, std::int64_t); REGISTER_TYPE(FloatType, kFloat, \ - Type::kNumeric, false, kNativeEmbedded, float); + Type::kNumeric, kCxxNativePod, float); REGISTER_TYPE(DoubleType, kDouble, \ - Type::kNumeric, false, kNativeEmbedded, double); + Type::kNumeric, kCxxNativePod, double); REGISTER_TYPE(DateType, kDate, \ - Type::kOther, false, kNativeEmbedded, DateLit); + Type::kOther, kCxxNativePod, DateLit); REGISTER_TYPE(DatetimeType, kDatetime, \ - Type::kOther, false, kNativeEmbedded, DatetimeLit); + Type::kOther, kCxxNativePod, DatetimeLit); REGISTER_TYPE(DatetimeIntervalType, kDatetimeInterval, \ - Type::kOther, false, kNativeEmbedded, DatetimeIntervalLit); + Type::kOther, kCxxNativePod, DatetimeIntervalLit); REGISTER_TYPE(YearMonthIntervalType, kYearMonthInterval, \ - Type::kOther, false, kNativeEmbedded, YearMonthIntervalLit); + Type::kOther, kCxxNativePod, YearMonthIntervalLit); REGISTER_TYPE(CharType, kChar, \ - Type::kAsciiString, true, kNonNativeInline, void); + Type::kAsciiString, kParNativePod, void); REGISTER_TYPE(VarCharType, kVarChar, \ - Type::kAsciiString, true, kOutOfLine, void); + Type::kAsciiString, kParIndirectPod, void); REGISTER_TYPE(NullType, kNullType, \ - Type::kOther, false, kNonNativeInline, void); + Type::kOther, kCxxNativePod, NullLit); #undef REGISTER_TYPE http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/02005508/types/TypeSynthesizer.hpp ---------------------------------------------------------------------- diff --git a/types/TypeSynthesizer.hpp b/types/TypeSynthesizer.hpp index 27ba02a..16d59c9 100644 --- a/types/TypeSynthesizer.hpp +++ b/types/TypeSynthesizer.hpp @@ -46,15 +46,15 @@ template <TypeID type_id> class TypeSynthesizer : public Type, public TypeInstance<typename TypeIDTrait<type_id>::TypeClass, - TypeIDTrait<type_id>::kParameterized> { + TypeIDTrait<type_id>::kIsParameterizedPod> { public: using Trait = TypeIDTrait<type_id>; using TypeClass = typename Trait::TypeClass; static constexpr Type::SuperTypeID kStaticSuperTypeID = Trait::kStaticSuperTypeID; static constexpr TypeID kStaticTypeID = Trait::kStaticTypeID; - static constexpr bool kParameterized = Trait::kParameterized; - static constexpr TypeStorageLayout kLayout = Trait::kLayout; + static constexpr bool kIsParameterizedPod = Trait::kIsParameterizedPod; + static constexpr MemoryLayout kMemoryLayout = Trait::kMemoryLayout; typedef typename Trait::cpptype cpptype; @@ -64,7 +64,7 @@ class TypeSynthesizer proto.mutable_type_id()->CopyFrom(TypeIDFactory::GetProto(type_id_)); proto.set_nullable(nullable_); - if (kParameterized) { + if (kIsParameterizedPod) { proto.set_length(parameter_); } @@ -72,62 +72,45 @@ class TypeSynthesizer } const Type& getNullableVersion() const override { - return getInstance<kParameterized>(true); + return getInstance<kIsParameterizedPod>(true); } const Type& getNonNullableVersion() const override { - return getInstance<kParameterized>(false); + return getInstance<kIsParameterizedPod>(false); } protected: - template <TypeStorageLayout layout = kLayout, bool parameterized = kParameterized> + template <MemoryLayout layout = kMemoryLayout, bool par = kIsParameterizedPod> explicit TypeSynthesizer(const bool nullable, - std::enable_if_t<layout == kNativeEmbedded || - layout == kNativeInline>* = 0) + std::enable_if_t<layout == kCxxNativePod>* = 0) : Type(kStaticSuperTypeID, kStaticTypeID, nullable, sizeof(cpptype), sizeof(cpptype)) { - DCHECK(!kParameterized); } - template <TypeStorageLayout layout = kLayout, bool parameterized = kParameterized> + template <MemoryLayout layout = kMemoryLayout, bool par = kIsParameterizedPod> TypeSynthesizer(const bool nullable, const std::size_t minimum_byte_length, const std::size_t maximum_byte_length, const std::size_t parameter, - std::enable_if_t<parameterized && - (layout == kNonNativeInline || - layout == kOutOfLine)>* = 0) + std::enable_if_t<par>* = 0) : Type(kStaticSuperTypeID, kStaticTypeID, nullable, minimum_byte_length, maximum_byte_length, parameter) { - DCHECK(kLayout != kNonNativeInline || minimum_byte_length == maximum_byte_length); - } - - template <TypeStorageLayout layout = kLayout, bool parameterized = kParameterized> - TypeSynthesizer(const bool nullable, - const std::size_t minimum_byte_length, - const std::size_t maximum_byte_length, - std::enable_if_t<!parameterized && - (layout == kNonNativeInline || - layout == kOutOfLine)>* = 0) - : Type(kStaticSuperTypeID, kStaticTypeID, nullable, - minimum_byte_length, maximum_byte_length) { - DCHECK(kLayout != kNonNativeInline || minimum_byte_length == maximum_byte_length); } private: template <bool has_param> inline const Type& getInstance(const bool nullable, std::enable_if_t<has_param>* = 0) const { - return TypeInstance<TypeClass, kParameterized>::Instance(parameter_, nullable); + return TypeInstance<TypeClass, kIsParameterizedPod>::Instance(parameter_, nullable); } template <bool has_param> inline const Type& getInstance(const bool nullable, std::enable_if_t<!has_param>* = 0) const { - return TypeInstance<TypeClass, kParameterized>::Instance(nullable); + return TypeInstance<TypeClass, kIsParameterizedPod>::Instance(nullable); } - friend class TypeInstance<TypeClass, kParameterized>; + friend class TypeInstance<TypeClass, kIsParameterizedPod>; DISALLOW_COPY_AND_ASSIGN(TypeSynthesizer); }; @@ -139,10 +122,10 @@ template <TypeID type_id> constexpr TypeID TypeSynthesizer<type_id>::kStaticTypeID; template <TypeID type_id> -constexpr bool TypeSynthesizer<type_id>::kParameterized; +constexpr bool TypeSynthesizer<type_id>::kIsParameterizedPod; template <TypeID type_id> -constexpr TypeStorageLayout TypeSynthesizer<type_id>::kLayout; +constexpr MemoryLayout TypeSynthesizer<type_id>::kMemoryLayout; template <typename TypeClass> http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/02005508/types/TypeUtil.hpp ---------------------------------------------------------------------- diff --git a/types/TypeUtil.hpp b/types/TypeUtil.hpp index b146f02..5a55280 100644 --- a/types/TypeUtil.hpp +++ b/types/TypeUtil.hpp @@ -49,11 +49,11 @@ namespace quickstep { class TypeUtil { public: - static bool IsParameterized(const TypeID type_id) { + static bool IsParameterizedPod(const TypeID type_id) { return InvokeOnTypeID( type_id, [&](auto tid) -> bool { // NOLINT(build/c++11) - return TypeIDTrait<decltype(tid)::value>::kParameterized; + return TypeIDTrait<decltype(tid)::value>::kIsParameterizedPod; }); } http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/02005508/types/containers/ColumnVector.hpp ---------------------------------------------------------------------- diff --git a/types/containers/ColumnVector.hpp b/types/containers/ColumnVector.hpp index 0d6447d..a312ee2 100644 --- a/types/containers/ColumnVector.hpp +++ b/types/containers/ColumnVector.hpp @@ -70,13 +70,25 @@ typedef std::shared_ptr<const ColumnVector> ColumnVectorPtr; **/ class ColumnVector { public: + /** + * @brief Enum with cases for different subclasses of ColumnVector. + */ + enum Implementation { + kNative = 0, + kIndirect, + kGeneric + }; + /** * @brief Constructor. * * @param type The Type of values to hold. **/ - explicit ColumnVector(const Type &type) - : type_(type) { + explicit ColumnVector(const Implementation implementation, + const Type &type) + : implementation_(implementation), + type_(type) { + // TODO: check that impl matches type. } /** @@ -101,14 +113,27 @@ class ColumnVector { const TypedValue &value, const std::size_t num_copies); + /** - * @brief Check whether this ColumnVector is a NativeColumnVector or an - * IndirectColumnVector. + * @brief Determine the concrete type of this ColumnVector. * - * @return true if this is a NativeColumnVector, false if this is an - * IndirectColumnVector. + * @return The implementation type of this ColumnVector. **/ - virtual bool isNative() const = 0; + inline Implementation getImplementation() const { + return implementation_; + } + + inline bool isNative() const { + return implementation_ == kNative; + } + + inline bool isIndrect() const { + return implementation_ == kIndirect; + } + + inline bool isGeneric() const { + return implementation_ == kGeneric; + } /** * @brief Get the number of values in this ColumnVector. @@ -118,6 +143,7 @@ class ColumnVector { virtual std::size_t size() const = 0; protected: + const Implementation implementation_; const Type &type_; private: @@ -140,7 +166,7 @@ class NativeColumnVector : public ColumnVector { * NativeColumnVector will hold. **/ NativeColumnVector(const Type &type, const std::size_t reserved_length) - : ColumnVector(type), + : ColumnVector(ColumnVector::kNative, type), type_length_(type.maximumByteLength()), reserved_length_(reserved_length), values_(std::malloc(type.maximumByteLength() * reserved_length)), @@ -170,10 +196,6 @@ class NativeColumnVector : public ColumnVector { return !type.isVariableLength(); } - bool isNative() const override { - return true; - } - /** * @brief Determine if this NativeColumnVector's Type is nullable. * @@ -421,7 +443,7 @@ class IndirectColumnVector : public ColumnVector { * @param reserved_length The number of values to reserve space for. **/ IndirectColumnVector(const Type &type, const std::size_t reserved_length) - : ColumnVector(type), + : ColumnVector(ColumnVector::kIndirect, type), type_is_nullable_(type.isNullable()), reserved_length_(reserved_length) { values_.reserve(reserved_length); @@ -433,10 +455,6 @@ class IndirectColumnVector : public ColumnVector { ~IndirectColumnVector() override { } - bool isNative() const override { - return false; - } - /** * @brief Determine if this IndirectColumnVector's Type is nullable. * @@ -590,6 +608,11 @@ class IndirectColumnVector : public ColumnVector { DISALLOW_COPY_AND_ASSIGN(IndirectColumnVector); }; +class GenericColumnVector { + + +}; + /** @} */ } // namespace quickstep http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/02005508/types/containers/ColumnVectorsValueAccessor.hpp ---------------------------------------------------------------------- diff --git a/types/containers/ColumnVectorsValueAccessor.hpp b/types/containers/ColumnVectorsValueAccessor.hpp index ebd46d4..0ea6d50 100644 --- a/types/containers/ColumnVectorsValueAccessor.hpp +++ b/types/containers/ColumnVectorsValueAccessor.hpp @@ -73,10 +73,11 @@ class ColumnVectorsValueAccessor : public ValueAccessor { * this value-accessor is responsible for freeing this column * vector. **/ - void addColumn(ColumnVectorPtr column) { + void addColumn(const ColumnVectorPtr &column) { // If this is not the first column to be added, make sure it is the same // length as the others. DCHECK(columns_.empty() || column->size() == column_length_); + DCHECK(column->isNative() || column->isIndrect()); columns_.push_back(column); column_native_.push_back(column->isNative()); column_length_ = column->size(); http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/02005508/types/operations/OperationUtil.hpp ---------------------------------------------------------------------- diff --git a/types/operations/OperationUtil.hpp b/types/operations/OperationUtil.hpp index 076dc0c..8290061 100644 --- a/types/operations/OperationUtil.hpp +++ b/types/operations/OperationUtil.hpp @@ -103,7 +103,7 @@ template <typename FuncSpec, typename T, typename EnableT = void> struct Codegen; template <typename FuncSpec, typename T> -struct Codegen<FuncSpec, T, std::enable_if_t<T::kLayout == kNativeEmbedded>> { +struct Codegen<FuncSpec, T, std::enable_if_t<T::kMemoryLayout == kCxxNativePod>> { using ColumnVectorType = NativeColumnVector; using FunctorSpecializer = FuncSpec; @@ -171,7 +171,7 @@ struct Codegen<FuncSpec, T, std::enable_if_t<T::kLayout == kNativeEmbedded>> { }; template <typename FuncSpec, typename T> -struct Codegen<FuncSpec, T, std::enable_if_t<T::kLayout == kNonNativeInline>> { +struct Codegen<FuncSpec, T, std::enable_if_t<T::kMemoryLayout == kParNativePod>> { using ColumnVectorType = NativeColumnVector; using FunctorSpecializer = FuncSpec; @@ -244,7 +244,7 @@ struct Codegen<FuncSpec, T, std::enable_if_t<T::kLayout == kNonNativeInline>> { }; template <typename FuncSpec, typename T> -struct Codegen<FuncSpec, T, std::enable_if_t<T::kLayout == kOutOfLine>> { +struct Codegen<FuncSpec, T, std::enable_if_t<T::kMemoryLayout == kParIndirectPod>> { using ColumnVectorType = IndirectColumnVector; using FunctorSpecializer = FuncSpec; http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/02005508/types/operations/binary_operations/BinaryOperationWrapper.hpp ---------------------------------------------------------------------- diff --git a/types/operations/binary_operations/BinaryOperationWrapper.hpp b/types/operations/binary_operations/BinaryOperationWrapper.hpp index 98c2e8d..d819000 100644 --- a/types/operations/binary_operations/BinaryOperationWrapper.hpp +++ b/types/operations/binary_operations/BinaryOperationWrapper.hpp @@ -195,7 +195,7 @@ class UncheckedBinaryOperatorWrapperCodegen : public UncheckedBinaryOperator { std::size_t *num_tuples_applied) const override { constexpr bool is_supported = LeftType::kStaticTypeID == ResultType::kStaticTypeID && - (LeftType::kLayout == kNativeEmbedded || LeftType::kLayout == kNativeInline) && + LeftType::kMemoryLayout == kCxxNativePod && std::is_copy_assignable<typename LeftType::cpptype>::value; using RightCVT = typename RightGen::ColumnVectorType; @@ -217,7 +217,7 @@ class UncheckedBinaryOperatorWrapperCodegen : public UncheckedBinaryOperator { std::size_t *num_tuples_applied) const override { constexpr bool is_supported = LeftType::kStaticTypeID == ResultType::kStaticTypeID && - (LeftType::kLayout == kNativeEmbedded || LeftType::kLayout == kNativeInline) && + LeftType::kMemoryLayout == kCxxNativePod && std::is_copy_assignable<typename LeftType::cpptype>::value; return InvokeOnValueAccessorMaybeTupleIdSequenceAdapter( @@ -511,7 +511,7 @@ class BinaryOperationWrapper : public BinaryOperation { DCHECK(left.getTypeID() == LeftType::kStaticTypeID); DCHECK(right.getTypeID() == RightType::kStaticTypeID); DCHECK(static_arguments.empty()); - return getResultTypeImpl<ResultType::kParameterized>( + return getResultTypeImpl<ResultType::kIsParameterizedPod>( left, right, static_arguments); } http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/02005508/types/operations/unary_operations/UnaryOperationWrapper.hpp ---------------------------------------------------------------------- diff --git a/types/operations/unary_operations/UnaryOperationWrapper.hpp b/types/operations/unary_operations/UnaryOperationWrapper.hpp index 59b2cf0..09e7b05 100644 --- a/types/operations/unary_operations/UnaryOperationWrapper.hpp +++ b/types/operations/unary_operations/UnaryOperationWrapper.hpp @@ -184,7 +184,7 @@ class UnaryOperationWrapper : public UnaryOperation { const std::vector<TypedValue> &static_arguments) const override { DCHECK(argument_type.getTypeID() == ArgumentType::kStaticTypeID); DCHECK(static_arguments.empty()); - return getResultTypeImpl<ResultType::kParameterized>( + return getResultTypeImpl<ResultType::kIsParameterizedPodz>( argument_type, static_arguments); }
