acelyc111 commented on a change in pull request #5811:
URL: https://github.com/apache/incubator-doris/pull/5811#discussion_r647165034



##########
File path: be/src/olap/rowset/alpha_rowset_reader.cpp
##########
@@ -120,20 +129,24 @@ int64_t AlphaRowsetReader::filtered_rows() {
 }
 
 OLAPStatus AlphaRowsetReader::_union_block(RowBlock** block) {
-    while (_ordinal < _merge_ctxs.size()) {
+    while (_cur_ctx != nullptr) {
         // union block only use one block to store
-        OLAPStatus status = _pull_next_block(&(_merge_ctxs[_ordinal]));
+        OLAPStatus status = _pull_next_block(_cur_ctx);
         if (status == OLAP_ERR_DATA_EOF) {
-            _ordinal++;
-            continue;
+            delete _cur_ctx;
+            _cur_ctx = nullptr;
+            _sequential_ctxs.pop_front();
+            if (!_sequential_ctxs.empty()) {
+                _cur_ctx = *(_sequential_ctxs.begin());
+            }
         } else if (status != OLAP_SUCCESS) {
             return status;
         } else {
-            (*block) = _merge_ctxs[_ordinal].row_block;
+            (*block) = _cur_ctx->row_block;
             return OLAP_SUCCESS;
         }
     }
-    if (_ordinal == _merge_ctxs.size()) {
+    if (_sequential_ctxs.empty()) {

Review comment:
       _Do you mean `CHECK(_merge_heap.empty())`?_
   Yes, you are right! In '_union_block' mode, `_merge_heap` should always be 
empty, but it's a hotspot code path, better to avoid this check?

##########
File path: be/src/olap/rowset/alpha_rowset_reader.cpp
##########
@@ -37,6 +37,15 @@ AlphaRowsetReader::AlphaRowsetReader(int 
num_rows_per_row_block, AlphaRowsetShar
 AlphaRowsetReader::~AlphaRowsetReader() {
     delete _dst_cursor;
     _rowset->release();
+    while (!_merge_heap.empty()) {

Review comment:
       In previous implementation, `_merge_heap`'s elements are pointers 
reference to`std::vector<AlphaMergeContext> _merge_ctxs`'s object elements, the 
latter will be automatically released in deconstructor.
   But now I've removed `_merge_ctxs` member variable, and `_merge_heap`'s 
elements are malloced from heap then fill into `_sequential_ctxs`. In 
'_merge_block' mode, these pointers will be moved to `_merge_heap`, so it's 
needed to clear it now.
   On the other hand, in '_union_block' mode, these pointers are kept in 
`_sequential_ctxs`, we have to clear it too in the following lines.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to