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 7e378177657b480aba4ac74a6e5d7fec71d565ac Author: bobhan1 <bh2444151...@outlook.com> AuthorDate: Tue Sep 12 11:10:52 2023 +0800 [Fix](status)Fix leaky abstraction and shield the status code `END_OF_FILE` from upper layers (#24165) --- be/src/olap/delete_bitmap_calculator.cpp | 1 + be/src/olap/rowset/segment_v2/binary_prefix_page.cpp | 8 +++++++- be/src/olap/rowset/segment_v2/segment.cpp | 7 +++++-- be/src/olap/tablet.cpp | 2 +- be/test/olap/primary_key_index_test.cpp | 2 +- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/be/src/olap/delete_bitmap_calculator.cpp b/be/src/olap/delete_bitmap_calculator.cpp index bfdb506c06..a370f0c06b 100644 --- a/be/src/olap/delete_bitmap_calculator.cpp +++ b/be/src/olap/delete_bitmap_calculator.cpp @@ -17,6 +17,7 @@ #include "olap/delete_bitmap_calculator.h" +#include "common/status.h" #include "olap/primary_key_index.h" #include "vec/data_types/data_type_factory.hpp" 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 ab9056def1..183e7bb085 100644 --- a/be/src/olap/rowset/segment_v2/binary_prefix_page.cpp +++ b/be/src/olap/rowset/segment_v2/binary_prefix_page.cpp @@ -202,7 +202,13 @@ Status BinaryPrefixPageDecoder::seek_at_or_after_value(const void* value, bool* return Status::OK(); } _cur_pos++; - RETURN_IF_ERROR(_read_next_value()); + auto st = _read_next_value(); + if (st.is<ErrorCode::END_OF_FILE>()) { + return Status::Error<ErrorCode::ENTRY_NOT_FOUND>("all value small than the value"); + } + if (!st.ok()) { + return st; + } } } diff --git a/be/src/olap/rowset/segment_v2/segment.cpp b/be/src/olap/rowset/segment_v2/segment.cpp index 195b40fa83..0e2d6a6e3e 100644 --- a/be/src/olap/rowset/segment_v2/segment.cpp +++ b/be/src/olap/rowset/segment_v2/segment.cpp @@ -373,8 +373,11 @@ Status Segment::lookup_row_key(const Slice& key, bool with_seq_col, RowLocation* bool exact_match = false; std::unique_ptr<segment_v2::IndexedColumnIterator> index_iterator; RETURN_IF_ERROR(_pk_index_reader->new_iterator(&index_iterator)); - RETURN_IF_ERROR(index_iterator->seek_at_or_after(&key_without_seq, &exact_match)); - if (!has_seq_col && !exact_match) { + auto st = index_iterator->seek_at_or_after(&key_without_seq, &exact_match); + if (!st.ok() && !st.is<ErrorCode::ENTRY_NOT_FOUND>()) { + return st; + } + if (st.is<ErrorCode::ENTRY_NOT_FOUND>() || (!has_seq_col && !exact_match)) { return Status::Error<ErrorCode::KEY_NOT_FOUND>("Can't find key in the segment"); } row_location->row_id = index_iterator->get_current_ordinal(); diff --git a/be/src/olap/tablet.cpp b/be/src/olap/tablet.cpp index 71da59808e..c732b200f7 100644 --- a/be/src/olap/tablet.cpp +++ b/be/src/olap/tablet.cpp @@ -2832,7 +2832,7 @@ Status Tablet::lookup_row_key(const Slice& encoded_key, bool with_seq_col, for (auto id : picked_segments) { Status s = segments[id]->lookup_row_key(encoded_key, with_seq_col, &loc); - if (s.is<ENTRY_NOT_FOUND>() || s.is<KEY_NOT_FOUND>()) { + if (s.is<KEY_NOT_FOUND>()) { continue; } if (!s.ok() && !s.is<KEY_ALREADY_EXISTS>()) { diff --git a/be/test/olap/primary_key_index_test.cpp b/be/test/olap/primary_key_index_test.cpp index 37189f22ec..d643ab501e 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<ErrorCode::END_OF_FILE>()); + EXPECT_TRUE(status.is<ErrorCode::ENTRY_NOT_FOUND>()); } // read all key --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org