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 e3e893a0ddd6c4..ab9056def1b9b3 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 #include +#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 837d2587007744..46b87b712da23f 100644 --- a/be/test/olap/primary_key_index_test.cpp +++ b/be/test/olap/primary_key_index_test.cpp @@ -129,7 +129,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()); + EXPECT_TRUE(status.is()); } // read all key