You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@doris.apache.org by GitBox <gi...@apache.org> on 2019/08/23 07:36:56 UTC

[GitHub] [incubator-doris] wangbo commented on a change in pull request #1694: optimize V2 BinaryPlainPage format (#1648)

wangbo commented on a change in pull request #1694: optimize V2 BinaryPlainPage format (#1648)
URL: https://github.com/apache/incubator-doris/pull/1694#discussion_r317008129
 
 

 ##########
 File path: be/src/olap/rowset/segment_v2/binary_plain_page.h
 ##########
 @@ -80,24 +80,21 @@ class BinaryPlainPageBuilder : public PageBuilder {
     Slice finish() override {
         _finished = true;
 
-        size_t offsets_pos = _buffer.size();
-
-        // Set up the header
-        encode_fixed32_le(&_buffer[0], _offsets.size());
-        encode_fixed32_le(&_buffer[4], offsets_pos);
+        // Set up trailer
+        size_t new_cap = _buffer.size() + _offsets.size() * sizeof(uint32_t) + MAX_TRAILER_SIZE;
+        if (new_cap > _buffer.capacity())
+            _buffer.GrowArray(new_cap);
 
 Review comment:
   when append trailer to buffer_,the size is known,so grow buffer manually can avoid auto grow which may more than needed(auto grow always expand by at least 50%),this will waste memory

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@doris.apache.org
For additional commands, e-mail: dev-help@doris.apache.org