Skip to content

Commit

Permalink
fix rf
Browse files Browse the repository at this point in the history
  • Loading branch information
jacktengg committed Oct 20, 2023
1 parent fee30d0 commit 96cab18
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 16 deletions.
28 changes: 28 additions & 0 deletions be/src/exprs/runtime_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -786,6 +788,18 @@ class RuntimePredicateWrapper {
});
break;
}
case TYPE_DECIMAL256: {
batch_assign(in_filter, [](std::shared_ptr<HybridSetBase>& set, PColumnValue& column,
ObjectPool* pool) {
auto string_val = column.stringval();
StringParser::ParseResult result;
auto int_val = StringParser::string_to_int<wide::Int256>(
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: {
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -1571,6 +1589,12 @@ void IRuntimeFilter::to_protobuf(PInFilter* filter) {
});
return;
}
case TYPE_DECIMAL256: {
batch_copy<wide::Int256>(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: {
Expand Down Expand Up @@ -1680,6 +1704,10 @@ void IRuntimeFilter::to_protobuf(PMinMaxFilter* filter) {
LargeIntValue::to_string(*reinterpret_cast<const int128_t*>(max_data)));
return;
}
case TYPE_DECIMAL256: {
// TODO: support decimal256
return;
}
case TYPE_CHAR:
case TYPE_VARCHAR:
case TYPE_STRING: {
Expand Down
6 changes: 6 additions & 0 deletions be/src/util/string_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -571,6 +572,11 @@ inline int StringParser::StringParseTraits<__int128>::max_ascii_len() {
return 39;
}

template <>
inline int StringParser::StringParseTraits<wide::Int256>::max_ascii_len() {
return 78;
}

template <PrimitiveType P, typename T>
T StringParser::string_to_decimal(const char* s, int len, int type_precision, int type_scale,
ParseResult* result) {
Expand Down
8 changes: 4 additions & 4 deletions be/src/vec/core/accurate_comparison.h
Original file line number Diff line number Diff line change
Expand Up @@ -495,11 +495,11 @@ bool lessOp(A a, B b) {
/// different signedness

if constexpr (is_signed_v<A> && !is_signed_v<B>) {
return a < 0 || static_cast<make_unsigned_t<A>>(a) < b;
return a < 0 || static_cast<std::make_unsigned_t<A>>(a) < b;
}

if constexpr (!is_signed_v<A> && is_signed_v<B>) {
return b >= 0 && a < static_cast<make_unsigned_t<B>>(b);
return b >= 0 && a < static_cast<std::make_unsigned_t<B>>(b);
}
}

Expand Down Expand Up @@ -574,11 +574,11 @@ bool equalsOp(A a, B b) {
/// different signedness

if constexpr (is_signed_v<A> && !is_signed_v<B>) {
return a >= 0 && static_cast<make_unsigned_t<A>>(a) == b;
return a >= 0 && static_cast<std::make_unsigned_t<A>>(a) == b;
}

if constexpr (!is_signed_v<A> && is_signed_v<B>) {
return b >= 0 && a == static_cast<make_unsigned_t<B>>(b);
return b >= 0 && a == static_cast<std::make_unsigned_t<B>>(b);
}
}

Expand Down
2 changes: 1 addition & 1 deletion be/src/vec/core/decomposed_float.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ struct DecomposedFloat {
}

using UInt = std::conditional_t<(sizeof(Int) > sizeof(typename Traits::UInt)),
make_unsigned_t<Int>, typename Traits::UInt>;
std::make_unsigned_t<Int>, typename Traits::UInt>;
UInt uint_rhs = rhs < 0 ? -rhs : rhs;

/// Smaller octave: abs(rhs) < abs(float)
Expand Down
23 changes: 12 additions & 11 deletions be/src/vec/core/extended_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -65,8 +65,7 @@ template <class T>
concept is_integer = std::is_integral_v<T>
// || std::is_same_v<T, Int128>
// || std::is_same_v<T, UInt128>
|| std::is_same_v<T, Int256>;
// || std::is_same_v<T, UInt256>;
|| std::is_same_v<T, Int256> || std::is_same_v<T, UInt256>;

template <class T>
concept is_floating_point = std::is_floating_point_v<T>;
Expand All @@ -85,19 +84,21 @@ concept is_floating_point = std::is_floating_point_v<T>;
// template <typename T>
// inline constexpr bool is_arithmetic_v = is_arithmetic<T>::value;
//
template <typename T>
struct make_unsigned // NOLINT(readability-identifier-naming)
{
using type = std::make_unsigned_t<T>;
};

namespace std {
// template <> struct make_unsigned<Int128> { using type = UInt128; };
// template <> struct make_unsigned<UInt128> { using type = UInt128; };
// template <> struct make_unsigned<Int256> { using type = UInt256; };
// template <> struct make_unsigned<UInt256> { using type = UInt256; };
template <>
struct make_unsigned<Int256> {
using type = UInt256;
};
template <>
struct make_unsigned<UInt256> {
using type = UInt256;
};

template <typename T>
using make_unsigned_t = typename make_unsigned<T>::type;
} // namespace std

// template <typename T>
// struct make_signed // NOLINT(readability-identifier-naming)
Expand Down

0 comments on commit 96cab18

Please sign in to comment.