This is an automated email from the ASF dual-hosted git repository. kxiao pushed a commit to branch branch-2.0 in repository https://gitbox.apache.org/repos/asf/doris.git
commit 2fa15cce135f4a3f03e365a2b5646987210b2777 Author: bobhan1 <bh2444151...@outlook.com> AuthorDate: Wed Sep 6 16:34:38 2023 +0800 [Fix](BinaryPrefixPage) stop to read values when current pos reached the end of the page in `BinaryPrefixPageDecoder::next_batch` (#23855) --- be/src/olap/rowset/segment_v2/binary_prefix_page.cpp | 9 +++++++-- be/test/olap/primary_key_index_test.cpp | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/be/src/olap/rowset/segment_v2/binary_prefix_page.cpp b/be/src/olap/rowset/segment_v2/binary_prefix_page.cpp index e3e893a0dd..ab9056def1 100644 --- a/be/src/olap/rowset/segment_v2/binary_prefix_page.cpp +++ b/be/src/olap/rowset/segment_v2/binary_prefix_page.cpp @@ -23,6 +23,7 @@ #include <algorithm> #include <vector> +#include "common/status.h" #include "gutil/port.h" #include "gutil/strings/substitute.h" #include "util/coding.h" @@ -114,12 +115,13 @@ const uint8_t* BinaryPrefixPageDecoder::_decode_value_lengths(const uint8_t* ptr Status BinaryPrefixPageDecoder::_read_next_value() { if (_cur_pos >= _num_values) { - return Status::NotFound("no more value to read"); + return Status::EndOfFile("no more value to read"); } uint32_t shared_len; uint32_t non_shared_len; auto data_ptr = _decode_value_lengths(_next_ptr, &shared_len, &non_shared_len); if (data_ptr == nullptr) { + DCHECK(false) << "[BinaryPrefixPageDecoder::_read_next_value] corruption!"; return Status::Corruption("Failed to decode value at position {}", _cur_pos); } _current_value.resize(shared_len); @@ -215,8 +217,11 @@ Status BinaryPrefixPageDecoder::next_batch(size_t* n, vectorized::MutableColumnP // read and copy values for (size_t i = 0; i < max_fetch; ++i) { dst->insert_data((char*)(_current_value.data()), _current_value.size()); - _read_next_value(); _cur_pos++; + // reach the end of the page, should not read the next value + if (_cur_pos < _num_values) { + RETURN_IF_ERROR(_read_next_value()); + } } *n = max_fetch; diff --git a/be/test/olap/primary_key_index_test.cpp b/be/test/olap/primary_key_index_test.cpp index 66b33a607d..37189f22ec 100644 --- a/be/test/olap/primary_key_index_test.cpp +++ b/be/test/olap/primary_key_index_test.cpp @@ -128,7 +128,7 @@ TEST_F(PrimaryKeyIndexTest, builder) { EXPECT_FALSE(exists); auto status = index_iterator->seek_at_or_after(&slice, &exact_match); EXPECT_FALSE(exact_match); - EXPECT_TRUE(status.is<NOT_FOUND>()); + EXPECT_TRUE(status.is<ErrorCode::END_OF_FILE>()); } // read all key --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org