yiguolei commented on code in PR #48382: URL: https://github.com/apache/doris/pull/48382#discussion_r1974984043
########## be/src/runtime_filter/utils.cpp: ########## @@ -0,0 +1,300 @@ +// 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 "runtime_filter/utils.h" + +#include "vec/exprs/vexpr.h" +#include "vec/exprs/vliteral.h" + +namespace doris { + +std::string filter_type_to_string(RuntimeFilterType type) { + switch (type) { + case RuntimeFilterType::IN_FILTER: { + return "in"; + } + case RuntimeFilterType::BLOOM_FILTER: { + return "bloomfilter"; + } + case RuntimeFilterType::MIN_FILTER: { + return "only_min"; + } + case RuntimeFilterType::MAX_FILTER: { + return "only_max"; + } + case RuntimeFilterType::MINMAX_FILTER: { + return "minmax"; + } + case RuntimeFilterType::IN_OR_BLOOM_FILTER: { + return "in_or_bloomfilter"; + } + case RuntimeFilterType::BITMAP_FILTER: { + return "bitmapfilter"; + } + default: + return "unknown"; + } +} + +RuntimeFilterType get_runtime_filter_type(const TRuntimeFilterDesc* desc) { + switch (desc->type) { + case TRuntimeFilterType::BLOOM: { + return RuntimeFilterType::BLOOM_FILTER; + } + case TRuntimeFilterType::MIN_MAX: { + if (desc->__isset.min_max_type) { + if (desc->min_max_type == TMinMaxRuntimeFilterType::MIN) { + return RuntimeFilterType::MIN_FILTER; + } else if (desc->min_max_type == TMinMaxRuntimeFilterType::MAX) { + return RuntimeFilterType::MAX_FILTER; + } + } + return RuntimeFilterType::MINMAX_FILTER; + } + case TRuntimeFilterType::IN: { + return RuntimeFilterType::IN_FILTER; + } + case TRuntimeFilterType::IN_OR_BLOOM: { + return RuntimeFilterType::IN_OR_BLOOM_FILTER; + } + case TRuntimeFilterType::BITMAP: { + return RuntimeFilterType::BITMAP_FILTER; + } + default: { + throw doris::Exception(doris::ErrorCode::INTERNAL_ERROR, "Invalid runtime filter type {}", + int(desc->type)); + } + } +} + +// PrimitiveType-> PColumnType +PColumnType to_proto(PrimitiveType type) { + switch (type) { + case TYPE_BOOLEAN: + return PColumnType::COLUMN_TYPE_BOOL; + case TYPE_TINYINT: + return PColumnType::COLUMN_TYPE_TINY_INT; + case TYPE_SMALLINT: + return PColumnType::COLUMN_TYPE_SMALL_INT; + case TYPE_INT: + return PColumnType::COLUMN_TYPE_INT; + case TYPE_BIGINT: + return PColumnType::COLUMN_TYPE_BIGINT; + case TYPE_LARGEINT: + return PColumnType::COLUMN_TYPE_LARGEINT; + case TYPE_FLOAT: + return PColumnType::COLUMN_TYPE_FLOAT; + case TYPE_DOUBLE: + return PColumnType::COLUMN_TYPE_DOUBLE; + case TYPE_DATE: + return PColumnType::COLUMN_TYPE_DATE; + case TYPE_DATEV2: + return PColumnType::COLUMN_TYPE_DATEV2; + case TYPE_DATETIMEV2: + return PColumnType::COLUMN_TYPE_DATETIMEV2; + case TYPE_DATETIME: + return PColumnType::COLUMN_TYPE_DATETIME; + case TYPE_DECIMALV2: + return PColumnType::COLUMN_TYPE_DECIMALV2; + case TYPE_DECIMAL32: + return PColumnType::COLUMN_TYPE_DECIMAL32; + case TYPE_DECIMAL64: + return PColumnType::COLUMN_TYPE_DECIMAL64; + case TYPE_DECIMAL128I: + return PColumnType::COLUMN_TYPE_DECIMAL128I; + case TYPE_DECIMAL256: + return PColumnType::COLUMN_TYPE_DECIMAL256; + case TYPE_CHAR: + return PColumnType::COLUMN_TYPE_CHAR; + case TYPE_VARCHAR: + return PColumnType::COLUMN_TYPE_VARCHAR; + case TYPE_STRING: + return PColumnType::COLUMN_TYPE_STRING; + case TYPE_IPV4: + return PColumnType::COLUMN_TYPE_IPV4; + case TYPE_IPV6: + return PColumnType::COLUMN_TYPE_IPV6; + default: + throw Exception(ErrorCode::INTERNAL_ERROR, + "runtime filter meet invalid PrimitiveType type {}", int(type)); + } +} + +// PColumnType->PrimitiveType +PrimitiveType to_primitive_type(PColumnType type) { Review Comment: 移动都到primitive_type.h 这个文件中吧 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org