Skip to content

Commit

Permalink
[Chore](runtime-filter) refactor of runtime filter void type data usa…
Browse files Browse the repository at this point in the history
…ge (apache#43957)

refactor of runtime filter void type data usage
  • Loading branch information
BiteTheDDDDt authored Nov 26, 2024
1 parent 680c572 commit 137ed95
Show file tree
Hide file tree
Showing 9 changed files with 172 additions and 349 deletions.
84 changes: 30 additions & 54 deletions be/src/exprs/hybrid_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,8 @@

#pragma once

#include <glog/logging.h>

#include <type_traits>

#include "common/exception.h"
#include "common/object_pool.h"
#include "common/status.h"
#include "exprs/runtime_filter.h"
#include "runtime/decimalv2_value.h"
#include "runtime/define_primitive_type.h"
#include "runtime/primitive_type.h"
#include "vec/columns/column_nullable.h"
#include "vec/columns/column_string.h"
#include "vec/common/hash_table/phmap_fwd_decl.h"
#include "vec/common/string_ref.h"
#include "exprs/runtime_filter_convertor.h"

namespace doris {

Expand Down Expand Up @@ -221,30 +208,19 @@ class HybridSetBase : public RuntimeFilterFuncBase {
virtual bool find(const void* data, size_t) const = 0;

virtual void find_batch(const doris::vectorized::IColumn& column, size_t rows,
doris::vectorized::ColumnUInt8::Container& results) {
LOG(FATAL) << "HybridSetBase not support find_batch";
__builtin_unreachable();
}

doris::vectorized::ColumnUInt8::Container& results) = 0;
virtual void find_batch_negative(const doris::vectorized::IColumn& column, size_t rows,
doris::vectorized::ColumnUInt8::Container& results) {
LOG(FATAL) << "HybridSetBase not support find_batch_negative";
__builtin_unreachable();
}

doris::vectorized::ColumnUInt8::Container& results) = 0;
virtual void find_batch_nullable(const doris::vectorized::IColumn& column, size_t rows,
const doris::vectorized::NullMap& null_map,
doris::vectorized::ColumnUInt8::Container& results) {
LOG(FATAL) << "HybridSetBase not support find_batch_nullable";
__builtin_unreachable();
}
doris::vectorized::ColumnUInt8::Container& results) = 0;

virtual void find_batch_nullable_negative(const doris::vectorized::IColumn& column, size_t rows,
const doris::vectorized::NullMap& null_map,
doris::vectorized::ColumnUInt8::Container& results) {
LOG(FATAL) << "HybridSetBase not support find_batch_nullable_negative";
__builtin_unreachable();
}
virtual void find_batch_nullable_negative(
const doris::vectorized::IColumn& column, size_t rows,
const doris::vectorized::NullMap& null_map,
doris::vectorized::ColumnUInt8::Container& results) = 0;

virtual void to_pb(PInFilter* filter) = 0;

class IteratorBase {
public:
Expand All @@ -261,26 +237,6 @@ class HybridSetBase : public RuntimeFilterFuncBase {
bool _contains_null = false;
};

template <typename Type>
const Type* check_and_get_hybrid_set(const HybridSetBase& column) {
return typeid_cast<const Type*>(&column);
}

template <typename Type>
const Type* check_and_get_hybrid_set(const HybridSetBase* column) {
return typeid_cast<const Type*>(column);
}

template <typename Type>
bool check_hybrid_set(const HybridSetBase& column) {
return check_and_get_hybrid_set<Type>(&column);
}

template <typename Type>
bool check_hybrid_set(const HybridSetBase* column) {
return check_and_get_hybrid_set<Type>(column);
}

template <PrimitiveType T,
typename _ContainerType = DynamicContainer<typename PrimitiveTypeTraits<T>::CppType>,
typename _ColumnType = typename PrimitiveTypeTraits<T>::ColumnType>
Expand Down Expand Up @@ -409,6 +365,14 @@ class HybridSet : public HybridSetBase {

ContainerType* get_inner_set() { return &_set; }

void set_pb(PInFilter* filter, auto f) {
for (auto v : _set) {
f(filter->add_values(), v);
}
}

void to_pb(PInFilter* filter) override { set_pb(filter, get_convertor<ElementType>()); }

private:
ContainerType _set;
ObjectPool _pool;
Expand Down Expand Up @@ -569,6 +533,14 @@ class StringSet : public HybridSetBase {

ContainerType* get_inner_set() { return &_set; }

void set_pb(PInFilter* filter, auto f) {
for (const auto& v : _set) {
f(filter->add_values(), v);
}
}

void to_pb(PInFilter* filter) override { set_pb(filter, get_convertor<std::string>()); }

private:
ContainerType _set;
ObjectPool _pool;
Expand Down Expand Up @@ -735,6 +707,10 @@ class StringValueSet : public HybridSetBase {

ContainerType* get_inner_set() { return &_set; }

void to_pb(PInFilter* filter) override {
throw Exception(ErrorCode::INTERNAL_ERROR, "StringValueSet do not support to_pb");
}

private:
ContainerType _set;
ObjectPool _pool;
Expand Down
23 changes: 14 additions & 9 deletions be/src/exprs/minmax_predicate.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,8 @@

#pragma once

#include <type_traits>

#include "common/object_pool.h"
#include "exprs/runtime_filter.h"
#include "runtime/type_limit.h"
#include "vec/columns/column.h"
#include "vec/columns/column_nullable.h"
#include "vec/columns/column_string.h"
#include "vec/common/assert_cast.h"
#include "vec/common/string_ref.h"
#include "exprs/runtime_filter_convertor.h"

namespace doris {
// only used in Runtime Filter
Expand All @@ -45,6 +37,8 @@ class MinMaxFuncBase : public RuntimeFilterFuncBase {

void set_contain_null() { _contain_null = true; }

virtual void to_pb(PMinMaxFilter* filter) = 0;

protected:
bool _contain_null = false;
};
Expand Down Expand Up @@ -165,6 +159,17 @@ class MinMaxNumFunc : public MinMaxFuncBase {
return Status::OK();
}

void set_pb(PMinMaxFilter* filter, auto f) {
if constexpr (NeedMin) {
f(filter->mutable_min_val(), _min);
}
if constexpr (NeedMax) {
f(filter->mutable_max_val(), _max);
}
}

void to_pb(PMinMaxFilter* filter) override { set_pb(filter, get_convertor<T>()); }

protected:
T _max = type_limit<T>::min();
T _min = type_limit<T>::max();
Expand Down
Loading

0 comments on commit 137ed95

Please sign in to comment.