diff --git a/be/src/common/status.h b/be/src/common/status.h index d74758ddf97c3b..2b6b639b043462 100644 --- a/be/src/common/status.h +++ b/be/src/common/status.h @@ -273,6 +273,7 @@ E(INVERTED_INDEX_EVALUATE_SKIPPED, -6007); E(INVERTED_INDEX_BUILD_WAITTING, -6008); E(KEY_NOT_FOUND, -6009); E(KEY_ALREADY_EXISTS, -6010); +E(ENTRY_NOT_FOUND, -6011); #undef E } // namespace ErrorCode @@ -311,6 +312,7 @@ constexpr bool capture_stacktrace(int code) { && code != ErrorCode::TRANSACTION_ALREADY_VISIBLE && code != ErrorCode::TOO_MANY_TRANSACTIONS && code != ErrorCode::TRANSACTION_ALREADY_COMMITTED + && code != ErrorCode::ENTRY_NOT_FOUND && code != ErrorCode::KEY_NOT_FOUND && code != ErrorCode::KEY_ALREADY_EXISTS && code != ErrorCode::CANCELLED diff --git a/be/src/olap/delete_bitmap_calculator.cpp b/be/src/olap/delete_bitmap_calculator.cpp index 46929a59c0dd20..bfdb506c066e6b 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/binary_dict_page.cpp b/be/src/olap/rowset/segment_v2/binary_dict_page.cpp index 94057fe5daeb4d..f075a5a2083de5 100644 --- a/be/src/olap/rowset/segment_v2/binary_dict_page.cpp +++ b/be/src/olap/rowset/segment_v2/binary_dict_page.cpp @@ -26,6 +26,7 @@ // IWYU pragma: no_include #include "common/compiler_util.h" // IWYU pragma: keep #include "common/logging.h" +#include "common/status.h" #include "gutil/casts.h" #include "gutil/port.h" #include "gutil/strings/substitute.h" // for Substitute @@ -179,7 +180,7 @@ Status BinaryDictPageBuilder::get_dictionary_page(OwnedSlice* dictionary_page) { Status BinaryDictPageBuilder::get_first_value(void* value) const { DCHECK(_finished); if (_data_page_builder->count() == 0) { - return Status::NotFound("page is empty"); + return Status::Error("page is empty"); } if (_encoding_type != DICT_ENCODING) { return _data_page_builder->get_first_value(value); @@ -191,7 +192,7 @@ Status BinaryDictPageBuilder::get_first_value(void* value) const { Status BinaryDictPageBuilder::get_last_value(void* value) const { DCHECK(_finished); if (_data_page_builder->count() == 0) { - return Status::NotFound("page is empty"); + return Status::Error("page is empty"); } if (_encoding_type != DICT_ENCODING) { return _data_page_builder->get_last_value(value); diff --git a/be/src/olap/rowset/segment_v2/binary_plain_page.h b/be/src/olap/rowset/segment_v2/binary_plain_page.h index f16039c09958bb..1a48894c977863 100644 --- a/be/src/olap/rowset/segment_v2/binary_plain_page.h +++ b/be/src/olap/rowset/segment_v2/binary_plain_page.h @@ -124,7 +124,7 @@ class BinaryPlainPageBuilder : public PageBuilder { Status get_first_value(void* value) const override { DCHECK(_finished); if (_offsets.size() == 0) { - return Status::NotFound("page is empty"); + return Status::Error("page is empty"); } *reinterpret_cast(value) = Slice(_first_value); return Status::OK(); @@ -132,7 +132,7 @@ class BinaryPlainPageBuilder : public PageBuilder { Status get_last_value(void* value) const override { DCHECK(_finished); if (_offsets.size() == 0) { - return Status::NotFound("page is empty"); + return Status::Error("page is empty"); } *reinterpret_cast(value) = Slice(_last_value); return Status::OK(); diff --git a/be/src/olap/rowset/segment_v2/binary_prefix_page.h b/be/src/olap/rowset/segment_v2/binary_prefix_page.h index b6ca02190f08b5..26bdb1518d5ed5 100644 --- a/be/src/olap/rowset/segment_v2/binary_prefix_page.h +++ b/be/src/olap/rowset/segment_v2/binary_prefix_page.h @@ -72,7 +72,7 @@ class BinaryPrefixPageBuilder : public PageBuilder { Status get_first_value(void* value) const override { DCHECK(_finished); if (_count == 0) { - return Status::NotFound("page is empty"); + return Status::Error("page is empty"); } *reinterpret_cast(value) = Slice(_first_entry); return Status::OK(); @@ -81,7 +81,7 @@ class BinaryPrefixPageBuilder : public PageBuilder { Status get_last_value(void* value) const override { DCHECK(_finished); if (_count == 0) { - return Status::NotFound("page is empty"); + return Status::Error("page is empty"); } *reinterpret_cast(value) = Slice(_last_entry); return Status::OK(); @@ -137,7 +137,7 @@ class BinaryPrefixPageDecoder : public PageDecoder { // read next value at `_cur_pos` and `_next_ptr` into `_current_value`. // return OK and advance `_next_ptr` on success. `_cur_pos` is not modified. - // return NotFound when no more entry can be read. + // return EndOfFile when no more entry can be read. // return other error status otherwise. Status _read_next_value(); diff --git a/be/src/olap/rowset/segment_v2/bitmap_index_reader.h b/be/src/olap/rowset/segment_v2/bitmap_index_reader.h index 1ac16439891c37..6f1687354c248b 100644 --- a/be/src/olap/rowset/segment_v2/bitmap_index_reader.h +++ b/be/src/olap/rowset/segment_v2/bitmap_index_reader.h @@ -86,7 +86,7 @@ class BitmapIndexIterator { // by `current_ordinal()`, *exact_match is set to indicate whether the // seeked value exactly matches `value` or not // - // Returns NotFound when no such value exists (all values in dictionary < `value`). + // Returns Status::Error when no such value exists (all values in dictionary < `value`). // Returns other error status otherwise. Status seek_dictionary(const void* value, bool* exact_match); diff --git a/be/src/olap/rowset/segment_v2/bitshuffle_page.h b/be/src/olap/rowset/segment_v2/bitshuffle_page.h index 657a34e7c19615..1d22b76b8077c6 100644 --- a/be/src/olap/rowset/segment_v2/bitshuffle_page.h +++ b/be/src/olap/rowset/segment_v2/bitshuffle_page.h @@ -168,7 +168,7 @@ class BitshufflePageBuilder : public PageBuilder { Status get_first_value(void* value) const override { DCHECK(_finished); if (_count == 0) { - return Status::NotFound("page is empty"); + return Status::Error("page is empty"); } memcpy(value, &_first_value, SIZE_OF_TYPE); return Status::OK(); @@ -176,7 +176,7 @@ class BitshufflePageBuilder : public PageBuilder { Status get_last_value(void* value) const override { DCHECK(_finished); if (_count == 0) { - return Status::NotFound("page is empty"); + return Status::Error("page is empty"); } memcpy(value, &_last_value, SIZE_OF_TYPE); return Status::OK(); @@ -332,7 +332,7 @@ class BitShufflePageDecoder : public PageDecoder { DCHECK(_parsed) << "Must call init() firstly"; if (_num_elements == 0) { - return Status::NotFound("page is empty"); + return Status::Error("page is empty"); } size_t left = 0; @@ -353,7 +353,7 @@ class BitShufflePageDecoder : public PageDecoder { } } if (left >= _num_elements) { - return Status::NotFound("all value small than the value"); + return Status::Error("all value small than the value"); } void* find_value = get_data(left); if (TypeTraits::cmp(find_value, value) == 0) { diff --git a/be/src/olap/rowset/segment_v2/frame_of_reference_page.h b/be/src/olap/rowset/segment_v2/frame_of_reference_page.h index ad1e0bc5410735..64e57afa988250 100644 --- a/be/src/olap/rowset/segment_v2/frame_of_reference_page.h +++ b/be/src/olap/rowset/segment_v2/frame_of_reference_page.h @@ -70,7 +70,7 @@ class FrameOfReferencePageBuilder : public PageBuilder { Status get_first_value(void* value) const override { if (_count == 0) { - return Status::NotFound("page is empty"); + return Status::Error("page is empty"); } memcpy(value, &_first_val, sizeof(CppType)); return Status::OK(); @@ -78,7 +78,7 @@ class FrameOfReferencePageBuilder : public PageBuilder { Status get_last_value(void* value) const override { if (_count == 0) { - return Status::NotFound("page is empty"); + return Status::Error("page is empty"); } memcpy(value, &_last_val, sizeof(CppType)); return Status::OK(); @@ -135,7 +135,7 @@ class FrameOfReferencePageDecoder : public PageDecoder { DCHECK(_parsed) << "Must call init() firstly"; bool found = _decoder->seek_at_or_after_value(value, exact_match); if (!found) { - return Status::NotFound("not found"); + return Status::Error("not found"); } _cur_index = _decoder->current_index(); return Status::OK(); diff --git a/be/src/olap/rowset/segment_v2/index_page.cpp b/be/src/olap/rowset/segment_v2/index_page.cpp index 3b8bc03977d7b5..9af7047c49b39a 100644 --- a/be/src/olap/rowset/segment_v2/index_page.cpp +++ b/be/src/olap/rowset/segment_v2/index_page.cpp @@ -52,7 +52,7 @@ void IndexPageBuilder::finish(OwnedSlice* body, PageFooterPB* footer) { Status IndexPageBuilder::get_first_key(Slice* key) const { if (_count == 0) { - return Status::NotFound("index page is empty"); + return Status::Error("index page is empty"); } Slice input(_buffer); if (get_length_prefixed_slice(&input, key)) { @@ -105,7 +105,8 @@ Status IndexPageIterator::seek_at_or_before(const Slice& search_key) { // no exact match, the insertion point is `left` if (left == 0) { // search key is smaller than all keys - return Status::NotFound("given key is smaller than all keys in page"); + return Status::Error( + "given key is smaller than all keys in page"); } // index entry records the first key of the indexed page, // therefore the first page with keys >= searched key is the one before the insertion point diff --git a/be/src/olap/rowset/segment_v2/index_page.h b/be/src/olap/rowset/segment_v2/index_page.h index 106fc0ffc5fd10..c889d0fb1613d1 100644 --- a/be/src/olap/rowset/segment_v2/index_page.h +++ b/be/src/olap/rowset/segment_v2/index_page.h @@ -123,7 +123,7 @@ class IndexPageIterator { // Find the largest index entry whose key is <= search_key. // Return OK status when such entry exists. - // Return NotFound when no such entry is found (all keys > search_key). + // Return ENTRY_NOT_FOUND when no such entry is found (all keys > search_key). // Return other error status otherwise. Status seek_at_or_before(const Slice& search_key); 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 d5a84a4c9c72cb..9cc79cb5437242 100644 --- a/be/src/olap/rowset/segment_v2/indexed_column_reader.cpp +++ b/be/src/olap/rowset/segment_v2/indexed_column_reader.cpp @@ -21,6 +21,7 @@ #include +#include "common/status.h" #include "gutil/strings/substitute.h" // for Substitute #include "olap/key_coder.h" #include "olap/olap_common.h" @@ -200,7 +201,7 @@ Status IndexedColumnIterator::seek_at_or_after(const void* key, bool* exact_matc } if (_reader->num_values() == 0) { - return Status::NotFound("value index is empty "); + return Status::Error("value index is empty "); } g_index_reader_seek_count << 1; @@ -212,11 +213,11 @@ Status IndexedColumnIterator::seek_at_or_after(const void* key, bool* exact_matc std::string encoded_key; _reader->_value_key_coder->full_encode_ascending(key, &encoded_key); Status st = _value_iter.seek_at_or_before(encoded_key); - if (st.is()) { + if (st.is()) { // all keys in page is greater than `encoded_key`, point to the first page. // otherwise, we may missing some pages. // For example, the predicate is `col1 > 2`, and the index page is [3,5,7]. - // so the `seek_at_or_before(2)` will return Status::NotFound(). + // so the `seek_at_or_before(2)` will return Status::Error(). // But actually, we expect it to point to page `3`. _value_iter.seek_to_first(); } else if (!st.ok()) { @@ -241,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() && _reader->_has_index_page) { if (_value_iter.has_next()) { _seeked = true; *exact_match = false; diff --git a/be/src/olap/rowset/segment_v2/indexed_column_reader.h b/be/src/olap/rowset/segment_v2/indexed_column_reader.h index b49dc0f18b21c7..6399176e15f726 100644 --- a/be/src/olap/rowset/segment_v2/indexed_column_reader.h +++ b/be/src/olap/rowset/segment_v2/indexed_column_reader.h @@ -103,7 +103,7 @@ class IndexedColumnIterator { _value_iter(&reader->_value_index_reader) {} // Seek to the given ordinal entry. Entry 0 is the first entry. - // Return NotFound if provided seek point is past the end. + // Return Status::Error if provided seek point is past the end. // Return NotSupported for column without ordinal index. Status seek_to_ordinal(ordinal_t idx); @@ -114,7 +114,7 @@ class IndexedColumnIterator { // Sets *exact_match to indicate whether the seek found the exact // key requested. // - // Return NotFound if the given key is greater than all keys in this column. + // Return Status::Error if the given key is greater than all keys in this column. // Return NotSupported for column without value index. Status seek_at_or_after(const void* key, bool* exact_match); Status seek_at_or_after(const std::string* key, bool* exact_match) { diff --git a/be/src/olap/rowset/segment_v2/page_builder.h b/be/src/olap/rowset/segment_v2/page_builder.h index ab74ad7fcaed9d..5df2ce949b9b39 100644 --- a/be/src/olap/rowset/segment_v2/page_builder.h +++ b/be/src/olap/rowset/segment_v2/page_builder.h @@ -79,12 +79,12 @@ class PageBuilder { // Return the first value in this page. // This method could only be called between finish() and reset(). - // Status::NotFound if no values have been added. + // Status::Error if no values have been added. virtual Status get_first_value(void* value) const = 0; // Return the last value in this page. // This method could only be called between finish() and reset(). - // Status::NotFound if no values have been added. + // Status::Error if no values have been added. virtual Status get_last_value(void* value) const = 0; private: diff --git a/be/src/olap/rowset/segment_v2/page_decoder.h b/be/src/olap/rowset/segment_v2/page_decoder.h index e1aef24e4e6cae..c059ac4b83acfc 100644 --- a/be/src/olap/rowset/segment_v2/page_decoder.h +++ b/be/src/olap/rowset/segment_v2/page_decoder.h @@ -52,7 +52,7 @@ class PageDecoder { // // If the given value is less than the lowest value in the page, // seeks to the start of the page. If it is higher than the highest - // value in the page, then returns Status::NotFound + // value in the page, then returns Status::Error // // This will only return valid results when the data page // consists of values in sorted order. diff --git a/be/src/olap/rowset/segment_v2/plain_page.h b/be/src/olap/rowset/segment_v2/plain_page.h index bd2e9747097054..ca2029245aeb22 100644 --- a/be/src/olap/rowset/segment_v2/plain_page.h +++ b/be/src/olap/rowset/segment_v2/plain_page.h @@ -77,7 +77,7 @@ class PlainPageBuilder : public PageBuilder { Status get_first_value(void* value) const override { if (_count == 0) { - return Status::NotFound("page is empty"); + return Status::Error("page is empty"); } memcpy(value, _first_value.data(), SIZE_OF_TYPE); return Status::OK(); @@ -85,7 +85,7 @@ class PlainPageBuilder : public PageBuilder { Status get_last_value(void* value) const override { if (_count == 0) { - return Status::NotFound("page is empty"); + return Status::Error("page is empty"); } memcpy(value, _last_value.data(), SIZE_OF_TYPE); return Status::OK(); @@ -147,7 +147,7 @@ class PlainPageDecoder : public PageDecoder { DCHECK(_parsed) << "Must call init() firstly"; if (_num_elems == 0) { - return Status::NotFound("page is empty"); + return Status::Error("page is empty"); } size_t left = 0; @@ -168,7 +168,7 @@ class PlainPageDecoder : public PageDecoder { } } if (left >= _num_elems) { - return Status::NotFound("all value small than the value"); + return Status::Error("all value small than the value"); } const void* find_value = &_data[PLAIN_PAGE_HEADER_SIZE + left * SIZE_OF_TYPE]; if (TypeTraits::cmp(find_value, value) == 0) { diff --git a/be/src/olap/rowset/segment_v2/rle_page.h b/be/src/olap/rowset/segment_v2/rle_page.h index bae694dbfcc8aa..7f98b6e76f8f5b 100644 --- a/be/src/olap/rowset/segment_v2/rle_page.h +++ b/be/src/olap/rowset/segment_v2/rle_page.h @@ -116,7 +116,7 @@ class RlePageBuilder : public PageBuilder { Status get_first_value(void* value) const override { DCHECK(_finished); if (_count == 0) { - return Status::NotFound("page is empty"); + return Status::Error("page is empty"); } memcpy(value, &_first_value, SIZE_OF_TYPE); return Status::OK(); @@ -125,7 +125,7 @@ class RlePageBuilder : public PageBuilder { Status get_last_value(void* value) const override { DCHECK(_finished); if (_count == 0) { - return Status::NotFound("page is empty"); + return Status::Error("page is empty"); } memcpy(value, &_last_value, SIZE_OF_TYPE); return Status::OK(); diff --git a/be/src/olap/rowset/segment_v2/segment_iterator.cpp b/be/src/olap/rowset/segment_v2/segment_iterator.cpp index c82ad31b2423a2..605eeb793ba70f 100644 --- a/be/src/olap/rowset/segment_v2/segment_iterator.cpp +++ b/be/src/olap/rowset/segment_v2/segment_iterator.cpp @@ -1201,7 +1201,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 c732b200f77eb1..71da59808e6e8f 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()) { + if (s.is() || s.is()) { continue; } if (!s.ok() && !s.is()) { diff --git a/be/test/olap/rowset/segment_v2/binary_prefix_page_test.cpp b/be/test/olap/rowset/segment_v2/binary_prefix_page_test.cpp index 07329f18fe2ede..e6aefd49e165d6 100644 --- a/be/test/olap/rowset/segment_v2/binary_prefix_page_test.cpp +++ b/be/test/olap/rowset/segment_v2/binary_prefix_page_test.cpp @@ -132,7 +132,7 @@ class BinaryPrefixPageTest : public testing::Test { Slice v1 = Slice("1039"); bool exact_match; ret = page_decoder->seek_at_or_after_value(&v1, &exact_match); - EXPECT_TRUE(ret.is()); + EXPECT_TRUE(ret.is()); Slice v2 = Slice("1000"); ret = page_decoder->seek_at_or_after_value(&v2, &exact_match); @@ -243,7 +243,7 @@ class BinaryPrefixPageTest : public testing::Test { Slice v1 = Slice("1039"); bool exact_match; ret = page_decoder->seek_at_or_after_value(&v1, &exact_match); - EXPECT_TRUE(ret.is()); + EXPECT_TRUE(ret.is()); Slice v2 = Slice("1000"); ret = page_decoder->seek_at_or_after_value(&v2, &exact_match); diff --git a/be/test/olap/rowset/segment_v2/bitshuffle_page_test.cpp b/be/test/olap/rowset/segment_v2/bitshuffle_page_test.cpp index bf4623c26becc8..75d09363ee2fa1 100644 --- a/be/test/olap/rowset/segment_v2/bitshuffle_page_test.cpp +++ b/be/test/olap/rowset/segment_v2/bitshuffle_page_test.cpp @@ -165,7 +165,7 @@ class BitShufflePageTest : public testing::Test { EXPECT_FALSE(exact_match); status = page_decoder.seek_at_or_after_value(bigger_than_biggest, &exact_match); - EXPECT_EQ(status.code(), NOT_FOUND); + EXPECT_EQ(status.code(), ENTRY_NOT_FOUND); } }; diff --git a/be/test/olap/rowset/segment_v2/plain_page_test.cpp b/be/test/olap/rowset/segment_v2/plain_page_test.cpp index 22e2e7b03b7361..bd18215522c042 100644 --- a/be/test/olap/rowset/segment_v2/plain_page_test.cpp +++ b/be/test/olap/rowset/segment_v2/plain_page_test.cpp @@ -160,7 +160,7 @@ class PlainPageTest : public testing::Test { if (bigger_than_biggest != nullptr) { status = page_decoder.seek_at_or_after_value(bigger_than_biggest, &exact_match); - EXPECT_EQ(status.code(), NOT_FOUND); + EXPECT_EQ(status.code(), ENTRY_NOT_FOUND); } } };