From b9de530da1d0eb7c39576516e58f7666042c7437 Mon Sep 17 00:00:00 2001 From: bobhan1 Date: Wed, 22 Oct 2025 11:48:41 +0800 Subject: [PATCH 1/8] add config --- be/src/common/config.cpp | 2 ++ be/src/common/config.h | 2 ++ be/src/olap/rowset/segment_v2/encoding_info.h | 14 ++++++++++++++ 3 files changed, 18 insertions(+) diff --git a/be/src/common/config.cpp b/be/src/common/config.cpp index 5a53acbeacee94..ee4ea8bf092be3 100644 --- a/be/src/common/config.cpp +++ b/be/src/common/config.cpp @@ -1626,6 +1626,8 @@ DEFINE_Validator(binary_plain_encoding_default_impl, [](const std::string& confi return config == "v1" || config == "v2"; }); +DEFINE_mBool(integer_type_default_use_plain_encoding, "true"); + // clang-format off #ifdef BE_TEST // test s3 diff --git a/be/src/common/config.h b/be/src/common/config.h index 3297bfea8ebe95..8489554394a534 100644 --- a/be/src/common/config.h +++ b/be/src/common/config.h @@ -1666,6 +1666,8 @@ DECLARE_mString(aws_credentials_provider_version); DECLARE_mString(binary_plain_encoding_default_impl); +DECLARE_mBool(integer_type_default_use_plain_encoding); + #ifdef BE_TEST // test s3 DECLARE_String(test_s3_resource); diff --git a/be/src/olap/rowset/segment_v2/encoding_info.h b/be/src/olap/rowset/segment_v2/encoding_info.h index 92d87459398fbf..5b44a39209069c 100644 --- a/be/src/olap/rowset/segment_v2/encoding_info.h +++ b/be/src/olap/rowset/segment_v2/encoding_info.h @@ -34,6 +34,14 @@ enum class FieldType; namespace segment_v2 { +namespace { +bool is_integer_type(FieldType type) { + return type == FieldType::OLAP_FIELD_TYPE_TINYINT || + type == FieldType::OLAP_FIELD_TYPE_SMALLINT || type == FieldType::OLAP_FIELD_TYPE_INT || + type == FieldType::OLAP_FIELD_TYPE_BIGINT || type == FieldType::OLAP_FIELD_TYPE_LARGEINT; +} +} // namespace + class PageBuilder; class PageDecoder; struct PageBuilderOptions; @@ -114,6 +122,12 @@ class EncodingInfoResolver { _encoding_map.contains(std::make_pair(type, PLAIN_ENCODING_V2))) { return PLAIN_ENCODING_V2; } + + if (is_integer_type(type) && config::integer_type_default_use_plain_encoding && + _encoding_map.contains(std::make_pair(type, PLAIN_ENCODING))) { + return PLAIN_ENCODING; + } + return encoding; } return UNKNOWN_ENCODING; From 7f6b4bf334dcc5e0c23f0be7bdb1d376d5bb9184 Mon Sep 17 00:00:00 2001 From: bobhan1 Date: Fri, 10 Oct 2025 11:37:37 +0800 Subject: [PATCH 2/8] impl next_batch for PlainPageDecoder --- be/src/olap/rowset/segment_v2/plain_page.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/be/src/olap/rowset/segment_v2/plain_page.h b/be/src/olap/rowset/segment_v2/plain_page.h index 1a537e5b8b7912..f6f723ffe79cd7 100644 --- a/be/src/olap/rowset/segment_v2/plain_page.h +++ b/be/src/olap/rowset/segment_v2/plain_page.h @@ -204,7 +204,21 @@ class PlainPageDecoder : public PageDecoder { } Status next_batch(size_t* n, vectorized::MutableColumnPtr& dst) override { - return Status::NotSupported("plain page not implement vec op now"); + DCHECK(_parsed); + if (*n == 0 || _cur_idx >= _num_elems) [[unlikely]] { + *n = 0; + return Status::OK(); + } + + size_t max_fetch = std::min(*n, static_cast(_num_elems - _cur_idx)); + const void* src_data = &_data[PLAIN_PAGE_HEADER_SIZE + _cur_idx * SIZE_OF_TYPE]; + + dst->insert_many_fix_len_data((const char*)src_data, max_fetch); + + *n = max_fetch; + _cur_idx += max_fetch; + + return Status::OK(); } size_t count() const override { From 58837507a41b9ceec79abb5dfaf09735c72feafa Mon Sep 17 00:00:00 2001 From: bobhan1 Date: Fri, 10 Oct 2025 19:36:03 +0800 Subject: [PATCH 3/8] impl read_by_rowids for PlainPageDecoder --- be/src/olap/rowset/segment_v2/plain_page.h | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/be/src/olap/rowset/segment_v2/plain_page.h b/be/src/olap/rowset/segment_v2/plain_page.h index f6f723ffe79cd7..cd61e1a08dc12e 100644 --- a/be/src/olap/rowset/segment_v2/plain_page.h +++ b/be/src/olap/rowset/segment_v2/plain_page.h @@ -221,6 +221,31 @@ class PlainPageDecoder : public PageDecoder { return Status::OK(); } + Status read_by_rowids(const rowid_t* rowids, ordinal_t page_first_ordinal, size_t* n, + vectorized::MutableColumnPtr& dst) override { + DCHECK(_parsed); + if (*n == 0) [[unlikely]] { + *n = 0; + return Status::OK(); + } + + auto total = *n; + size_t read_count = 0; + for (size_t i = 0; i < total; ++i) { + ordinal_t ord = rowids[i] - page_first_ordinal; + if (UNLIKELY(ord >= _num_elems)) { + break; + } + + const void* src_data = &_data[PLAIN_PAGE_HEADER_SIZE + ord * SIZE_OF_TYPE]; + dst->insert_data((const char*)src_data, SIZE_OF_TYPE); + read_count++; + } + + *n = read_count; + return Status::OK(); + } + size_t count() const override { DCHECK(_parsed); return _num_elems; From f6ce001eeafd41037637820b1240843c5e9a71f5 Mon Sep 17 00:00:00 2001 From: bobhan1 Date: Wed, 22 Oct 2025 11:53:40 +0800 Subject: [PATCH 4/8] update --- .../olap/rowset/segment_v2/encoding_info.cpp | 31 +++++++++++++++++++ be/src/olap/rowset/segment_v2/encoding_info.h | 30 +----------------- 2 files changed, 32 insertions(+), 29 deletions(-) diff --git a/be/src/olap/rowset/segment_v2/encoding_info.cpp b/be/src/olap/rowset/segment_v2/encoding_info.cpp index 6fcf571c038071..58907966ccde55 100644 --- a/be/src/olap/rowset/segment_v2/encoding_info.cpp +++ b/be/src/olap/rowset/segment_v2/encoding_info.cpp @@ -317,6 +317,37 @@ EncodingInfoResolver::~EncodingInfoResolver() { _encoding_map.clear(); } +namespace { +bool is_integer_type(FieldType type) { + return type == FieldType::OLAP_FIELD_TYPE_TINYINT || + type == FieldType::OLAP_FIELD_TYPE_SMALLINT || type == FieldType::OLAP_FIELD_TYPE_INT || + type == FieldType::OLAP_FIELD_TYPE_BIGINT || type == FieldType::OLAP_FIELD_TYPE_LARGEINT; +} +} // namespace + +EncodingTypePB EncodingInfoResolver::get_default_encoding(FieldType type, + bool optimize_value_seek) const { + auto& encoding_map = + optimize_value_seek ? _value_seek_encoding_map : _default_encoding_type_map; + auto it = encoding_map.find(type); + if (it != encoding_map.end()) { + EncodingTypePB encoding = it->second; + // For binary types, use PLAIN_ENCODING_V2 if config::binary_plain_encoding_default_impl is "v2" + if (encoding == PLAIN_ENCODING && config::binary_plain_encoding_default_impl == "v2" && + _encoding_map.contains(std::make_pair(type, PLAIN_ENCODING_V2))) { + return PLAIN_ENCODING_V2; + } + + if (is_integer_type(type) && config::integer_type_default_use_plain_encoding && + _encoding_map.contains(std::make_pair(type, PLAIN_ENCODING))) { + return PLAIN_ENCODING; + } + + return encoding; + } + return UNKNOWN_ENCODING; +} + Status EncodingInfoResolver::get(FieldType data_type, EncodingTypePB encoding_type, const EncodingInfo** out) { if (encoding_type == DEFAULT_ENCODING) { diff --git a/be/src/olap/rowset/segment_v2/encoding_info.h b/be/src/olap/rowset/segment_v2/encoding_info.h index 5b44a39209069c..46d0f3f7581b9e 100644 --- a/be/src/olap/rowset/segment_v2/encoding_info.h +++ b/be/src/olap/rowset/segment_v2/encoding_info.h @@ -34,14 +34,6 @@ enum class FieldType; namespace segment_v2 { -namespace { -bool is_integer_type(FieldType type) { - return type == FieldType::OLAP_FIELD_TYPE_TINYINT || - type == FieldType::OLAP_FIELD_TYPE_SMALLINT || type == FieldType::OLAP_FIELD_TYPE_INT || - type == FieldType::OLAP_FIELD_TYPE_BIGINT || type == FieldType::OLAP_FIELD_TYPE_LARGEINT; -} -} // namespace - class PageBuilder; class PageDecoder; struct PageBuilderOptions; @@ -111,27 +103,7 @@ class EncodingInfoResolver { EncodingInfoResolver(); ~EncodingInfoResolver(); - EncodingTypePB get_default_encoding(FieldType type, bool optimize_value_seek) const { - auto& encoding_map = - optimize_value_seek ? _value_seek_encoding_map : _default_encoding_type_map; - auto it = encoding_map.find(type); - if (it != encoding_map.end()) { - EncodingTypePB encoding = it->second; - // For binary types, use PLAIN_ENCODING_V2 if config::binary_plain_encoding_default_impl is "v2" - if (encoding == PLAIN_ENCODING && config::binary_plain_encoding_default_impl == "v2" && - _encoding_map.contains(std::make_pair(type, PLAIN_ENCODING_V2))) { - return PLAIN_ENCODING_V2; - } - - if (is_integer_type(type) && config::integer_type_default_use_plain_encoding && - _encoding_map.contains(std::make_pair(type, PLAIN_ENCODING))) { - return PLAIN_ENCODING; - } - - return encoding; - } - return UNKNOWN_ENCODING; - } + EncodingTypePB get_default_encoding(FieldType type, bool optimize_value_seek) const; Status get(FieldType data_type, EncodingTypePB encoding_type, const EncodingInfo** out); From a29f390595895479ddb99a7cabafd7c4fb6bcc54 Mon Sep 17 00:00:00 2001 From: bobhan1 Date: Wed, 22 Oct 2025 14:05:03 +0800 Subject: [PATCH 5/8] update --- .../olap/rowset/segment_v2/encoding_info.cpp | 60 ++++++++++++++++--- 1 file changed, 52 insertions(+), 8 deletions(-) diff --git a/be/src/olap/rowset/segment_v2/encoding_info.cpp b/be/src/olap/rowset/segment_v2/encoding_info.cpp index 58907966ccde55..723b3266233841 100644 --- a/be/src/olap/rowset/segment_v2/encoding_info.cpp +++ b/be/src/olap/rowset/segment_v2/encoding_info.cpp @@ -19,6 +19,7 @@ #include +#include #include #include #include @@ -323,24 +324,67 @@ bool is_integer_type(FieldType type) { type == FieldType::OLAP_FIELD_TYPE_SMALLINT || type == FieldType::OLAP_FIELD_TYPE_INT || type == FieldType::OLAP_FIELD_TYPE_BIGINT || type == FieldType::OLAP_FIELD_TYPE_LARGEINT; } + +bool is_binary_type(FieldType type) { + return type == FieldType::OLAP_FIELD_TYPE_CHAR || type == FieldType::OLAP_FIELD_TYPE_VARCHAR || + type == FieldType::OLAP_FIELD_TYPE_STRING || type == FieldType::OLAP_FIELD_TYPE_JSONB || + type == FieldType::OLAP_FIELD_TYPE_VARIANT || type == FieldType::OLAP_FIELD_TYPE_HLL || + type == FieldType::OLAP_FIELD_TYPE_BITMAP || + type == FieldType::OLAP_FIELD_TYPE_QUANTILE_STATE || + type == FieldType::OLAP_FIELD_TYPE_AGG_STATE; +} } // namespace EncodingTypePB EncodingInfoResolver::get_default_encoding(FieldType type, bool optimize_value_seek) const { + // Predicate for default encoding transformation + // Parameters: (type, current_default_encoding, optimize_value_seek) + // Returns: true if the transformation should be applied + using Predicate = std::function; + + // Hook for transforming default encoding: predicate -> target encoding + struct EncodingTransform { + Predicate predicate; + EncodingTypePB target_encoding; + }; + + // Static array of hooks for default encoding transformations + static const std::array hooks = { + // Hook 1: Binary types - PLAIN_ENCODING -> PLAIN_ENCODING_V2 + // Applies when: type is binary, encoding is PLAIN_ENCODING, and config enables v2 + EncodingTransform { + .predicate = + [](FieldType type, EncodingTypePB encoding, bool optimize_value_seek) { + return encoding == PLAIN_ENCODING && is_binary_type(type) && + config::binary_plain_encoding_default_impl == "v2"; + }, + .target_encoding = PLAIN_ENCODING_V2}, + + // Hook 2: Integer types - any encoding -> PLAIN_ENCODING + // Applies when: type is integer and config enables plain encoding for integers + EncodingTransform { + .predicate = + [](FieldType type, EncodingTypePB encoding, bool optimize_value_seek) { + return is_integer_type(type) && + config::integer_type_default_use_plain_encoding; + }, + .target_encoding = PLAIN_ENCODING}}; + auto& encoding_map = optimize_value_seek ? _value_seek_encoding_map : _default_encoding_type_map; auto it = encoding_map.find(type); if (it != encoding_map.end()) { EncodingTypePB encoding = it->second; - // For binary types, use PLAIN_ENCODING_V2 if config::binary_plain_encoding_default_impl is "v2" - if (encoding == PLAIN_ENCODING && config::binary_plain_encoding_default_impl == "v2" && - _encoding_map.contains(std::make_pair(type, PLAIN_ENCODING_V2))) { - return PLAIN_ENCODING_V2; - } - if (is_integer_type(type) && config::integer_type_default_use_plain_encoding && - _encoding_map.contains(std::make_pair(type, PLAIN_ENCODING))) { - return PLAIN_ENCODING; + // Apply hooks in order to transform the default encoding + for (const auto& hook : hooks) { + if (hook.predicate(type, encoding, optimize_value_seek)) { + // Verify target encoding is available for this type + if (_encoding_map.contains(std::make_pair(type, hook.target_encoding))) { + encoding = hook.target_encoding; + break; // Apply only the first matching hook + } + } } return encoding; From ac66f3c7dec45f524b6b234362bd393238fe0afd Mon Sep 17 00:00:00 2001 From: bobhan1 Date: Thu, 23 Oct 2025 11:08:41 +0800 Subject: [PATCH 6/8] fix --- be/src/olap/rowset/segment_v2/encoding_info.cpp | 2 +- be/src/olap/rowset/segment_v2/plain_page.h | 2 -- be/test/olap/rowset/segment_v2/encoding_info_test.cpp | 6 ++++-- .../suites/show_p0/test_show_data_warehouse.groovy | 7 +++++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/be/src/olap/rowset/segment_v2/encoding_info.cpp b/be/src/olap/rowset/segment_v2/encoding_info.cpp index 723b3266233841..31216c0e3fafff 100644 --- a/be/src/olap/rowset/segment_v2/encoding_info.cpp +++ b/be/src/olap/rowset/segment_v2/encoding_info.cpp @@ -349,7 +349,7 @@ EncodingTypePB EncodingInfoResolver::get_default_encoding(FieldType type, }; // Static array of hooks for default encoding transformations - static const std::array hooks = { + static const std::vector hooks = { // Hook 1: Binary types - PLAIN_ENCODING -> PLAIN_ENCODING_V2 // Applies when: type is binary, encoding is PLAIN_ENCODING, and config enables v2 EncodingTransform { diff --git a/be/src/olap/rowset/segment_v2/plain_page.h b/be/src/olap/rowset/segment_v2/plain_page.h index cd61e1a08dc12e..b311bab86e81c1 100644 --- a/be/src/olap/rowset/segment_v2/plain_page.h +++ b/be/src/olap/rowset/segment_v2/plain_page.h @@ -206,7 +206,6 @@ class PlainPageDecoder : public PageDecoder { Status next_batch(size_t* n, vectorized::MutableColumnPtr& dst) override { DCHECK(_parsed); if (*n == 0 || _cur_idx >= _num_elems) [[unlikely]] { - *n = 0; return Status::OK(); } @@ -225,7 +224,6 @@ class PlainPageDecoder : public PageDecoder { vectorized::MutableColumnPtr& dst) override { DCHECK(_parsed); if (*n == 0) [[unlikely]] { - *n = 0; return Status::OK(); } diff --git a/be/test/olap/rowset/segment_v2/encoding_info_test.cpp b/be/test/olap/rowset/segment_v2/encoding_info_test.cpp index ab0361cc270a2d..365722df4a4b60 100644 --- a/be/test/olap/rowset/segment_v2/encoding_info_test.cpp +++ b/be/test/olap/rowset/segment_v2/encoding_info_test.cpp @@ -109,13 +109,15 @@ TEST_F(EncodingInfoTest, test_use_plain_binary_v2_config) { const auto* bigint_type_info = get_scalar_type_info(); config::binary_plain_encoding_default_impl = "v1"; + auto expected_encoding = + (config::integer_type_default_use_plain_encoding) ? PLAIN_ENCODING : BIT_SHUFFLE; EncodingTypePB encoding_type = EncodingInfo::get_default_encoding(bigint_type_info->type(), false); - EXPECT_EQ(BIT_SHUFFLE, encoding_type); + EXPECT_EQ(expected_encoding, encoding_type); config::binary_plain_encoding_default_impl = "v2"; encoding_type = EncodingInfo::get_default_encoding(bigint_type_info->type(), false); - EXPECT_EQ(BIT_SHUFFLE, encoding_type); // Should remain BIT_SHUFFLE + EXPECT_EQ(expected_encoding, encoding_type); // Should remain BIT_SHUFFLE // Reset to default config::binary_plain_encoding_default_impl = "v1"; diff --git a/regression-test/suites/show_p0/test_show_data_warehouse.groovy b/regression-test/suites/show_p0/test_show_data_warehouse.groovy index 55388b17d8a4a3..8dadd0bb61a4db 100644 --- a/regression-test/suites/show_p0/test_show_data_warehouse.groovy +++ b/regression-test/suites/show_p0/test_show_data_warehouse.groovy @@ -88,17 +88,19 @@ suite("test_show_data_warehouse") { boolean hitDb1 = false; boolean hitDb2 = false; - long db1Size = 945 * replicaCount1 - long db2Size = 922 * replicaCount1 + long db1Size = 988 * replicaCount1 + long db2Size = 875 * replicaCount2 def result; do { current = System.currentTimeMillis() result = sql """ show data properties("entire_warehouse"="true","db_names"="${db1Name}"); """ + log.info("show data warehouse db1 result: ${result}"); if ((result.size() == 2) && result[0][1].toInteger() >= db1Size) { hitDb1 = true; } result = sql """ show data properties("entire_warehouse"="true","db_names"="${db2Name}"); """ + log.info("show data warehouse db2 result: ${result}"); if (result.size() == 2 && result[0][1].toInteger() >= db2Size) { hitDb2 = true; } @@ -112,6 +114,7 @@ suite("test_show_data_warehouse") { assertTrue((hitDb1 && hitDb2), "data size check fail after 1200s") result = sql """ show data properties("entire_warehouse"="true","db_names"="${db1Name},${db2Name}"); """ + log.info("show data warehouse db1 and db2 result: ${result}"); assertEquals(result.size(), 3) assert result[0][1].toInteger() >= db1Size assert result[1][1].toInteger() >= db2Size From 4c91ba26159f3ca110d87f675c8b14de84c356a6 Mon Sep 17 00:00:00 2001 From: bobhan1 Date: Thu, 23 Oct 2025 15:14:38 +0800 Subject: [PATCH 7/8] fix --- be/src/olap/rowset/segment_v2/plain_page.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/be/src/olap/rowset/segment_v2/plain_page.h b/be/src/olap/rowset/segment_v2/plain_page.h index b311bab86e81c1..a84a7a1a6630c6 100644 --- a/be/src/olap/rowset/segment_v2/plain_page.h +++ b/be/src/olap/rowset/segment_v2/plain_page.h @@ -25,6 +25,7 @@ #include "olap/types.h" #include "util/coding.h" #include "util/faststring.h" +#include "vec/common/unaligned.h" namespace doris { #include "common/compile_check_begin.h" @@ -33,7 +34,7 @@ namespace segment_v2 { static const size_t PLAIN_PAGE_HEADER_SIZE = sizeof(uint32_t); template -class PlainPageBuilder : public PageBuilderHelper > { +class PlainPageBuilder : public PageBuilderHelper> { public: using Self = PlainPageBuilder; friend class PageBuilderHelper; @@ -228,16 +229,20 @@ class PlainPageDecoder : public PageDecoder { } auto total = *n; - size_t read_count = 0; + auto read_count = 0; + _buffer.resize(total); for (size_t i = 0; i < total; ++i) { ordinal_t ord = rowids[i] - page_first_ordinal; if (UNLIKELY(ord >= _num_elems)) { break; } - const void* src_data = &_data[PLAIN_PAGE_HEADER_SIZE + ord * SIZE_OF_TYPE]; - dst->insert_data((const char*)src_data, SIZE_OF_TYPE); - read_count++; + _buffer[read_count++] = + unaligned_load(&_data[PLAIN_PAGE_HEADER_SIZE + ord * SIZE_OF_TYPE]); + } + + if (LIKELY(read_count > 0)) { + dst->insert_many_fix_len_data((char*)_buffer.data(), read_count); } *n = read_count; @@ -262,6 +267,8 @@ class PlainPageDecoder : public PageDecoder { uint32_t _cur_idx; typedef typename TypeTraits::CppType CppType; enum { SIZE_OF_TYPE = TypeTraits::size }; + + std::vector, uint8_t, CppType>> _buffer; }; } // namespace segment_v2 From 48d5ad545562a8a4f8e72f5970b719cc3ee7e717 Mon Sep 17 00:00:00 2001 From: bobhan1 Date: Sun, 26 Oct 2025 00:49:39 +0800 Subject: [PATCH 8/8] fix PlainPageBuilder::add --- be/src/olap/rowset/segment_v2/plain_page.h | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/be/src/olap/rowset/segment_v2/plain_page.h b/be/src/olap/rowset/segment_v2/plain_page.h index a84a7a1a6630c6..2065a5a899112a 100644 --- a/be/src/olap/rowset/segment_v2/plain_page.h +++ b/be/src/olap/rowset/segment_v2/plain_page.h @@ -42,24 +42,28 @@ class PlainPageBuilder : public PageBuilderHelper> { Status init() override { // Reserve enough space for the page, plus a bit of slop since // we often overrun the page by a few values. - RETURN_IF_CATCH_EXCEPTION(_buffer.reserve(_options.data_page_size + 1024)); + RETURN_IF_CATCH_EXCEPTION(_buffer.reserve(_options.data_page_size)); return reset(); } - bool is_page_full() override { return _buffer.size() > _options.data_page_size; } + bool is_page_full() override { return _remain_element_capacity == 0; } Status add(const uint8_t* vals, size_t* count) override { - if (is_page_full()) { + if (is_page_full() || *count == 0) { *count = 0; return Status::OK(); } size_t old_size = _buffer.size(); + size_t to_add = std::min(_remain_element_capacity, *count); // This may need a large memory, should return error if could not allocated // successfully, to avoid BE OOM. - RETURN_IF_CATCH_EXCEPTION(_buffer.resize(old_size + *count * SIZE_OF_TYPE)); - memcpy(&_buffer[old_size], vals, *count * SIZE_OF_TYPE); - _count += *count; - _raw_data_size += *count * SIZE_OF_TYPE; + RETURN_IF_CATCH_EXCEPTION(_buffer.resize(old_size + to_add * SIZE_OF_TYPE)); + memcpy(&_buffer[old_size], vals, to_add * SIZE_OF_TYPE); + _count += to_add; + _raw_data_size += to_add * SIZE_OF_TYPE; + + *count = to_add; + _remain_element_capacity -= to_add; return Status::OK(); } @@ -79,11 +83,12 @@ class PlainPageBuilder : public PageBuilderHelper> { Status reset() override { RETURN_IF_CATCH_EXCEPTION({ - _buffer.reserve(_options.data_page_size + 1024); + _buffer.reserve(_options.data_page_size); _count = 0; _raw_data_size = 0; _buffer.clear(); _buffer.resize(PLAIN_PAGE_HEADER_SIZE); + _remain_element_capacity = _options.data_page_size / SIZE_OF_TYPE; }); return Status::OK(); } @@ -116,6 +121,7 @@ class PlainPageBuilder : public PageBuilderHelper> { faststring _buffer; PageBuilderOptions _options; size_t _count; + size_t _remain_element_capacity {0}; uint64_t _raw_data_size = 0; typedef typename TypeTraits::CppType CppType; enum { SIZE_OF_TYPE = TypeTraits::size };