[Fix](status)Fix leaky abstraction and shield the status code END_OF_FILE from upper layers (#24165)

This commit is contained in:
bobhan1
2023-09-12 11:10:52 +08:00
committed by GitHub
parent 7aa8cdc1d4
commit bdacefa734
5 changed files with 15 additions and 5 deletions

View File

@ -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"

View File

@ -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;
}
}
}

View File

@ -363,8 +363,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();

View File

@ -2835,7 +2835,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>()) {

View File

@ -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<ErrorCode::END_OF_FILE>());
EXPECT_TRUE(status.is<ErrorCode::ENTRY_NOT_FOUND>());
}
// read all key