Skip to content

Commit

Permalink
fix ut
Browse files Browse the repository at this point in the history
Signed-off-by: silverbullet233 <[email protected]>
  • Loading branch information
silverbullet233 committed Feb 14, 2025
1 parent d053642 commit af1c9f5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
25 changes: 13 additions & 12 deletions be/src/exprs/runtime_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,8 @@ class RuntimeFilter {
std::vector<RuntimeFilter*> _group_colocate_filters;
};


template <typename ModuloFunc>
struct WithModuloArg {

template <TRuntimeFilterLayoutMode::type M>
struct HashValueCompute {
void operator()(const RuntimeFilterLayout& layout, const std::vector<const Column*>& columns, size_t num_rows,
Expand Down Expand Up @@ -1192,32 +1190,36 @@ class RuntimeBloomFilter final : public RuntimeFilter {
}
}

bool _evaluate_min_max(const CppType& value) const {
ALWAYS_INLINE bool _evaluate_min_max(const CppType& value) const {
if constexpr (!IsSlice<CppType>) {
return value >= _min && value <= _max;
bool left = _left_close_interval ? value >= _min : value > _min;
bool right = _right_close_interval ? value <= _max : value < _max;
return left && right;
}
return true;
}

uint16_t _evaluate_min_max(const ContainerType& values, uint16_t* sel, uint16_t sel_size, uint16_t* dst_sel) const {
if constexpr (!IsSlice<CppType>) {
const auto* data = values.data();
uint16_t new_size = 0;
for (int i = 0; i < sel_size; i++) {
uint16_t idx = sel[i];
dst_sel[new_size] = idx;
new_size += (data[idx] >= _min && data[idx] <= _max);
new_size += _evaluate_min_max(data[idx]);
}
return new_size;
} else {
return sel_size;
}
}

void _evaluate_min_max(const ContainerType& values, uint8_t* selection, uint16_t from, uint16_t to) const {
if constexpr (!IsSlice<CppType>) {
const auto* data = values.data();
for (uint16_t i = from; i < to; i++) {
if (!selection[i]) continue;
selection[i] = (data[i] >= _min && data[i] <= _max);
selection[i] = _evaluate_min_max(data[i]);
}
}
}
Expand All @@ -1235,15 +1237,14 @@ class RuntimeBloomFilter final : public RuntimeFilter {
if (column->is_nullable()) {
const auto* nullable_column = down_cast<const NullableColumn*>(column);
const auto& data = GetContainer<Type>::get_data(nullable_column->data_column());
uint16_t new_sel_size = _evaluate_min_max(data, sel, sel_size, dst_sel);
if (nullable_column->has_null()) {
const uint8_t* null_data = nullable_column->immutable_null_column_data().data();
for (int i = 0; i < new_sel_size; i++) {
uint16_t idx = dst_sel[i];
for (int i = 0; i < sel_size; i++) {
uint16_t idx = sel[i];
dst_sel[new_size] = idx;
if (null_data[idx]) {
new_size += _has_null;
} else {
} else if (_evaluate_min_max(data[idx])) {
if constexpr (can_use_bf) {
new_size +=
_rf_test_data<multi_partition>(data[idx], multi_partition ? hash_values[idx] : 0);
Expand All @@ -1253,6 +1254,7 @@ class RuntimeBloomFilter final : public RuntimeFilter {
}
}
} else {
uint16_t new_sel_size = _evaluate_min_max(data, sel, sel_size, dst_sel);
if constexpr (can_use_bf) {
for (int i = 0; i < new_sel_size; ++i) {
uint16_t idx = dst_sel[i];
Expand Down Expand Up @@ -1294,10 +1296,9 @@ class RuntimeBloomFilter final : public RuntimeFilter {
if (nullable_column->has_null()) {
const uint8_t* null_data = nullable_column->immutable_null_column_data().data();
for (uint16_t i = from; i < to; i++) {
if (!selection[i]) continue;
if (null_data[i]) {
selection[i] = _has_null;
} else {
} else if (selection[i]) {
if constexpr (can_use_bf) {
selection[i] =
_rf_test_data<multi_partition>(data[i], multi_partition ? hash_values[i] : 0);
Expand Down
3 changes: 2 additions & 1 deletion be/src/runtime/runtime_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,8 @@ class RuntimeState {
void set_enable_event_scheduler(bool enable) { _enable_event_scheduler = enable; }

bool enable_join_runtime_filter_pushdown() const {
return _query_options.__isset.enable_join_runtime_filter_pushdown && _query_options.enable_join_runtime_filter_pushdown;
return _query_options.__isset.enable_join_runtime_filter_pushdown &&
_query_options.enable_join_runtime_filter_pushdown;
}

DebugActionMgr& debug_action_mgr() { return _debug_action_mgr; }
Expand Down

0 comments on commit af1c9f5

Please sign in to comment.