diff --git a/be/src/exprs/runtime_filter.cpp b/be/src/exprs/runtime_filter.cpp index be8ab3b02e10bc5..cf8cb6863c8557a 100644 --- a/be/src/exprs/runtime_filter.cpp +++ b/be/src/exprs/runtime_filter.cpp @@ -52,6 +52,8 @@ #include "vec/columns/column.h" #include "vec/columns/column_complex.h" #include "vec/common/assert_cast.h" +#include "vec/core/wide_integer.h" +#include "vec/core/wide_integer_to_string.h" #include "vec/exprs/vbitmap_predicate.h" #include "vec/exprs/vbloom_predicate.h" #include "vec/exprs/vdirect_in_predicate.h" @@ -786,6 +788,18 @@ class RuntimePredicateWrapper { }); break; } + case TYPE_DECIMAL256: { + batch_assign(in_filter, [](std::shared_ptr& set, PColumnValue& column, + ObjectPool* pool) { + auto string_val = column.stringval(); + StringParser::ParseResult result; + auto int_val = StringParser::string_to_int( + string_val.c_str(), string_val.length(), &result); + DCHECK(result == StringParser::PARSE_SUCCESS); + set->insert(&int_val); + }); + break; + } case TYPE_VARCHAR: case TYPE_CHAR: case TYPE_STRING: { @@ -919,6 +933,10 @@ class RuntimePredicateWrapper { DCHECK(result == StringParser::PARSE_SUCCESS); return _context.minmax_func->assign(&min_val, &max_val); } + case TYPE_DECIMAL256: { + // TODO: support decimal256 + return Status::OK(); + } case TYPE_VARCHAR: case TYPE_CHAR: case TYPE_STRING: { @@ -1571,6 +1589,12 @@ void IRuntimeFilter::to_protobuf(PInFilter* filter) { }); return; } + case TYPE_DECIMAL256: { + batch_copy(filter, it, [](PColumnValue* column, const wide::Int256* value) { + column->set_stringval(wide::to_string(*value)); + }); + return; + } case TYPE_CHAR: case TYPE_VARCHAR: case TYPE_STRING: { @@ -1680,6 +1704,10 @@ void IRuntimeFilter::to_protobuf(PMinMaxFilter* filter) { LargeIntValue::to_string(*reinterpret_cast(max_data))); return; } + case TYPE_DECIMAL256: { + // TODO: support decimal256 + return; + } case TYPE_CHAR: case TYPE_VARCHAR: case TYPE_STRING: { diff --git a/be/src/util/string_parser.hpp b/be/src/util/string_parser.hpp index 1a22e149888e049..83289e73adeed20 100644 --- a/be/src/util/string_parser.hpp +++ b/be/src/util/string_parser.hpp @@ -41,6 +41,7 @@ #include "runtime/large_int_value.h" #include "runtime/primitive_type.h" #include "vec/common/int_exp.h" +#include "vec/core/extended_types.h" #include "vec/core/wide_integer.h" #include "vec/data_types/data_type_decimal.h" @@ -571,6 +572,11 @@ inline int StringParser::StringParseTraits<__int128>::max_ascii_len() { return 39; } +template <> +inline int StringParser::StringParseTraits::max_ascii_len() { + return 78; +} + template T StringParser::string_to_decimal(const char* s, int len, int type_precision, int type_scale, ParseResult* result) { diff --git a/be/src/vec/core/accurate_comparison.h b/be/src/vec/core/accurate_comparison.h index 3e90a3cbb56fec8..a090d4ccf2c7e32 100644 --- a/be/src/vec/core/accurate_comparison.h +++ b/be/src/vec/core/accurate_comparison.h @@ -495,11 +495,11 @@ bool lessOp(A a, B b) { /// different signedness if constexpr (is_signed_v && !is_signed_v) { - return a < 0 || static_cast>(a) < b; + return a < 0 || static_cast>(a) < b; } if constexpr (!is_signed_v && is_signed_v) { - return b >= 0 && a < static_cast>(b); + return b >= 0 && a < static_cast>(b); } } @@ -574,11 +574,11 @@ bool equalsOp(A a, B b) { /// different signedness if constexpr (is_signed_v && !is_signed_v) { - return a >= 0 && static_cast>(a) == b; + return a >= 0 && static_cast>(a) == b; } if constexpr (!is_signed_v && is_signed_v) { - return b >= 0 && a == static_cast>(b); + return b >= 0 && a == static_cast>(b); } } diff --git a/be/src/vec/core/decomposed_float.h b/be/src/vec/core/decomposed_float.h index 24e3f547a35d599..a4784e3f132681e 100644 --- a/be/src/vec/core/decomposed_float.h +++ b/be/src/vec/core/decomposed_float.h @@ -139,7 +139,7 @@ struct DecomposedFloat { } using UInt = std::conditional_t<(sizeof(Int) > sizeof(typename Traits::UInt)), - make_unsigned_t, typename Traits::UInt>; + std::make_unsigned_t, typename Traits::UInt>; UInt uint_rhs = rhs < 0 ? -rhs : rhs; /// Smaller octave: abs(rhs) < abs(float) diff --git a/be/src/vec/core/extended_types.h b/be/src/vec/core/extended_types.h index 3c67ebb50e29425..5d73536781022ea 100644 --- a/be/src/vec/core/extended_types.h +++ b/be/src/vec/core/extended_types.h @@ -26,7 +26,7 @@ // using Int128 = wide::integer<128, signed>; // using UInt128 = wide::integer<128, unsigned>; using Int256 = wide::integer<256, signed>; -// using UInt256 = wide::integer<256, unsigned>; +using UInt256 = wide::integer<256, unsigned>; static_assert(sizeof(Int256) == 32); // static_assert(sizeof(UInt256) == 32); @@ -65,8 +65,7 @@ template concept is_integer = std::is_integral_v // || std::is_same_v // || std::is_same_v - || std::is_same_v; -// || std::is_same_v; + || std::is_same_v || std::is_same_v; template concept is_floating_point = std::is_floating_point_v; @@ -85,19 +84,21 @@ concept is_floating_point = std::is_floating_point_v; // template // inline constexpr bool is_arithmetic_v = is_arithmetic::value; // -template -struct make_unsigned // NOLINT(readability-identifier-naming) -{ - using type = std::make_unsigned_t; -}; - +namespace std { // template <> struct make_unsigned { using type = UInt128; }; // template <> struct make_unsigned { using type = UInt128; }; -// template <> struct make_unsigned { using type = UInt256; }; -// template <> struct make_unsigned { using type = UInt256; }; +template <> +struct make_unsigned { + using type = UInt256; +}; +template <> +struct make_unsigned { + using type = UInt256; +}; template using make_unsigned_t = typename make_unsigned::type; +} // namespace std // template // struct make_signed // NOLINT(readability-identifier-naming)