spaces-X commented on code in PR #9459:
URL: https://github.com/apache/incubator-doris/pull/9459#discussion_r870024960


##########
be/src/olap/memtable.cpp:
##########
@@ -263,22 +274,56 @@ vectorized::Block MemTable::_collect_vskiplist_results() {
                 auto function = _agg_functions[i];
                 function->insert_result_into(it.key()->_agg_places[i],
                                              
*(_output_mutable_block.get_column_by_position(i)));
-                function->destroy(it.key()->_agg_places[i]);
+                if (final) {
+                    function->destroy(it.key()->_agg_places[i]);
+                }
             }
+            // re-index the row_pos in VSkipList
+            it.key()->_row_pos = idx;
+            idx++;
+        }
+        if (!final) {
+            _input_mutable_block.swap(_output_mutable_block);
+            //TODO(weixang):opt here.
+            _output_mutable_block = 
vectorized::MutableBlock::build_mutable_block(&in_block);
+            _output_mutable_block.clear_column_data();
+        }
+    }
+}
+
+void MemTable::shrink_memtable_by_agg() {
+    {
+        SCOPED_TIMER(_shrunk_agg_time);
+        if (_is_shrunk_by_agg) {
+            return;
         }
+        size_t old_size = _input_mutable_block.allocated_bytes();
+        _collect_vskiplist_to_output(false);
+        size_t new_size = _input_mutable_block.allocated_bytes();
+        // shrink mem usage of memetable after agged.
+        _mem_usage += new_size - old_size;
+        _mem_tracker->consume(new_size - old_size);
+        _is_shrunk_by_agg = true;
     }
-    return _output_mutable_block.to_block();
+}
+
+bool MemTable::is_full() {
+    return memory_usage() >= config::write_buffer_size;
 }
 
 Status MemTable::flush() {
-    VLOG_CRITICAL << "begin to flush memtable for tablet: " << _tablet_id
+    clock_t now = clock();

Review Comment:
   i pushed my debug code by mistake.
   These logs and profiles will be removed later.



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