Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 5 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions be/src/olap/delete_bitmap_calculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
8 changes: 7 additions & 1 deletion be/src/olap/rowset/segment_v2/binary_prefix_page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>()) {
Copy link
Contributor

@liaoxin01 liaoxin01 Sep 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it have an impact on other users of this code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
only IndexedColumnIterator::seek_at_or_after may call BinaryPrefixPageDecoder::seek_at_or_after_value

return Status::Error<ErrorCode::ENTRY_NOT_FOUND>("all value small than the value");
}
if (!st.ok()) {
return st;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should return a Status::OK() at the end of this method?

}

Expand Down
7 changes: 5 additions & 2 deletions be/src/olap/rowset/segment_v2/segment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,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();
Expand Down
2 changes: 1 addition & 1 deletion be/src/olap/tablet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>()) {
Expand Down
2 changes: 1 addition & 1 deletion be/test/olap/primary_key_index_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down