Copilot commented on code in PR #61858:
URL: https://github.com/apache/doris/pull/61858#discussion_r3013250260
##########
be/src/storage/predicate/predicate_creator.h:
##########
@@ -17,271 +17,35 @@
#pragma once
-#include <fast_float/fast_float.h>
-
-#include <charconv>
-#include <stdexcept>
+#include <memory>
#include <string>
-#include <type_traits>
-#include "common/exception.h"
-#include "common/status.h"
#include "core/data_type/data_type.h"
-#include "core/data_type/define_primitive_type.h"
#include "core/data_type/primitive_type.h"
-#include "core/string_ref.h"
-#include "exprs/create_predicate_function.h"
-#include "exprs/function/cast/cast_parameters.h"
-#include "exprs/function/cast/cast_to_basic_number_common.h"
+#include "core/field.h"
#include "exprs/hybrid_set.h"
-#include "storage/olap_utils.h"
-#include "storage/predicate/bloom_filter_predicate.h"
#include "storage/predicate/column_predicate.h"
-#include "storage/predicate/comparison_predicate.h"
-#include "storage/predicate/in_list_predicate.h"
-#include "storage/predicate/null_predicate.h"
-#include "storage/tablet/tablet_schema.h"
-#include "util/date_func.h"
-#include "util/string_util.h"
namespace doris {
#include "common/compile_check_begin.h"
-template <PrimitiveType TYPE, PredicateType PT>
-std::shared_ptr<ColumnPredicate> create_in_list_predicate(const uint32_t cid,
- const std::string
col_name,
- const
std::shared_ptr<HybridSetBase>& set,
- bool is_opposite,
- size_t char_length =
0) {
- auto set_size = set->size();
- if (set_size == 1) {
- return InListPredicateBase<TYPE, PT, 1>::create_shared(cid, col_name,
set, is_opposite,
- char_length);
- } else if (set_size == 2) {
- return InListPredicateBase<TYPE, PT, 2>::create_shared(cid, col_name,
set, is_opposite,
- char_length);
- } else if (set_size == 3) {
- return InListPredicateBase<TYPE, PT, 3>::create_shared(cid, col_name,
set, is_opposite,
- char_length);
- } else if (set_size == 4) {
- return InListPredicateBase<TYPE, PT, 4>::create_shared(cid, col_name,
set, is_opposite,
- char_length);
- } else if (set_size == 5) {
- return InListPredicateBase<TYPE, PT, 5>::create_shared(cid, col_name,
set, is_opposite,
- char_length);
- } else if (set_size == 6) {
- return InListPredicateBase<TYPE, PT, 6>::create_shared(cid, col_name,
set, is_opposite,
- char_length);
- } else if (set_size == 7) {
- return InListPredicateBase<TYPE, PT, 7>::create_shared(cid, col_name,
set, is_opposite,
- char_length);
- } else if (set_size == FIXED_CONTAINER_MAX_SIZE) {
- return InListPredicateBase<TYPE, PT, 8>::create_shared(cid, col_name,
set, is_opposite,
- char_length);
- } else {
- return InListPredicateBase<TYPE, PT, FIXED_CONTAINER_MAX_SIZE +
1>::create_shared(
- cid, col_name, set, is_opposite, char_length);
- }
-}
+class BloomFilterFuncBase;
+class BitmapFilterFuncBase;
+// Defined in predicate_creator.cpp with explicit instantiations.
template <PredicateType PT>
std::shared_ptr<ColumnPredicate> create_in_list_predicate(const uint32_t cid,
const std::string
col_name,
const DataTypePtr&
data_type,
const
std::shared_ptr<HybridSetBase> set,
- bool is_opposite) {
- switch (data_type->get_primitive_type()) {
- case TYPE_TINYINT: {
- return create_in_list_predicate<TYPE_TINYINT, PT>(cid, col_name, set,
is_opposite);
- }
- case TYPE_SMALLINT: {
- return create_in_list_predicate<TYPE_SMALLINT, PT>(cid, col_name, set,
is_opposite);
- }
- case TYPE_INT: {
- return create_in_list_predicate<TYPE_INT, PT>(cid, col_name, set,
is_opposite);
- }
- case TYPE_BIGINT: {
- return create_in_list_predicate<TYPE_BIGINT, PT>(cid, col_name, set,
is_opposite);
- }
- case TYPE_LARGEINT: {
- return create_in_list_predicate<TYPE_LARGEINT, PT>(cid, col_name, set,
is_opposite);
- }
- case TYPE_FLOAT: {
- return create_in_list_predicate<TYPE_FLOAT, PT>(cid, col_name, set,
is_opposite);
- }
- case TYPE_DOUBLE: {
- return create_in_list_predicate<TYPE_DOUBLE, PT>(cid, col_name, set,
is_opposite);
- }
- case TYPE_DECIMALV2: {
- return create_in_list_predicate<TYPE_DECIMALV2, PT>(cid, col_name,
set, is_opposite);
- }
- case TYPE_DECIMAL32: {
- return create_in_list_predicate<TYPE_DECIMAL32, PT>(cid, col_name,
set, is_opposite);
- }
- case TYPE_DECIMAL64: {
- return create_in_list_predicate<TYPE_DECIMAL64, PT>(cid, col_name,
set, is_opposite);
- }
- case TYPE_DECIMAL128I: {
- return create_in_list_predicate<TYPE_DECIMAL128I, PT>(cid, col_name,
set, is_opposite);
- }
- case TYPE_DECIMAL256: {
- return create_in_list_predicate<TYPE_DECIMAL256, PT>(cid, col_name,
set, is_opposite);
- }
- case TYPE_CHAR: {
- return create_in_list_predicate<TYPE_CHAR, PT>(
- cid, col_name, set, is_opposite,
- assert_cast<const
DataTypeString*>(remove_nullable(data_type).get())->len());
- }
- case TYPE_VARCHAR: {
- return create_in_list_predicate<TYPE_VARCHAR, PT>(cid, col_name, set,
is_opposite);
- }
- case TYPE_STRING: {
- return create_in_list_predicate<TYPE_STRING, PT>(cid, col_name, set,
is_opposite);
- }
- case TYPE_DATE: {
- return create_in_list_predicate<TYPE_DATE, PT>(cid, col_name, set,
is_opposite);
- }
- case TYPE_DATEV2: {
- return create_in_list_predicate<TYPE_DATEV2, PT>(cid, col_name, set,
is_opposite);
- }
- case TYPE_DATETIME: {
- return create_in_list_predicate<TYPE_DATETIME, PT>(cid, col_name, set,
is_opposite);
- }
- case TYPE_DATETIMEV2: {
- return create_in_list_predicate<TYPE_DATETIMEV2, PT>(cid, col_name,
set, is_opposite);
- }
- case TYPE_TIMESTAMPTZ: {
- return create_in_list_predicate<TYPE_TIMESTAMPTZ, PT>(cid, col_name,
set, is_opposite);
- }
- case TYPE_BOOLEAN: {
- return create_in_list_predicate<TYPE_BOOLEAN, PT>(cid, col_name, set,
is_opposite);
- }
- case TYPE_IPV4: {
- return create_in_list_predicate<TYPE_IPV4, PT>(cid, col_name, set,
is_opposite);
- }
- case TYPE_IPV6: {
- return create_in_list_predicate<TYPE_IPV6, PT>(cid, col_name, set,
is_opposite);
- }
- default:
- throw Exception(Status::InternalError("Unsupported type {} for
in_predicate",
-
type_to_string(data_type->get_primitive_type())));
- return nullptr;
- }
-}
+ bool is_opposite);
Review Comment:
The comment says this template is defined in `predicate_creator.cpp` with
explicit instantiations, but the IN/NOT IN implementations live in
`predicate_creator_in_list_in.cpp` / `predicate_creator_in_list_not_in.cpp`
(and they are explicit specializations, not instantiations). Please update the
comment to point to the correct TU(s) to avoid misleading future
refactors/debugging.
##########
be/src/storage/predicate/predicate_creator.h:
##########
@@ -17,271 +17,35 @@
#pragma once
-#include <fast_float/fast_float.h>
-
-#include <charconv>
-#include <stdexcept>
+#include <memory>
#include <string>
-#include <type_traits>
-#include "common/exception.h"
-#include "common/status.h"
#include "core/data_type/data_type.h"
-#include "core/data_type/define_primitive_type.h"
#include "core/data_type/primitive_type.h"
-#include "core/string_ref.h"
-#include "exprs/create_predicate_function.h"
-#include "exprs/function/cast/cast_parameters.h"
-#include "exprs/function/cast/cast_to_basic_number_common.h"
+#include "core/field.h"
#include "exprs/hybrid_set.h"
-#include "storage/olap_utils.h"
-#include "storage/predicate/bloom_filter_predicate.h"
#include "storage/predicate/column_predicate.h"
-#include "storage/predicate/comparison_predicate.h"
-#include "storage/predicate/in_list_predicate.h"
-#include "storage/predicate/null_predicate.h"
-#include "storage/tablet/tablet_schema.h"
-#include "util/date_func.h"
-#include "util/string_util.h"
namespace doris {
#include "common/compile_check_begin.h"
-template <PrimitiveType TYPE, PredicateType PT>
-std::shared_ptr<ColumnPredicate> create_in_list_predicate(const uint32_t cid,
- const std::string
col_name,
- const
std::shared_ptr<HybridSetBase>& set,
- bool is_opposite,
- size_t char_length =
0) {
- auto set_size = set->size();
- if (set_size == 1) {
- return InListPredicateBase<TYPE, PT, 1>::create_shared(cid, col_name,
set, is_opposite,
- char_length);
- } else if (set_size == 2) {
- return InListPredicateBase<TYPE, PT, 2>::create_shared(cid, col_name,
set, is_opposite,
- char_length);
- } else if (set_size == 3) {
- return InListPredicateBase<TYPE, PT, 3>::create_shared(cid, col_name,
set, is_opposite,
- char_length);
- } else if (set_size == 4) {
- return InListPredicateBase<TYPE, PT, 4>::create_shared(cid, col_name,
set, is_opposite,
- char_length);
- } else if (set_size == 5) {
- return InListPredicateBase<TYPE, PT, 5>::create_shared(cid, col_name,
set, is_opposite,
- char_length);
- } else if (set_size == 6) {
- return InListPredicateBase<TYPE, PT, 6>::create_shared(cid, col_name,
set, is_opposite,
- char_length);
- } else if (set_size == 7) {
- return InListPredicateBase<TYPE, PT, 7>::create_shared(cid, col_name,
set, is_opposite,
- char_length);
- } else if (set_size == FIXED_CONTAINER_MAX_SIZE) {
- return InListPredicateBase<TYPE, PT, 8>::create_shared(cid, col_name,
set, is_opposite,
- char_length);
- } else {
- return InListPredicateBase<TYPE, PT, FIXED_CONTAINER_MAX_SIZE +
1>::create_shared(
- cid, col_name, set, is_opposite, char_length);
- }
-}
+class BloomFilterFuncBase;
+class BitmapFilterFuncBase;
+// Defined in predicate_creator.cpp with explicit instantiations.
template <PredicateType PT>
std::shared_ptr<ColumnPredicate> create_in_list_predicate(const uint32_t cid,
const std::string
col_name,
const DataTypePtr&
data_type,
const
std::shared_ptr<HybridSetBase> set,
- bool is_opposite) {
- switch (data_type->get_primitive_type()) {
- case TYPE_TINYINT: {
- return create_in_list_predicate<TYPE_TINYINT, PT>(cid, col_name, set,
is_opposite);
- }
- case TYPE_SMALLINT: {
- return create_in_list_predicate<TYPE_SMALLINT, PT>(cid, col_name, set,
is_opposite);
- }
- case TYPE_INT: {
- return create_in_list_predicate<TYPE_INT, PT>(cid, col_name, set,
is_opposite);
- }
- case TYPE_BIGINT: {
- return create_in_list_predicate<TYPE_BIGINT, PT>(cid, col_name, set,
is_opposite);
- }
- case TYPE_LARGEINT: {
- return create_in_list_predicate<TYPE_LARGEINT, PT>(cid, col_name, set,
is_opposite);
- }
- case TYPE_FLOAT: {
- return create_in_list_predicate<TYPE_FLOAT, PT>(cid, col_name, set,
is_opposite);
- }
- case TYPE_DOUBLE: {
- return create_in_list_predicate<TYPE_DOUBLE, PT>(cid, col_name, set,
is_opposite);
- }
- case TYPE_DECIMALV2: {
- return create_in_list_predicate<TYPE_DECIMALV2, PT>(cid, col_name,
set, is_opposite);
- }
- case TYPE_DECIMAL32: {
- return create_in_list_predicate<TYPE_DECIMAL32, PT>(cid, col_name,
set, is_opposite);
- }
- case TYPE_DECIMAL64: {
- return create_in_list_predicate<TYPE_DECIMAL64, PT>(cid, col_name,
set, is_opposite);
- }
- case TYPE_DECIMAL128I: {
- return create_in_list_predicate<TYPE_DECIMAL128I, PT>(cid, col_name,
set, is_opposite);
- }
- case TYPE_DECIMAL256: {
- return create_in_list_predicate<TYPE_DECIMAL256, PT>(cid, col_name,
set, is_opposite);
- }
- case TYPE_CHAR: {
- return create_in_list_predicate<TYPE_CHAR, PT>(
- cid, col_name, set, is_opposite,
- assert_cast<const
DataTypeString*>(remove_nullable(data_type).get())->len());
- }
- case TYPE_VARCHAR: {
- return create_in_list_predicate<TYPE_VARCHAR, PT>(cid, col_name, set,
is_opposite);
- }
- case TYPE_STRING: {
- return create_in_list_predicate<TYPE_STRING, PT>(cid, col_name, set,
is_opposite);
- }
- case TYPE_DATE: {
- return create_in_list_predicate<TYPE_DATE, PT>(cid, col_name, set,
is_opposite);
- }
- case TYPE_DATEV2: {
- return create_in_list_predicate<TYPE_DATEV2, PT>(cid, col_name, set,
is_opposite);
- }
- case TYPE_DATETIME: {
- return create_in_list_predicate<TYPE_DATETIME, PT>(cid, col_name, set,
is_opposite);
- }
- case TYPE_DATETIMEV2: {
- return create_in_list_predicate<TYPE_DATETIMEV2, PT>(cid, col_name,
set, is_opposite);
- }
- case TYPE_TIMESTAMPTZ: {
- return create_in_list_predicate<TYPE_TIMESTAMPTZ, PT>(cid, col_name,
set, is_opposite);
- }
- case TYPE_BOOLEAN: {
- return create_in_list_predicate<TYPE_BOOLEAN, PT>(cid, col_name, set,
is_opposite);
- }
- case TYPE_IPV4: {
- return create_in_list_predicate<TYPE_IPV4, PT>(cid, col_name, set,
is_opposite);
- }
- case TYPE_IPV6: {
- return create_in_list_predicate<TYPE_IPV6, PT>(cid, col_name, set,
is_opposite);
- }
- default:
- throw Exception(Status::InternalError("Unsupported type {} for
in_predicate",
-
type_to_string(data_type->get_primitive_type())));
- return nullptr;
- }
-}
+ bool is_opposite);
+// Defined in predicate_creator.cpp with explicit instantiations.
template <PredicateType PT>
std::shared_ptr<ColumnPredicate> create_comparison_predicate(const uint32_t
cid,
const std::string
col_name,
const
DataTypePtr& data_type,
- const Field&
value, bool opposite) {
- switch (data_type->get_primitive_type()) {
- case TYPE_TINYINT: {
- return ComparisonPredicateBase<TYPE_TINYINT, PT>::create_shared(cid,
col_name, value,
-
opposite);
- }
- case TYPE_SMALLINT: {
- return ComparisonPredicateBase<TYPE_SMALLINT, PT>::create_shared(cid,
col_name, value,
-
opposite);
- }
- case TYPE_INT: {
- return ComparisonPredicateBase<TYPE_INT, PT>::create_shared(cid,
col_name, value, opposite);
- }
- case TYPE_BIGINT: {
- return ComparisonPredicateBase<TYPE_BIGINT, PT>::create_shared(cid,
col_name, value,
-
opposite);
- }
- case TYPE_LARGEINT: {
- return ComparisonPredicateBase<TYPE_LARGEINT, PT>::create_shared(cid,
col_name, value,
-
opposite);
- }
- case TYPE_FLOAT: {
- return ComparisonPredicateBase<TYPE_FLOAT, PT>::create_shared(cid,
col_name, value,
-
opposite);
- }
- case TYPE_DOUBLE: {
- return ComparisonPredicateBase<TYPE_DOUBLE, PT>::create_shared(cid,
col_name, value,
-
opposite);
- }
- case TYPE_DECIMALV2: {
- return ComparisonPredicateBase<TYPE_DECIMALV2, PT>::create_shared(cid,
col_name, value,
-
opposite);
- }
- case TYPE_DECIMAL32: {
- return ComparisonPredicateBase<TYPE_DECIMAL32, PT>::create_shared(cid,
col_name, value,
-
opposite);
- }
- case TYPE_DECIMAL64: {
- return ComparisonPredicateBase<TYPE_DECIMAL64, PT>::create_shared(cid,
col_name, value,
-
opposite);
- }
- case TYPE_DECIMAL128I: {
- return ComparisonPredicateBase<TYPE_DECIMAL128I,
PT>::create_shared(cid, col_name, value,
-
opposite);
- }
- case TYPE_DECIMAL256: {
- return ComparisonPredicateBase<TYPE_DECIMAL256,
PT>::create_shared(cid, col_name, value,
-
opposite);
- }
- case TYPE_CHAR: {
- auto target = std::max(cast_set<size_t>(assert_cast<const
DataTypeString*>(
-
remove_nullable(data_type).get())
- ->len()),
- value.template get<TYPE_CHAR>().size());
- if (target > value.template get<TYPE_CHAR>().size()) {
- std::string tmp(target, '\0');
- memcpy(tmp.data(), value.template get<TYPE_CHAR>().data(),
- value.template get<TYPE_CHAR>().size());
- return ComparisonPredicateBase<TYPE_CHAR, PT>::create_shared(
- cid, col_name,
Field::create_field<TYPE_CHAR>(std::move(tmp)), opposite);
- } else {
- return ComparisonPredicateBase<TYPE_CHAR, PT>::create_shared(
- cid, col_name,
Field::create_field<TYPE_CHAR>(value.template get<TYPE_CHAR>()),
- opposite);
- }
- }
- case TYPE_VARCHAR:
- case TYPE_STRING: {
- return ComparisonPredicateBase<TYPE_STRING, PT>::create_shared(cid,
col_name, value,
-
opposite);
- }
- case TYPE_DATE: {
- return ComparisonPredicateBase<TYPE_DATE, PT>::create_shared(cid,
col_name, value,
- opposite);
- }
- case TYPE_DATEV2: {
- return ComparisonPredicateBase<TYPE_DATEV2, PT>::create_shared(cid,
col_name, value,
-
opposite);
- }
- case TYPE_DATETIME: {
- return ComparisonPredicateBase<TYPE_DATETIME, PT>::create_shared(cid,
col_name, value,
-
opposite);
- }
- case TYPE_DATETIMEV2: {
- return ComparisonPredicateBase<TYPE_DATETIMEV2,
PT>::create_shared(cid, col_name, value,
-
opposite);
- }
- case TYPE_TIMESTAMPTZ: {
- return ComparisonPredicateBase<TYPE_TIMESTAMPTZ,
PT>::create_shared(cid, col_name, value,
-
opposite);
- }
- case TYPE_BOOLEAN: {
- return ComparisonPredicateBase<TYPE_BOOLEAN, PT>::create_shared(cid,
col_name, value,
-
opposite);
- }
- case TYPE_IPV4: {
- return ComparisonPredicateBase<TYPE_IPV4, PT>::create_shared(cid,
col_name, value,
- opposite);
- }
- case TYPE_IPV6: {
- return ComparisonPredicateBase<TYPE_IPV6, PT>::create_shared(cid,
col_name, value,
- opposite);
- }
- default:
- throw Exception(Status::InternalError("Unsupported type {} for
comparison_predicate",
-
type_to_string(data_type->get_primitive_type())));
- return nullptr;
- }
-}
+ const Field&
value, bool opposite);
Review Comment:
This comment says the template is defined in `predicate_creator.cpp`, but
the comparison predicate template definition + explicit instantiations are in
`predicate_creator_comparison.cpp`. Please update the comment to match the
actual file to keep navigation accurate.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]