dataroaring commented on code in PR #19099:
URL: https://github.com/apache/doris/pull/19099#discussion_r1184600830


##########
be/src/olap/memtable.cpp:
##########
@@ -286,32 +292,90 @@ void MemTable::_collect_vskiplist_results() {
         _output_mutable_block.add_rows(&in_block, row_pos_vec.data(),
                                        row_pos_vec.data() + in_block.rows());
     } else {
-        size_t idx = 0;
-        for (it.SeekToFirst(); it.Valid(); it.Next()) {
+        size_t idx = 0, temp_idx = 0;
+        vectorized::MutableBlock mutable_block =
+                vectorized::MutableBlock::build_mutable_block(&in_block);
+        _vec_row_comparator->set_block(&mutable_block);
+        auto new_row_it = std::next(_row_in_blocks.begin(), _last_sorted_pos);
+        // sort new rows
+        std::sort(new_row_it, _row_in_blocks.end(),
+                  [this](const RowInBlock* l, const RowInBlock* r) -> bool {
+                      auto value = (*(this->_vec_row_comparator))(l, r);
+                      if (value == 0) {
+                          return l->_row_pos > r->_row_pos;
+                      } else {
+                          return value < 0;
+                      }
+                  });
+        // merge new rows and old rows
+        std::inplace_merge(_row_in_blocks.begin(), new_row_it, 
_row_in_blocks.end());
+        _last_sorted_pos = _row_in_blocks.size();
+        std::vector<RowInBlock*> temp_row_in_blocks(_last_sorted_pos);
+        std::vector<size_t> need_merge_idxs; // use bitset?
+        bool need_init_agg = true;

Review Comment:
   if (same_keys_num == 0) skip agg.



-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to