gaodayue commented on a change in pull request #1694: optimize V2 BinaryPlainPage format (#1648) URL: https://github.com/apache/incubator-doris/pull/1694#discussion_r317453726
########## File path: be/src/olap/rowset/segment_v2/binary_plain_page.h ########## @@ -222,39 +194,26 @@ class BinaryPlainPageDecoder : public PageDecoder { } Slice string_at_index(size_t idx) const { - const uint32_t str_offset = offset(idx); - uint32_t len = offset(idx + 1) - str_offset; + const uint32_t str_offset = idx == 0 ? 0 : offset(idx - 1); + uint32_t len = offset(idx) - str_offset; return Slice(&_data[str_offset], len); } - // Minimum length of a header. - static const size_t MIN_HEADER_SIZE = sizeof(uint32_t) * 2; private: // Return the offset within '_data' where the string value with index 'idx' can be found. uint32_t offset(int idx) const { - const uint8_t *p = &_offsets_buf[idx * sizeof(uint32_t)]; - uint32_t ret; - memcpy(&ret, p, sizeof(uint32_t)); - return ret; + const uint8_t *p = reinterpret_cast<const uint8_t *>(&_data[offsets_pos + idx * sizeof(uint32_t)]); + return decode_fixed32_le(p); } Slice _data; PageDecoderOptions _options; bool _parsed; - // A buffer for an array of 32-bit integers for the offsets of the underlying strings in '_data'. - // - // This array also contains one extra offset at the end, pointing - // _after_ the last entry. This makes the code much simpler. - // - // The array is stored inside a 'faststring' instead of a vector<uint32_t> to - // avoid the overhead of calling vector::push_back -- one would think it would - // be fully inlined away, but it's actually a perf win to do this. - faststring _offsets_buf; - uint32_t _num_elems; + uint32_t offsets_pos; Review comment: ```suggestion uint32_t _offsets_pos = 0; ``` ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@doris.apache.org For additional commands, e-mail: dev-h...@doris.apache.org