From 6ec8cdcf859153252560a2b1fe3b29791b13e96f Mon Sep 17 00:00:00 2001 From: bobhan1 Date: Mon, 11 Sep 2023 10:57:25 +0800 Subject: [PATCH 1/5] fix status --- be/src/olap/delete_bitmap_calculator.cpp | 2 +- be/src/olap/rowset/segment_v2/indexed_column_reader.cpp | 2 +- be/src/olap/rowset/segment_v2/segment_iterator.cpp | 2 +- be/src/olap/tablet.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/be/src/olap/delete_bitmap_calculator.cpp b/be/src/olap/delete_bitmap_calculator.cpp index bfdb506c066e6b..598157a0d70fbb 100644 --- a/be/src/olap/delete_bitmap_calculator.cpp +++ b/be/src/olap/delete_bitmap_calculator.cpp @@ -46,7 +46,7 @@ Status MergeIndexDeleteBitmapCalculatorContext::advance() { Status MergeIndexDeleteBitmapCalculatorContext::seek_at_or_after(Slice const& key) { auto st = _iter->seek_at_or_after(&key, &_excat_match); - if (st.is()) { + if (st.is()) { return Status::EndOfFile("Reach the end of file"); } RETURN_IF_ERROR(st); diff --git a/be/src/olap/rowset/segment_v2/indexed_column_reader.cpp b/be/src/olap/rowset/segment_v2/indexed_column_reader.cpp index 9cc79cb5437242..ba7f45ed61e6c2 100644 --- a/be/src/olap/rowset/segment_v2/indexed_column_reader.cpp +++ b/be/src/olap/rowset/segment_v2/indexed_column_reader.cpp @@ -242,7 +242,7 @@ Status IndexedColumnIterator::seek_at_or_after(const void* key, bool* exact_matc // seek inside data page Status st = _data_page.data_decoder->seek_at_or_after_value(key, exact_match); // return the first row of next page when not found - if (st.is() && _reader->_has_index_page) { + if ((st.is() || st.is()) && _reader->_has_index_page) { if (_value_iter.has_next()) { _seeked = true; *exact_match = false; diff --git a/be/src/olap/rowset/segment_v2/segment_iterator.cpp b/be/src/olap/rowset/segment_v2/segment_iterator.cpp index 067ec476760a9a..674d9c062ce36a 100644 --- a/be/src/olap/rowset/segment_v2/segment_iterator.cpp +++ b/be/src/olap/rowset/segment_v2/segment_iterator.cpp @@ -1185,7 +1185,7 @@ Status SegmentIterator::_lookup_ordinal_from_pk_index(const RowCursor& key, bool Status status = index_iterator->seek_at_or_after(&index_key, &exact_match); if (UNLIKELY(!status.ok())) { *rowid = num_rows(); - if (status.is()) { + if (status.is()) { return Status::OK(); } return status; diff --git a/be/src/olap/tablet.cpp b/be/src/olap/tablet.cpp index 7c737e4d3c0118..cac5b1d7be6980 100644 --- a/be/src/olap/tablet.cpp +++ b/be/src/olap/tablet.cpp @@ -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() || s.is()) { + if (s.is() || s.is() || s.is()) { continue; } if (!s.ok() && !s.is()) { From a79251ab6ca8c9fa6efdd6973a7f56c62072440a Mon Sep 17 00:00:00 2001 From: bobhan1 Date: Mon, 11 Sep 2023 14:59:44 +0800 Subject: [PATCH 2/5] update --- be/src/olap/rowset/segment_v2/binary_prefix_page.cpp | 6 +++++- be/src/olap/rowset/segment_v2/indexed_column_reader.cpp | 2 +- 2 files changed, 6 insertions(+), 2 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 ab9056def1b9b3..1bc2f1afccef77 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,11 @@ 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()) { + return Status::Error("all value small than the value"); + } + RETURN_IF_ERROR(st); } } diff --git a/be/src/olap/rowset/segment_v2/indexed_column_reader.cpp b/be/src/olap/rowset/segment_v2/indexed_column_reader.cpp index ba7f45ed61e6c2..9cc79cb5437242 100644 --- a/be/src/olap/rowset/segment_v2/indexed_column_reader.cpp +++ b/be/src/olap/rowset/segment_v2/indexed_column_reader.cpp @@ -242,7 +242,7 @@ Status IndexedColumnIterator::seek_at_or_after(const void* key, bool* exact_matc // seek inside data page Status st = _data_page.data_decoder->seek_at_or_after_value(key, exact_match); // return the first row of next page when not found - if ((st.is() || st.is()) && _reader->_has_index_page) { + if (st.is() && _reader->_has_index_page) { if (_value_iter.has_next()) { _seeked = true; *exact_match = false; From 1ce260cbfdabdfbe92b7994ec1baae60656b83e5 Mon Sep 17 00:00:00 2001 From: bobhan1 Date: Mon, 11 Sep 2023 15:06:41 +0800 Subject: [PATCH 3/5] update --- be/src/olap/delete_bitmap_calculator.cpp | 3 ++- be/src/olap/rowset/segment_v2/binary_prefix_page.cpp | 4 +++- be/src/olap/rowset/segment_v2/segment_iterator.cpp | 2 +- be/src/olap/tablet.cpp | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/be/src/olap/delete_bitmap_calculator.cpp b/be/src/olap/delete_bitmap_calculator.cpp index 598157a0d70fbb..a370f0c06bf8e7 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" @@ -46,7 +47,7 @@ Status MergeIndexDeleteBitmapCalculatorContext::advance() { Status MergeIndexDeleteBitmapCalculatorContext::seek_at_or_after(Slice const& key) { auto st = _iter->seek_at_or_after(&key, &_excat_match); - if (st.is()) { + if (st.is()) { return Status::EndOfFile("Reach the end of file"); } RETURN_IF_ERROR(st); 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 1bc2f1afccef77..183e7bb0853440 100644 --- a/be/src/olap/rowset/segment_v2/binary_prefix_page.cpp +++ b/be/src/olap/rowset/segment_v2/binary_prefix_page.cpp @@ -206,7 +206,9 @@ Status BinaryPrefixPageDecoder::seek_at_or_after_value(const void* value, bool* if (st.is()) { return Status::Error("all value small than the value"); } - RETURN_IF_ERROR(st); + if (!st.ok()) { + return st; + } } } diff --git a/be/src/olap/rowset/segment_v2/segment_iterator.cpp b/be/src/olap/rowset/segment_v2/segment_iterator.cpp index 674d9c062ce36a..067ec476760a9a 100644 --- a/be/src/olap/rowset/segment_v2/segment_iterator.cpp +++ b/be/src/olap/rowset/segment_v2/segment_iterator.cpp @@ -1185,7 +1185,7 @@ Status SegmentIterator::_lookup_ordinal_from_pk_index(const RowCursor& key, bool Status status = index_iterator->seek_at_or_after(&index_key, &exact_match); if (UNLIKELY(!status.ok())) { *rowid = num_rows(); - if (status.is()) { + if (status.is()) { return Status::OK(); } return status; diff --git a/be/src/olap/tablet.cpp b/be/src/olap/tablet.cpp index cac5b1d7be6980..7c737e4d3c0118 100644 --- a/be/src/olap/tablet.cpp +++ b/be/src/olap/tablet.cpp @@ -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() || s.is() || s.is()) { + if (s.is() || s.is()) { continue; } if (!s.ok() && !s.is()) { From fda577651600de7db5b874f1d3178c479dd5fc8c Mon Sep 17 00:00:00 2001 From: bobhan1 Date: Mon, 11 Sep 2023 15:42:21 +0800 Subject: [PATCH 4/5] update --- be/test/olap/primary_key_index_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/be/test/olap/primary_key_index_test.cpp b/be/test/olap/primary_key_index_test.cpp index 46b87b712da23f..42abaeadb1f555 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 From 746dd12d4ededf80d2e2bf4b7501521d3fd0a66d Mon Sep 17 00:00:00 2001 From: bobhan1 Date: Mon, 11 Sep 2023 18:40:26 +0800 Subject: [PATCH 5/5] update --- be/src/olap/rowset/segment_v2/segment.cpp | 7 +++++-- be/src/olap/tablet.cpp | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/be/src/olap/rowset/segment_v2/segment.cpp b/be/src/olap/rowset/segment_v2/segment.cpp index 7eb660b3c26a7d..3c565a0d014807 100644 --- a/be/src/olap/rowset/segment_v2/segment.cpp +++ b/be/src/olap/rowset/segment_v2/segment.cpp @@ -357,8 +357,11 @@ Status Segment::lookup_row_key(const Slice& key, bool with_seq_col, RowLocation* bool exact_match = false; std::unique_ptr 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()) { + return st; + } + if (st.is() || (!has_seq_col && !exact_match)) { return Status::Error("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 7c737e4d3c0118..2ef732f2b49bc0 100644 --- a/be/src/olap/tablet.cpp +++ b/be/src/olap/tablet.cpp @@ -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() || s.is()) { + if (s.is()) { continue; } if (!s.ok() && !s.is()) {