From f02bec8ad1d371ea9af3b345de4c7f26d4bf2ba2 Mon Sep 17 00:00:00 2001 From: Pxl Date: Wed, 5 Jul 2023 14:03:55 +0800 Subject: [PATCH] [Chore](runtime filter) change runtime filter dcheck to error status or exception (#21475) change runtime filter dcheck to error status or exception --- be/src/exprs/runtime_filter_slots.h | 41 ++++++++++++++--------- be/src/exprs/runtime_filter_slots_cross.h | 18 +++++----- 2 files changed, 36 insertions(+), 23 deletions(-) diff --git a/be/src/exprs/runtime_filter_slots.h b/be/src/exprs/runtime_filter_slots.h index 816e62c731..6ca85f02ad 100644 --- a/be/src/exprs/runtime_filter_slots.h +++ b/be/src/exprs/runtime_filter_slots.h @@ -17,6 +17,7 @@ #pragma once +#include "common/exception.h" #include "common/status.h" #include "exprs/runtime_filter.h" #include "runtime/runtime_filter_mgr.h" @@ -28,20 +29,24 @@ #include "vec/runtime/shared_hash_table_controller.h" namespace doris { -// this class used in a hash join node -// Provide a unified interface for other classes -template -class RuntimeFilterSlotsBase { +// this class used in hash join node +class VRuntimeFilterSlots { public: - RuntimeFilterSlotsBase(const std::vector>& prob_expr_ctxs, - const std::vector>& build_expr_ctxs, - const std::vector& runtime_filter_descs) + VRuntimeFilterSlots( + const std::vector>& prob_expr_ctxs, + const std::vector>& build_expr_ctxs, + const std::vector& runtime_filter_descs) : _probe_expr_context(prob_expr_ctxs), _build_expr_context(build_expr_ctxs), _runtime_filter_descs(runtime_filter_descs) {} Status init(RuntimeState* state, int64_t hash_table_size, size_t build_bf_cardinality) { - DCHECK(_probe_expr_context.size() == _build_expr_context.size()); + if (_probe_expr_context.size() != _build_expr_context.size()) { + return Status::InternalError( + "_probe_expr_context.size() != _build_expr_context.size(), " + "_probe_expr_context.size()={}, _build_expr_context.size()={}", + _probe_expr_context.size(), _build_expr_context.size()); + } // runtime filter effect strategy // 1. we will ignore IN filter when hash_table_size is too big @@ -53,7 +58,10 @@ public: auto ignore_local_filter = [state](int filter_id) { std::vector filters; state->runtime_filter_mgr()->get_consume_filters(filter_id, filters); - DCHECK(!filters.empty()); + if (filters.empty()) { + throw Exception(ErrorCode::INTERNAL_ERROR, "filters empty, filter_id={}", + filter_id); + } for (auto filter : filters) { filter->set_ignored(); filter->signal(); @@ -92,9 +100,13 @@ public: IRuntimeFilter* runtime_filter = nullptr; RETURN_IF_ERROR(state->runtime_filter_mgr()->get_producer_filter(filter_desc.filter_id, &runtime_filter)); - DCHECK(runtime_filter != nullptr); - DCHECK(runtime_filter->expr_order() >= 0); - DCHECK(runtime_filter->expr_order() < _probe_expr_context.size()); + if (runtime_filter->expr_order() < 0 || + runtime_filter->expr_order() >= _probe_expr_context.size()) { + return Status::InternalError( + "runtime_filter meet invalid expr_order, expr_order={}, " + "probe_expr_context.size={}", + runtime_filter->expr_order(), _probe_expr_context.size()); + } // do not create 'in filter' when hash_table size over limit auto max_in_num = state->runtime_filter_max_in_num(); @@ -250,12 +262,11 @@ public: bool empty() { return !_runtime_filters.size(); } private: - const std::vector>& _probe_expr_context; - const std::vector>& _build_expr_context; + const std::vector>& _probe_expr_context; + const std::vector>& _build_expr_context; const std::vector& _runtime_filter_descs; // prob_contition index -> [IRuntimeFilter] std::map> _runtime_filters; }; -using VRuntimeFilterSlots = RuntimeFilterSlotsBase; } // namespace doris diff --git a/be/src/exprs/runtime_filter_slots_cross.h b/be/src/exprs/runtime_filter_slots_cross.h index 184ba46591..8711ba181c 100644 --- a/be/src/exprs/runtime_filter_slots_cross.h +++ b/be/src/exprs/runtime_filter_slots_cross.h @@ -32,23 +32,26 @@ namespace doris { // this class used in cross join node -template -class RuntimeFilterSlotsCross { +class VRuntimeFilterSlotsCross { public: - RuntimeFilterSlotsCross(const std::vector& runtime_filter_descs, - const vectorized::VExprContextSPtrs& src_expr_ctxs) + VRuntimeFilterSlotsCross(const std::vector& runtime_filter_descs, + const vectorized::VExprContextSPtrs& src_expr_ctxs) : _runtime_filter_descs(runtime_filter_descs), filter_src_expr_ctxs(src_expr_ctxs) {} - ~RuntimeFilterSlotsCross() = default; + ~VRuntimeFilterSlotsCross() = default; Status init(RuntimeState* state) { for (auto& filter_desc : _runtime_filter_descs) { IRuntimeFilter* runtime_filter = nullptr; RETURN_IF_ERROR(state->runtime_filter_mgr()->get_producer_filter(filter_desc.filter_id, &runtime_filter)); - DCHECK(runtime_filter != nullptr); + if (runtime_filter == nullptr) { + return Status::InternalError("runtime filter is nullptr"); + } // cross join has not remote filter - DCHECK(!runtime_filter->has_remote_target()); + if (runtime_filter->has_remote_target()) { + return Status::InternalError("cross join runtime filter has remote target"); + } _runtime_filters.push_back(runtime_filter); } return Status::OK(); @@ -104,5 +107,4 @@ private: std::vector _runtime_filters; }; -using VRuntimeFilterSlotsCross = RuntimeFilterSlotsCross; } // namespace doris