// 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" namespace doris { class MinmaxFunctionTraits { public: using BasePtr = MinMaxFuncBase*; template static BasePtr get_function() { return new (std::nothrow) MinMaxNumFunc::CppType>(); }; }; class HybridSetTraits { public: using BasePtr = HybridSetBase*; template static BasePtr get_function() { 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() { return new BloomFilterFunc(); }; }; template class PredicateFunctionCreator { public: template static typename Traits::BasePtr create() { return Traits::template get_function(); } }; template typename Traits::BasePtr create_predicate_function(PrimitiveType type) { using Creator = PredicateFunctionCreator; switch (type) { case TYPE_BOOLEAN: return Creator::template create(); case TYPE_TINYINT: return Creator::template create(); case TYPE_SMALLINT: return Creator::template create(); case TYPE_INT: return Creator::template create(); case TYPE_BIGINT: return Creator::template create(); case TYPE_LARGEINT: return Creator::template create(); case TYPE_FLOAT: return Creator::template create(); case TYPE_DOUBLE: return Creator::template create(); case TYPE_DECIMALV2: return Creator::template create(); case TYPE_DATE: return Creator::template create(); case TYPE_DATETIME: return Creator::template create(); case TYPE_CHAR: return Creator::template create(); case TYPE_VARCHAR: return Creator::template create(); case TYPE_STRING: return Creator::template create(); 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(PrimitiveType type) { return create_predicate_function(type); } } // namespace doris