This is an automated email from the ASF dual-hosted git repository. dataroaring pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new 50ef6e35be [enhancement](RowDescriptor) enhance tuple_idx check during runtime (#11835) 50ef6e35be is described below commit 50ef6e35bef972d4689e25aa0ec545e6ddef13df Author: AlexYue <yj976240...@qq.com> AuthorDate: Wed Aug 17 17:50:48 2022 +0800 [enhancement](RowDescriptor) enhance tuple_idx check during runtime (#11835) --- be/src/exec/blocking_join_node.cpp | 5 ++++- be/src/exec/hash_join_node.cpp | 5 ++++- be/src/exec/set_operation_node.cpp | 5 ++++- be/src/exec/table_function_node.cpp | 5 +++-- be/src/exprs/tuple_is_null_predicate.cpp | 2 ++ be/src/runtime/descriptors.cpp | 6 +++++- be/src/runtime/descriptors.h | 7 +++++++ be/src/vec/exec/vblocking_join_node.cpp | 5 ++++- 8 files changed, 33 insertions(+), 7 deletions(-) diff --git a/be/src/exec/blocking_join_node.cpp b/be/src/exec/blocking_join_node.cpp index ed533cc21f..10419a3499 100644 --- a/be/src/exec/blocking_join_node.cpp +++ b/be/src/exec/blocking_join_node.cpp @@ -23,6 +23,7 @@ #include <sstream> #include "gen_cpp/PlanNodes_types.h" +#include "runtime/descriptors.h" #include "runtime/row_batch.h" #include "runtime/runtime_state.h" #include "runtime/tuple.h" @@ -70,7 +71,9 @@ Status BlockingJoinNode::prepare(RuntimeState* state) { for (int i = 0; i < _build_tuple_size; ++i) { TupleDescriptor* build_tuple_desc = child(1)->row_desc().tuple_descriptors()[i]; - _build_tuple_idx.push_back(_row_descriptor.get_tuple_idx(build_tuple_desc->id())); + auto tuple_idx = _row_descriptor.get_tuple_idx(build_tuple_desc->id()); + RETURN_IF_INVALID_TUPLE_IDX(build_tuple_desc->id(), tuple_idx); + _build_tuple_idx.push_back(tuple_idx); } _probe_tuple_row_size = num_left_tuples * sizeof(Tuple*); diff --git a/be/src/exec/hash_join_node.cpp b/be/src/exec/hash_join_node.cpp index b328c4b157..cbba3c607c 100644 --- a/be/src/exec/hash_join_node.cpp +++ b/be/src/exec/hash_join_node.cpp @@ -29,6 +29,7 @@ #include "exprs/runtime_filter.h" #include "exprs/runtime_filter_slots.h" #include "gen_cpp/PlanNodes_types.h" +#include "runtime/descriptors.h" #include "runtime/row_batch.h" #include "runtime/runtime_filter_mgr.h" #include "runtime/runtime_state.h" @@ -132,7 +133,9 @@ Status HashJoinNode::prepare(RuntimeState* state) { for (int i = 0; i < _build_tuple_size; ++i) { TupleDescriptor* build_tuple_desc = child(1)->row_desc().tuple_descriptors()[i]; - _build_tuple_idx.push_back(_row_descriptor.get_tuple_idx(build_tuple_desc->id())); + auto tuple_idx = _row_descriptor.get_tuple_idx(build_tuple_desc->id()); + RETURN_IF_INVALID_TUPLE_IDX(build_tuple_desc->id(), tuple_idx); + _build_tuple_idx.push_back(tuple_idx); } _probe_tuple_row_size = num_left_tuples * sizeof(Tuple*); _build_tuple_row_size = num_build_tuples * sizeof(Tuple*); diff --git a/be/src/exec/set_operation_node.cpp b/be/src/exec/set_operation_node.cpp index 12ba3d373f..7e00e69fbe 100644 --- a/be/src/exec/set_operation_node.cpp +++ b/be/src/exec/set_operation_node.cpp @@ -19,6 +19,7 @@ #include "exprs/expr.h" #include "exprs/expr_context.h" +#include "runtime/descriptors.h" #include "runtime/raw_value.h" #include "runtime/row_batch.h" #include "runtime/runtime_state.h" @@ -57,7 +58,9 @@ Status SetOperationNode::prepare(RuntimeState* state) { for (int i = 0; i < _build_tuple_size; ++i) { TupleDescriptor* build_tuple_desc = child(0)->row_desc().tuple_descriptors()[i]; - _build_tuple_idx.push_back(_row_descriptor.get_tuple_idx(build_tuple_desc->id())); + auto tuple_idx = _row_descriptor.get_tuple_idx(build_tuple_desc->id()); + RETURN_IF_INVALID_TUPLE_IDX(build_tuple_desc->id(), tuple_idx); + _build_tuple_idx.push_back(tuple_idx); } _find_nulls = std::vector<bool>(); for (auto ctx : _child_expr_lists[0]) { diff --git a/be/src/exec/table_function_node.cpp b/be/src/exec/table_function_node.cpp index a1cbd9f10f..de852d1abe 100644 --- a/be/src/exec/table_function_node.cpp +++ b/be/src/exec/table_function_node.cpp @@ -286,8 +286,9 @@ Status TableFunctionNode::get_next(RuntimeState* state, RowBatch* row_batch, boo TupleDescriptor* child_tuple_desc = child_rowdesc.tuple_descriptors()[tuple_idx]; TupleDescriptor* parent_tuple_desc = parent_rowdesc.tuple_descriptors()[tuple_idx]; - Tuple* child_tuple = _cur_child_tuple_row->get_tuple( - child_rowdesc.get_tuple_idx(child_tuple_desc->id())); + auto tuple_idx = child_rowdesc.get_tuple_idx(child_tuple_desc->id()); + RETURN_IF_INVALID_TUPLE_IDX(child_tuple_desc->id(), tuple_idx); + Tuple* child_tuple = _cur_child_tuple_row->get_tuple(tuple_idx); // The child tuple is nullptr, only when the child tuple is from outer join. so we directly set // parent_tuple have same tuple_idx nullptr to mock the behavior diff --git a/be/src/exprs/tuple_is_null_predicate.cpp b/be/src/exprs/tuple_is_null_predicate.cpp index b3c93bd290..1c67092160 100644 --- a/be/src/exprs/tuple_is_null_predicate.cpp +++ b/be/src/exprs/tuple_is_null_predicate.cpp @@ -23,6 +23,7 @@ #include <sstream> #include "gen_cpp/Exprs_types.h" +#include "runtime/descriptors.h" namespace doris { @@ -39,6 +40,7 @@ Status TupleIsNullPredicate::prepare(RuntimeState* state, const RowDescriptor& r // Resolve tuple ids to tuple indexes. for (int i = 0; i < _tuple_ids.size(); ++i) { int32_t tuple_idx = row_desc.get_tuple_idx(_tuple_ids[i]); + RETURN_IF_INVALID_TUPLE_IDX(_tuple_ids[i], tuple_idx); if (row_desc.tuple_is_nullable(tuple_idx)) { _tuple_idxs.push_back(tuple_idx); } diff --git a/be/src/runtime/descriptors.cpp b/be/src/runtime/descriptors.cpp index 62e5707003..585f1ce574 100644 --- a/be/src/runtime/descriptors.cpp +++ b/be/src/runtime/descriptors.cpp @@ -399,7 +399,11 @@ int RowDescriptor::get_row_size() const { } int RowDescriptor::get_tuple_idx(TupleId id) const { - CHECK_LT(id, _tuple_idx_map.size()) << "RowDescriptor: " << debug_string(); + // comment CHECK temporarily to make fuzzy test run smoothly + // DCHECK_LT(id, _tuple_idx_map.size()) << "RowDescriptor: " << debug_string(); + if (_tuple_idx_map.size() <= id) { + return RowDescriptor::INVALID_IDX; + } return _tuple_idx_map[id]; } diff --git a/be/src/runtime/descriptors.h b/be/src/runtime/descriptors.h index c40285ce9f..abc87e705f 100644 --- a/be/src/runtime/descriptors.h +++ b/be/src/runtime/descriptors.h @@ -382,6 +382,13 @@ private: DescriptorTbl() = default; }; +#define RETURN_IF_INVALID_TUPLE_IDX(tuple_id, tuple_idx) \ + do { \ + if (UNLIKELY(RowDescriptor::INVALID_IDX == tuple_idx)) { \ + return Status::InternalError("failed to get tuple idx with tuple id: {}", tuple_id); \ + } \ + } while (false) + // Records positions of tuples within row produced by ExecNode. // TODO: this needs to differentiate between tuples contained in row // and tuples produced by ExecNode (parallel to PlanNode.rowTupleIds and diff --git a/be/src/vec/exec/vblocking_join_node.cpp b/be/src/vec/exec/vblocking_join_node.cpp index 62edd021aa..f98005ca9c 100644 --- a/be/src/vec/exec/vblocking_join_node.cpp +++ b/be/src/vec/exec/vblocking_join_node.cpp @@ -21,6 +21,7 @@ #include "exprs/expr.h" #include "gen_cpp/PlanNodes_types.h" +#include "runtime/descriptors.h" #include "runtime/runtime_state.h" #include "util/runtime_profile.h" @@ -57,7 +58,9 @@ Status VBlockingJoinNode::prepare(RuntimeState* state) { for (int i = 0; i < _build_tuple_size; ++i) { TupleDescriptor* build_tuple_desc = child(1)->row_desc().tuple_descriptors()[i]; - _build_tuple_idx.push_back(_row_descriptor.get_tuple_idx(build_tuple_desc->id())); + auto tuple_idx = _row_descriptor.get_tuple_idx(build_tuple_desc->id()); + RETURN_IF_INVALID_TUPLE_IDX(build_tuple_desc->id(), tuple_idx); + _build_tuple_idx.push_back(tuple_idx); } return Status::OK(); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org