From d70c17bdc006421af0b6af3fde7ea81db68fe4c9 Mon Sep 17 00:00:00 2001 From: Pxl Date: Mon, 23 Dec 2024 13:54:12 +0800 Subject: [PATCH] [Improvement](scan) use loop to instead recursion on Level1Iterator::_normal_next #38005 (#45767) pick from #38005 --- be/src/vec/olap/vcollect_iterator.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/be/src/vec/olap/vcollect_iterator.cpp b/be/src/vec/olap/vcollect_iterator.cpp index a020119924df49..d785ccf4ebc107 100644 --- a/be/src/vec/olap/vcollect_iterator.cpp +++ b/be/src/vec/olap/vcollect_iterator.cpp @@ -865,20 +865,20 @@ Status VCollectIterator::Level1Iterator::_merge_next(Block* block) { Status VCollectIterator::Level1Iterator::_normal_next(Block* block) { SCOPED_RAW_TIMER(&_reader->_stats.collect_iterator_normal_next_timer); auto res = _cur_child->next(block); + + while (res.is() && !_children.empty()) { + _cur_child = std::move(*(_children.begin())); + _children.pop_front(); + // clear TEMP columns to avoid column align problem + block->erase_tmp_columns(); + res = _cur_child->next(block); + } + if (LIKELY(res.ok())) { return Status::OK(); } else if (res.is()) { - // current child has been read, to read next - if (!_children.empty()) { - _cur_child = std::move(*(_children.begin())); - _children.pop_front(); - // clear TEMP columns to avoid column align problem - block->erase_tmp_columns(); - return _normal_next(block); - } else { - _cur_child.reset(); - return Status::Error(""); - } + _cur_child.reset(); + return Status::Error(""); } else { _cur_child.reset(); LOG(WARNING) << "failed to get next from child, res=" << res;