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

 ##########
 File path: be/src/olap/rowset/segment_v2/binary_plain_page.h
 ##########
 @@ -144,23 +141,16 @@ class BinaryPlainPageDecoder : public PageDecoder {
     Status init() override {
         CHECK(!_parsed);
 
-        if (_data.size < MIN_HEADER_SIZE) {
+        if (_data.size < MIN_TRAILER_SIZE) {
             std::stringstream ss;
-            ss << "file corrupton: not enough bytes for header in 
BinaryPlainPageDecoder ."
-                  "invalid data size:" << _data.size << ", header size:" << 
MIN_HEADER_SIZE;
+            ss << "file corrupton: not enough bytes for trailer in 
BinaryPlainPageDecoder ."
+                  "invalid data size:" << _data.size << ", trailer size:" << 
MIN_TRAILER_SIZE;
             return Status::InternalError(ss.str());
         }
 
-        // Decode header.
-        _num_elems         = decode_fixed32_le((const uint8_t *)&_data[0]);
-        size_t offsets_pos = decode_fixed32_le((const uint8_t *)&_data[4]);
-
-        // Sanity check.
-        if (offsets_pos > _data.size) {
-            std::stringstream ss;
-            ss << "offsets_pos "<< offsets_pos << " > page size " << 
_data.size << " in plain string page";
-            return Status::InternalError(ss.str());
-        }
+        // Decode trailer
+        _num_elems = decode_fixed32_le((const uint8_t 
*)&_data[_data.get_size() - sizeof(uint32_t)]);
+        size_t offsets_pos = _data.get_size() - sizeof(uint32_t) - _num_elems 
* sizeof(uint32_t);
 
 Review comment:
   I think we can remove _offsets_buf and just store the offset position. Don't 
forget to use decode_fixed32_le when decoding offsets

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


With regards,
Apache Git Services

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

Reply via email to