zuochunwei commented on a change in pull request #7852:
URL: https://github.com/apache/incubator-doris/pull/7852#discussion_r791334747



##########
File path: be/src/olap/rowset/segment_v2/segment_iterator.cpp
##########
@@ -872,13 +867,13 @@ Status SegmentIterator::next_batch(vectorized::Block* 
block) {
         RETURN_IF_ERROR(_init(true));
         _inited = true;
         if (!_vec_pred_column_ids.empty() || 
!_short_cir_pred_column_ids.empty()) {
-            _block_rowids.reserve(_opts.block_row_max);
+            _block_rowids.resize(_opts.block_row_max);

Review comment:
       reverve just alloc memory for optimization reason.
   
   there is one basic rule: any reserve calls can be removed, this removing 
operation will not influence the correctness of result.
   
   according this rule, if we remove this _block_rowids.reserve(), the will 
crash, so we should use resize instead.

##########
File path: be/src/olap/rowset/segment_v2/segment_iterator.cpp
##########
@@ -872,13 +867,13 @@ Status SegmentIterator::next_batch(vectorized::Block* 
block) {
         RETURN_IF_ERROR(_init(true));
         _inited = true;
         if (!_vec_pred_column_ids.empty() || 
!_short_cir_pred_column_ids.empty()) {
-            _block_rowids.reserve(_opts.block_row_max);
+            _block_rowids.resize(_opts.block_row_max);

Review comment:
       reserve只是预分配内存,是而且只是性能的考虑,代码中任何调用reserve()的地方应该可以被删除,而不会影响正确性。
   
   
比如vector,调用reserve后不会改变vector的size,随后的at(index)会崩,operator[index]的行为也依赖于实现,所以,这个地方用resize更合适




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