From a74fdf184caa8a155519210df50835e7f031b637 Mon Sep 17 00:00:00 2001 From: Pxl <952130278@qq.com> Date: Wed, 24 Nov 2021 10:39:29 +0800 Subject: [PATCH] [refactor](be) refactor predicate function creator (#7054) Refactor predicate function creator, make MinMaxFunction/HybridSet/BloomFilter use a unified interface through template to get function. --- be/src/exprs/CMakeLists.txt | 1 - be/src/exprs/bloomfilter_predicate.cpp | 44 ----- be/src/exprs/bloomfilter_predicate.h | 2 - be/src/exprs/create_predicate_function.h | 124 ++++++++++++++ be/src/exprs/hybrid_map.h | 3 +- be/src/exprs/hybrid_set.cpp | 68 -------- be/src/exprs/hybrid_set.h | 2 - be/src/exprs/in_predicate.cpp | 3 +- be/src/exprs/in_predicate.h | 1 + be/src/exprs/minmax_predicate.h | 116 +++++++++++++ be/src/exprs/runtime_filter.cpp | 153 +----------------- be/src/olap/bloom_filter_predicate.cpp | 18 +-- be/test/exprs/bloom_filter_predicate_test.cpp | 9 +- be/test/exprs/hybrid_set_test.cpp | 19 +-- .../bloom_filter_column_predicate_test.cpp | 3 +- 15 files changed, 278 insertions(+), 288 deletions(-) create mode 100644 be/src/exprs/create_predicate_function.h delete mode 100644 be/src/exprs/hybrid_set.cpp create mode 100644 be/src/exprs/minmax_predicate.h diff --git a/be/src/exprs/CMakeLists.txt b/be/src/exprs/CMakeLists.txt index 421cfc2cfc..99ebbf401f 100644 --- a/be/src/exprs/CMakeLists.txt +++ b/be/src/exprs/CMakeLists.txt @@ -62,7 +62,6 @@ add_library(Exprs udf_builtins.cpp utility_functions.cpp info_func.cpp - hybrid_set.cpp json_functions.cpp operators.cpp hll_hash_function.cpp diff --git a/be/src/exprs/bloomfilter_predicate.cpp b/be/src/exprs/bloomfilter_predicate.cpp index 5d52d855d8..1ce5acd1f5 100644 --- a/be/src/exprs/bloomfilter_predicate.cpp +++ b/be/src/exprs/bloomfilter_predicate.cpp @@ -27,50 +27,6 @@ namespace doris { -IBloomFilterFuncBase* IBloomFilterFuncBase::create_bloom_filter(MemTracker* tracker, - PrimitiveType type) { - switch (type) { - case TYPE_BOOLEAN: - return new BloomFilterFunc(tracker); - case TYPE_TINYINT: - return new BloomFilterFunc(tracker); - case TYPE_SMALLINT: - return new BloomFilterFunc(tracker); - case TYPE_INT: - return new BloomFilterFunc(tracker); - case TYPE_BIGINT: - return new BloomFilterFunc(tracker); - case TYPE_LARGEINT: - return new BloomFilterFunc(tracker); - - case TYPE_FLOAT: - return new BloomFilterFunc(tracker); - case TYPE_DOUBLE: - return new BloomFilterFunc(tracker); - - case TYPE_DECIMALV2: - return new BloomFilterFunc(tracker); - - case TYPE_TIME: - return new BloomFilterFunc(tracker); - case TYPE_DATE: - return new BloomFilterFunc(tracker); - case TYPE_DATETIME: - return new BloomFilterFunc(tracker); - - case TYPE_CHAR: - return new BloomFilterFunc(tracker); - case TYPE_VARCHAR: - return new BloomFilterFunc(tracker); - case TYPE_STRING: - return new BloomFilterFunc(tracker); - - default: - DCHECK(false) << "Invalid type."; - } - - return nullptr; -} BloomFilterPredicate::BloomFilterPredicate(const TExprNode& node) : Predicate(node), _is_prepare(false), diff --git a/be/src/exprs/bloomfilter_predicate.h b/be/src/exprs/bloomfilter_predicate.h index ff1bbc8713..e90f02d4f1 100644 --- a/be/src/exprs/bloomfilter_predicate.h +++ b/be/src/exprs/bloomfilter_predicate.h @@ -90,8 +90,6 @@ public: virtual Status get_data(char** data, int* len) = 0; virtual MemTracker* tracker() = 0; virtual void light_copy(IBloomFilterFuncBase* other) = 0; - - static IBloomFilterFuncBase* create_bloom_filter(MemTracker* tracker, PrimitiveType type); }; template diff --git a/be/src/exprs/create_predicate_function.h b/be/src/exprs/create_predicate_function.h new file mode 100644 index 0000000000..27aef88c92 --- /dev/null +++ b/be/src/exprs/create_predicate_function.h @@ -0,0 +1,124 @@ +// 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. + +#pragma once + +#include "exprs/bloomfilter_predicate.h" +#include "exprs/hybrid_set.h" +#include "exprs/minmax_predicate.h" +#include "runtime/mem_tracker.h" + +namespace doris { + +class MinmaxFunctionTraits { +public: + using BasePtr = MinMaxFuncBase*; + template + static BasePtr get_function([[maybe_unused]] MemTracker* tracker) { + return new (std::nothrow) MinMaxNumFunc::CppType>(); + }; +}; + +class HybridSetTraits { +public: + using BasePtr = HybridSetBase*; + template + static BasePtr get_function([[maybe_unused]] MemTracker* tracker) { + using CppType = typename PrimitiveTypeTraits::CppType; + using Set = std::conditional_t, StringValueSet, + HybridSet>; + return new (std::nothrow) Set(); + }; +}; + +class BloomFilterTraits { +public: + using BasePtr = IBloomFilterFuncBase*; + template + static BasePtr get_function(MemTracker* tracker) { + return new BloomFilterFunc(tracker); + }; +}; + +template +class PredicateFunctionCreator { +public: + template + static typename Traits::BasePtr create(MemTracker* tracker = nullptr) { + return Traits::template get_function(tracker); + } +}; + +template +typename Traits::BasePtr create_predicate_function(PrimitiveType type, + MemTracker* tracker = nullptr) { + using Creator = PredicateFunctionCreator; + + switch (type) { + case TYPE_BOOLEAN: + return Creator::template create(tracker); + case TYPE_TINYINT: + return Creator::template create(tracker); + case TYPE_SMALLINT: + return Creator::template create(tracker); + case TYPE_INT: + return Creator::template create(tracker); + case TYPE_BIGINT: + return Creator::template create(tracker); + case TYPE_LARGEINT: + return Creator::template create(tracker); + + case TYPE_FLOAT: + return Creator::template create(tracker); + case TYPE_DOUBLE: + return Creator::template create(tracker); + + case TYPE_DECIMALV2: + return Creator::template create(tracker); + + case TYPE_DATE: + return Creator::template create(tracker); + case TYPE_DATETIME: + return Creator::template create(tracker); + + case TYPE_CHAR: + return Creator::template create(tracker); + case TYPE_VARCHAR: + return Creator::template create(tracker); + case TYPE_STRING: + return Creator::template create(tracker); + + default: + DCHECK(false) << "Invalid type."; + } + + return nullptr; +} + +inline auto create_minmax_filter(PrimitiveType type) { + return create_predicate_function(type); +} + +inline auto create_set(PrimitiveType type) { + return create_predicate_function(type); +} + +inline auto create_bloom_filter(MemTracker* tracker, PrimitiveType type) { + return create_predicate_function(type, tracker); +} + +} // namespace doris \ No newline at end of file diff --git a/be/src/exprs/hybrid_map.h b/be/src/exprs/hybrid_map.h index 0e0d1396e5..7eadf002bd 100644 --- a/be/src/exprs/hybrid_map.h +++ b/be/src/exprs/hybrid_map.h @@ -22,6 +22,7 @@ #include "common/object_pool.h" #include "common/status.h" +#include "exprs/create_predicate_function.h" #include "exprs/hybrid_set.h" #include "runtime/datetime_value.h" #include "runtime/primitive_type.h" @@ -40,7 +41,7 @@ public: typename std::unordered_map::const_iterator it = _map.find(dst); if (it == _map.end()) { - _set_ptr = _pool.add(HybridSetBase::create_set(_type)); + _set_ptr = _pool.add(create_set(_type)); std::pair insert_pair(dst, _set_ptr); _map.insert(insert_pair); *is_add_buckets = true; diff --git a/be/src/exprs/hybrid_set.cpp b/be/src/exprs/hybrid_set.cpp deleted file mode 100644 index 1b3fd377b4..0000000000 --- a/be/src/exprs/hybrid_set.cpp +++ /dev/null @@ -1,68 +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 "exprs/hybrid_set.h" - -namespace doris { - -HybridSetBase* HybridSetBase::create_set(PrimitiveType type) { - switch (type) { - case TYPE_BOOLEAN: - return new (std::nothrow) HybridSet(); - - case TYPE_TINYINT: - return new (std::nothrow) HybridSet(); - - case TYPE_SMALLINT: - return new (std::nothrow) HybridSet(); - - case TYPE_INT: - return new (std::nothrow) HybridSet(); - - case TYPE_BIGINT: - return new (std::nothrow) HybridSet(); - - case TYPE_LARGEINT: - return new (std::nothrow) HybridSet<__int128>(); - - case TYPE_FLOAT: - return new (std::nothrow) HybridSet(); - - case TYPE_TIME: - case TYPE_DOUBLE: - return new (std::nothrow) HybridSet(); - - case TYPE_DECIMALV2: - return new (std::nothrow) HybridSet(); - - case TYPE_DATE: - case TYPE_DATETIME: - return new (std::nothrow) HybridSet(); - - case TYPE_CHAR: - case TYPE_VARCHAR: - case TYPE_STRING: - return new (std::nothrow) StringValueSet(); - - default: - DCHECK(false) << "Invalid type."; - } - - return nullptr; -} - -} // namespace doris diff --git a/be/src/exprs/hybrid_set.h b/be/src/exprs/hybrid_set.h index 6947f09a58..fef7146fdd 100644 --- a/be/src/exprs/hybrid_set.h +++ b/be/src/exprs/hybrid_set.h @@ -45,8 +45,6 @@ public: virtual bool find(void* data) = 0; // use in vectorize execute engine virtual bool find(void* data, size_t) = 0; - - static HybridSetBase* create_set(PrimitiveType type); class IteratorBase { public: IteratorBase() {} diff --git a/be/src/exprs/in_predicate.cpp b/be/src/exprs/in_predicate.cpp index 53143d7d46..0dd32df1f1 100644 --- a/be/src/exprs/in_predicate.cpp +++ b/be/src/exprs/in_predicate.cpp @@ -85,7 +85,8 @@ Status InPredicate::prepare(RuntimeState* state, const RowDescriptor& row_desc, if (_children.size() < 1) { return Status::InternalError("no Function operator in."); } - _hybrid_set.reset(HybridSetBase::create_set(_children[0]->type().type)); + + _hybrid_set.reset(create_set(_children[0]->type().type)); if (nullptr == _hybrid_set.get()) { return Status::InternalError("Unknown column type."); } diff --git a/be/src/exprs/in_predicate.h b/be/src/exprs/in_predicate.h index 35a8f0b553..d7d21e2662 100644 --- a/be/src/exprs/in_predicate.h +++ b/be/src/exprs/in_predicate.h @@ -21,6 +21,7 @@ #include #include +#include "exprs/create_predicate_function.h" #include "exprs/hybrid_set.h" #include "exprs/predicate.h" #include "runtime/raw_value.h" diff --git a/be/src/exprs/minmax_predicate.h b/be/src/exprs/minmax_predicate.h new file mode 100644 index 0000000000..eda8b78614 --- /dev/null +++ b/be/src/exprs/minmax_predicate.h @@ -0,0 +1,116 @@ +// 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. + +#pragma once + +#include "common/object_pool.h" +#include "runtime/primitive_type.h" +#include "runtime/type_limit.h" + +namespace doris { +// only used in Runtime Filter +class MinMaxFuncBase { +public: + virtual void insert(const void* data) = 0; + virtual bool find(void* data) = 0; + virtual bool is_empty() = 0; + virtual void* get_max() = 0; + virtual void* get_min() = 0; + // assign minmax data + virtual Status assign(void* min_data, void* max_data) = 0; + // merge from other minmax_func + virtual Status merge(MinMaxFuncBase* minmax_func, ObjectPool* pool) = 0; +}; + +template +class MinMaxNumFunc : public MinMaxFuncBase { +public: + MinMaxNumFunc() = default; + ~MinMaxNumFunc() = default; + virtual void insert(const void* data) { + if (data == nullptr) return; + const T val_data = *reinterpret_cast(data); + if (_empty) { + _min = val_data; + _max = val_data; + _empty = false; + return; + } + if (val_data < _min) { + _min = val_data; + } else if (val_data > _max) { + _max = val_data; + } + } + + virtual bool find(void* data) { + if (data == nullptr) { + return false; + } + T val_data = *reinterpret_cast(data); + return val_data >= _min && val_data <= _max; + } + + Status merge(MinMaxFuncBase* minmax_func, ObjectPool* pool) { + if constexpr (std::is_same_v) { + MinMaxNumFunc* other_minmax = static_cast*>(minmax_func); + + if (other_minmax->_min < _min) { + auto& other_min = other_minmax->_min; + auto str = pool->add(new std::string(other_min.ptr, other_min.len)); + _min.ptr = str->data(); + _min.len = str->length(); + } + if (other_minmax->_max > _max) { + auto& other_max = other_minmax->_max; + auto str = pool->add(new std::string(other_max.ptr, other_max.len)); + _max.ptr = str->data(); + _max.len = str->length(); + } + } else { + MinMaxNumFunc* other_minmax = static_cast*>(minmax_func); + if (other_minmax->_min < _min) { + _min = other_minmax->_min; + } + if (other_minmax->_max > _max) { + _max = other_minmax->_max; + } + } + + return Status::OK(); + } + + virtual bool is_empty() { return _empty; } + + virtual void* get_max() { return &_max; } + + virtual void* get_min() { return &_min; } + + virtual Status assign(void* min_data, void* max_data) { + _min = *(T*)min_data; + _max = *(T*)max_data; + return Status::OK(); + } + +private: + T _max = type_limit::min(); + T _min = type_limit::max(); + // we use _empty to avoid compare twice + bool _empty = true; +}; + +} \ No newline at end of file diff --git a/be/src/exprs/runtime_filter.cpp b/be/src/exprs/runtime_filter.cpp index 407e50b70e..29830f2ddf 100644 --- a/be/src/exprs/runtime_filter.cpp +++ b/be/src/exprs/runtime_filter.cpp @@ -24,11 +24,13 @@ #include "exec/hash_join_node.h" #include "exprs/binary_predicate.h" #include "exprs/bloomfilter_predicate.h" +#include "exprs/create_predicate_function.h" #include "exprs/expr.h" #include "exprs/expr_context.h" #include "exprs/hybrid_set.h" #include "exprs/in_predicate.h" #include "exprs/literal.h" +#include "exprs/minmax_predicate.h" #include "exprs/predicate.h" #include "gen_cpp/internal_service.pb.h" #include "gen_cpp/types.pb.h" @@ -40,145 +42,6 @@ #include "util/string_parser.hpp" namespace doris { -// only used in Runtime Filter -class MinMaxFuncBase { -public: - virtual void insert(const void* data) = 0; - virtual bool find(void* data) = 0; - virtual bool is_empty() = 0; - virtual void* get_max() = 0; - virtual void* get_min() = 0; - // assign minmax data - virtual Status assign(void* min_data, void* max_data) = 0; - // merge from other minmax_func - virtual Status merge(MinMaxFuncBase* minmax_func, ObjectPool* pool) = 0; - // create min-max filter function - static MinMaxFuncBase* create_minmax_filter(PrimitiveType type); -}; - -template -class MinMaxNumFunc : public MinMaxFuncBase { -public: - MinMaxNumFunc() = default; - ~MinMaxNumFunc() = default; - virtual void insert(const void* data) { - if (data == nullptr) return; - const T val_data = *reinterpret_cast(data); - if (_empty) { - _min = val_data; - _max = val_data; - _empty = false; - return; - } - if (val_data < _min) { - _min = val_data; - } else if (val_data > _max) { - _max = val_data; - } - } - - virtual bool find(void* data) { - if (data == nullptr) { - return false; - } - T val_data = *reinterpret_cast(data); - return val_data >= _min && val_data <= _max; - } - - Status merge(MinMaxFuncBase* minmax_func, ObjectPool* pool) { - if constexpr (std::is_same_v) { - MinMaxNumFunc* other_minmax = static_cast*>(minmax_func); - - if (other_minmax->_min < _min) { - auto& other_min = other_minmax->_min; - auto str = pool->add(new std::string(other_min.ptr, other_min.len)); - _min.ptr = str->data(); - _min.len = str->length(); - } - if (other_minmax->_max > _max) { - auto& other_max = other_minmax->_max; - auto str = pool->add(new std::string(other_max.ptr, other_max.len)); - _max.ptr = str->data(); - _max.len = str->length(); - } - } else { - MinMaxNumFunc* other_minmax = static_cast*>(minmax_func); - if (other_minmax->_min < _min) { - _min = other_minmax->_min; - } - if (other_minmax->_max > _max) { - _max = other_minmax->_max; - } - } - - return Status::OK(); - } - - virtual bool is_empty() { return _empty; } - - virtual void* get_max() { return &_max; } - - virtual void* get_min() { return &_min; } - - virtual Status assign(void* min_data, void* max_data) { - _min = *(T*)min_data; - _max = *(T*)max_data; - return Status::OK(); - } - -private: - T _max = type_limit::min(); - T _min = type_limit::max(); - // we use _empty to avoid compare twice - bool _empty = true; -}; - -MinMaxFuncBase* MinMaxFuncBase::create_minmax_filter(PrimitiveType type) { - switch (type) { - case TYPE_BOOLEAN: - return new (std::nothrow) MinMaxNumFunc(); - - case TYPE_TINYINT: - return new (std::nothrow) MinMaxNumFunc(); - - case TYPE_SMALLINT: - return new (std::nothrow) MinMaxNumFunc(); - - case TYPE_INT: - return new (std::nothrow) MinMaxNumFunc(); - - case TYPE_BIGINT: - return new (std::nothrow) MinMaxNumFunc(); - - case TYPE_LARGEINT: - return new (std::nothrow) MinMaxNumFunc<__int128>(); - - case TYPE_FLOAT: - return new (std::nothrow) MinMaxNumFunc(); - - case TYPE_TIME: - case TYPE_DOUBLE: - return new (std::nothrow) MinMaxNumFunc(); - - case TYPE_DECIMALV2: - return new (std::nothrow) MinMaxNumFunc(); - - case TYPE_DATE: - case TYPE_DATETIME: - return new (std::nothrow) MinMaxNumFunc(); - - case TYPE_CHAR: - case TYPE_VARCHAR: - case TYPE_STRING: - return new (std::nothrow) MinMaxNumFunc(); - - default: - DCHECK(false) << "Invalid type."; - } - - return nullptr; -} - // PrimitiveType->TExprNodeType // TODO: use constexpr if we use c++14 TExprNodeType::type get_expr_node_type(PrimitiveType type) { @@ -463,16 +326,15 @@ public: Status init(const RuntimeFilterParams* params) { switch (_filter_type) { case RuntimeFilterType::IN_FILTER: { - _hybrid_set.reset(HybridSetBase::create_set(_column_return_type)); + _hybrid_set.reset(create_set(_column_return_type)); break; } case RuntimeFilterType::MINMAX_FILTER: { - _minmax_func.reset(MinMaxFuncBase::create_minmax_filter(_column_return_type)); + _minmax_func.reset(create_minmax_filter(_column_return_type)); break; } case RuntimeFilterType::BLOOM_FILTER: { - _bloomfilter_func.reset( - IBloomFilterFuncBase::create_bloom_filter(_tracker, _column_return_type)); + _bloomfilter_func.reset(create_bloom_filter(_tracker, _column_return_type)); return _bloomfilter_func->init_with_fixed_length(params->bloom_filter_size); } default: @@ -594,8 +456,7 @@ public: DCHECK(_tracker != nullptr); // we won't use this class to insert or find any data // so any type is ok - _bloomfilter_func.reset( - IBloomFilterFuncBase::create_bloom_filter(_tracker, PrimitiveType::TYPE_INT)); + _bloomfilter_func.reset(create_bloom_filter(_tracker, PrimitiveType::TYPE_INT)); return _bloomfilter_func->assign(data, bloom_filter->filter_length()); } @@ -604,7 +465,7 @@ public: Status assign(const PMinMaxFilter* minmax_filter) { DCHECK(_tracker != nullptr); PrimitiveType type = to_primitive_type(minmax_filter->column_type()); - _minmax_func.reset(MinMaxFuncBase::create_minmax_filter(type)); + _minmax_func.reset(create_minmax_filter(type)); switch (type) { case TYPE_BOOLEAN: { bool min_val; diff --git a/be/src/olap/bloom_filter_predicate.cpp b/be/src/olap/bloom_filter_predicate.cpp index fca5a7e671..4812735718 100644 --- a/be/src/olap/bloom_filter_predicate.cpp +++ b/be/src/olap/bloom_filter_predicate.cpp @@ -17,6 +17,8 @@ #include "olap/bloom_filter_predicate.h" +#include "exprs/create_predicate_function.h" + #define APPLY_FOR_PRIMTYPE(M) \ M(TYPE_TINYINT) \ M(TYPE_SMALLINT) \ @@ -37,23 +39,21 @@ ColumnPredicate* BloomFilterColumnPredicateFactory::create_column_predicate( FieldType type) { std::shared_ptr filter; switch (type) { -#define M(NAME) \ - case OLAP_FIELD_##NAME: { \ - filter.reset(IBloomFilterFuncBase::create_bloom_filter(bloom_filter->tracker(), NAME)); \ - filter->light_copy(bloom_filter.get()); \ - return new BloomFilterColumnPredicate(column_id, filter); \ +#define M(NAME) \ + case OLAP_FIELD_##NAME: { \ + filter.reset(create_bloom_filter(bloom_filter->tracker(), NAME)); \ + filter->light_copy(bloom_filter.get()); \ + return new BloomFilterColumnPredicate(column_id, filter); \ } APPLY_FOR_PRIMTYPE(M) #undef M case OLAP_FIELD_TYPE_DECIMAL: { - filter.reset( - IBloomFilterFuncBase::create_bloom_filter(bloom_filter->tracker(), TYPE_DECIMALV2)); + filter.reset(create_bloom_filter(bloom_filter->tracker(), TYPE_DECIMALV2)); filter->light_copy(bloom_filter.get()); return new BloomFilterColumnPredicate(column_id, filter); } case OLAP_FIELD_TYPE_BOOL: { - filter.reset( - IBloomFilterFuncBase::create_bloom_filter(bloom_filter->tracker(), TYPE_BOOLEAN)); + filter.reset(create_bloom_filter(bloom_filter->tracker(), TYPE_BOOLEAN)); filter->light_copy(bloom_filter.get()); return new BloomFilterColumnPredicate(column_id, filter); } diff --git a/be/test/exprs/bloom_filter_predicate_test.cpp b/be/test/exprs/bloom_filter_predicate_test.cpp index 855807986b..ca6e5a9f0d 100644 --- a/be/test/exprs/bloom_filter_predicate_test.cpp +++ b/be/test/exprs/bloom_filter_predicate_test.cpp @@ -18,6 +18,7 @@ #include #include "exprs/bloomfilter_predicate.h" +#include "exprs/create_predicate_function.h" #include "gtest/gtest.h" #include "runtime/string_value.h" @@ -32,7 +33,7 @@ public: TEST_F(BloomFilterPredicateTest, bloom_filter_func_int_test) { auto tracker = MemTracker::CreateTracker(); std::unique_ptr func( - IBloomFilterFuncBase::create_bloom_filter(tracker.get(), PrimitiveType::TYPE_INT)); + create_bloom_filter(tracker.get(), PrimitiveType::TYPE_INT)); ASSERT_TRUE(func->init(1024, 0.05).ok()); const int data_size = 1024; int data[data_size]; @@ -54,7 +55,7 @@ TEST_F(BloomFilterPredicateTest, bloom_filter_func_int_test) { TEST_F(BloomFilterPredicateTest, bloom_filter_func_stringval_test) { auto tracker = MemTracker::CreateTracker(); std::unique_ptr func( - IBloomFilterFuncBase::create_bloom_filter(tracker.get(), PrimitiveType::TYPE_VARCHAR)); + create_bloom_filter(tracker.get(), PrimitiveType::TYPE_VARCHAR)); ASSERT_TRUE(func->init(1024, 0.05).ok()); ObjectPool obj_pool; const int data_size = 1024; @@ -73,7 +74,7 @@ TEST_F(BloomFilterPredicateTest, bloom_filter_func_stringval_test) { ASSERT_FALSE(func->find((const void*)¬_exist_val)); // test fixed char - func.reset(IBloomFilterFuncBase::create_bloom_filter(tracker.get(), PrimitiveType::TYPE_CHAR)); + func.reset(create_bloom_filter(tracker.get(), PrimitiveType::TYPE_CHAR)); ASSERT_TRUE(func->init(1024, 0.05).ok()); auto varchar_true_str = obj_pool.add(new std::string("true")); @@ -105,7 +106,7 @@ TEST_F(BloomFilterPredicateTest, bloom_filter_func_stringval_test) { TEST_F(BloomFilterPredicateTest, bloom_filter_size_test) { auto tracker = MemTracker::CreateTracker(); std::unique_ptr func( - IBloomFilterFuncBase::create_bloom_filter(tracker.get(), PrimitiveType::TYPE_VARCHAR)); + create_bloom_filter(tracker.get(), PrimitiveType::TYPE_VARCHAR)); int length = 4096; func->init_with_fixed_length(4096); char* data = nullptr; diff --git a/be/test/exprs/hybrid_set_test.cpp b/be/test/exprs/hybrid_set_test.cpp index d946afa7bc..4a93e90418 100644 --- a/be/test/exprs/hybrid_set_test.cpp +++ b/be/test/exprs/hybrid_set_test.cpp @@ -22,6 +22,7 @@ #include #include "common/configbase.h" +#include "exprs/create_predicate_function.h" #include "util/logging.h" namespace doris { @@ -35,7 +36,7 @@ protected: }; TEST_F(HybridSetTest, bool) { - HybridSetBase* set = HybridSetBase::create_set(TYPE_BOOLEAN); + HybridSetBase* set = create_set(TYPE_BOOLEAN); bool a = true; set->insert(&a); a = false; @@ -60,7 +61,7 @@ TEST_F(HybridSetTest, bool) { } TEST_F(HybridSetTest, tinyint) { - HybridSetBase* set = HybridSetBase::create_set(TYPE_TINYINT); + HybridSetBase* set = create_set(TYPE_TINYINT); int8_t a = 0; set->insert(&a); a = 1; @@ -97,7 +98,7 @@ TEST_F(HybridSetTest, tinyint) { ASSERT_FALSE(set->find(&a)); } TEST_F(HybridSetTest, smallint) { - HybridSetBase* set = HybridSetBase::create_set(TYPE_SMALLINT); + HybridSetBase* set = create_set(TYPE_SMALLINT); int16_t a = 0; set->insert(&a); a = 1; @@ -133,7 +134,7 @@ TEST_F(HybridSetTest, smallint) { ASSERT_FALSE(set->find(&a)); } TEST_F(HybridSetTest, int) { - HybridSetBase* set = HybridSetBase::create_set(TYPE_INT); + HybridSetBase* set = create_set(TYPE_INT); int32_t a = 0; set->insert(&a); a = 1; @@ -169,7 +170,7 @@ TEST_F(HybridSetTest, int) { ASSERT_FALSE(set->find(&a)); } TEST_F(HybridSetTest, bigint) { - HybridSetBase* set = HybridSetBase::create_set(TYPE_BIGINT); + HybridSetBase* set = create_set(TYPE_BIGINT); int64_t a = 0; set->insert(&a); a = 1; @@ -205,7 +206,7 @@ TEST_F(HybridSetTest, bigint) { ASSERT_FALSE(set->find(&a)); } TEST_F(HybridSetTest, float) { - HybridSetBase* set = HybridSetBase::create_set(TYPE_FLOAT); + HybridSetBase* set = create_set(TYPE_FLOAT); float a = 0; set->insert(&a); a = 1.1; @@ -241,7 +242,7 @@ TEST_F(HybridSetTest, float) { ASSERT_FALSE(set->find(&a)); } TEST_F(HybridSetTest, double) { - HybridSetBase* set = HybridSetBase::create_set(TYPE_DOUBLE); + HybridSetBase* set = create_set(TYPE_DOUBLE); double a = 0; set->insert(&a); a = 1.1; @@ -277,7 +278,7 @@ TEST_F(HybridSetTest, double) { ASSERT_FALSE(set->find(&a)); } TEST_F(HybridSetTest, string) { - HybridSetBase* set = HybridSetBase::create_set(TYPE_VARCHAR); + HybridSetBase* set = create_set(TYPE_VARCHAR); StringValue a; char buf[100]; @@ -329,7 +330,7 @@ TEST_F(HybridSetTest, string) { TEST_F(HybridSetTest, timestamp) { CpuInfo::init(); - HybridSetBase* set = HybridSetBase::create_set(TYPE_DATETIME); + HybridSetBase* set = create_set(TYPE_DATETIME); char s1[] = "2012-01-20 01:10:01"; char s2[] = "1990-10-20 10:10:10.123456 "; char s3[] = " 1990-10-20 10:10:10.123456"; diff --git a/be/test/olap/bloom_filter_column_predicate_test.cpp b/be/test/olap/bloom_filter_column_predicate_test.cpp index d4c4f1a1f6..164c51d27c 100644 --- a/be/test/olap/bloom_filter_column_predicate_test.cpp +++ b/be/test/olap/bloom_filter_column_predicate_test.cpp @@ -19,6 +19,7 @@ #include #include +#include "exprs/create_predicate_function.h" #include "olap/bloom_filter_predicate.h" #include "olap/column_predicate.h" #include "olap/field.h" @@ -91,7 +92,7 @@ TEST_F(TestBloomFilterColumnPredicate, FLOAT_COLUMN) { auto tracker = MemTracker::CreateTracker(-1, "OlapScanner"); std::shared_ptr bloom_filter( - IBloomFilterFuncBase::create_bloom_filter(tracker.get(), PrimitiveType::TYPE_FLOAT)); + create_bloom_filter(tracker.get(), PrimitiveType::TYPE_FLOAT)); bloom_filter->init(4096, 0.05); float value = 4.1;