From 83a9d0728847f672d92d264a2fcc4af61e545899 Mon Sep 17 00:00:00 2001 From: yiguolei <676222867@qq.com> Date: Sat, 7 Oct 2023 11:14:28 +0800 Subject: [PATCH] [refactor](segment iterator) remove some code to make the logic more clear (#25050) Co-authored-by: yiguolei --- be/src/olap/rowset/segment_v2/segment_iterator.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/be/src/olap/rowset/segment_v2/segment_iterator.cpp b/be/src/olap/rowset/segment_v2/segment_iterator.cpp index 42640802f4..51f31010cb 100644 --- a/be/src/olap/rowset/segment_v2/segment_iterator.cpp +++ b/be/src/olap/rowset/segment_v2/segment_iterator.cpp @@ -1405,6 +1405,8 @@ Status SegmentIterator::_vec_init_lazy_materialization() { // If common expr pushdown exists, and expr column is not contained in lazy materialization columns, // add to second read column, which will be read after lazy materialization if (_schema->column_ids().size() > pred_column_ids.size()) { + // pred_column_ids maybe empty, so that could not set _lazy_materialization_read = true here + // has to check there is at least one predicate column for (auto cid : _schema->column_ids()) { if (!_is_pred_column[cid]) { if (_is_need_vec_eval || _is_need_short_eval) { @@ -1449,11 +1451,15 @@ Status SegmentIterator::_vec_init_lazy_materialization() { auto cid = _schema->column_id(i); if (pred_id_set.find(cid) != pred_id_set.end()) { _first_read_column_ids.push_back(cid); - } else if (non_pred_set.find(cid) != non_pred_set.end()) { - _first_read_column_ids.push_back(cid); - // when _lazy_materialization_read = false, non-predicate column should also be filtered by sel idx, so we regard it as pred columns - _is_pred_column[cid] = true; } + // In the past, if schema columns > pred columns, the _lazy_materialization_read maybe == false, but + // we make sure using _lazy_materialization_read= true now, so these logic may never happens. I comment + // these lines and we could delete them in the future to make the code more clear. + // else if (non_pred_set.find(cid) != non_pred_set.end()) { + // _first_read_column_ids.push_back(cid); + // // when _lazy_materialization_read = false, non-predicate column should also be filtered by sel idx, so we regard it as pred columns + // _is_pred_column[cid] = true; + // } } } else if (_is_need_expr_eval) { DCHECK(!_is_need_vec_eval && !_is_need_short_eval);