This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new d4694167a8 [Enhancement](chore) Some Status relevant enhancement (#23072) d4694167a8 is described below commit d4694167a8183d5d7feee0d569a37f838178da08 Author: plat1ko <platonekos...@gmail.com> AuthorDate: Mon Aug 21 14:14:38 2023 +0800 [Enhancement](chore) Some Status relevant enhancement (#23072) --- be/src/common/exception.h | 6 ++-- be/src/common/status.h | 38 +++++++++++----------- be/src/http/action/download_action.cpp | 13 ++++---- be/src/io/fs/benchmark/base_benchmark.h | 8 ++--- be/src/olap/compaction.cpp | 3 +- be/src/olap/data_dir.cpp | 4 +-- be/src/olap/delete_handler.cpp | 2 +- be/src/olap/file_header.h | 9 +++-- be/src/olap/push_handler.cpp | 6 ++-- be/src/olap/rowset/segcompaction.cpp | 2 +- .../inverted_index_compound_directory.cpp | 4 +-- be/src/olap/rowset/segment_v2/segment_writer.cpp | 6 ++-- be/src/olap/single_replica_compaction.cpp | 2 +- be/src/olap/tablet_manager.cpp | 2 +- be/src/olap/task/engine_checksum_task.cpp | 2 +- be/src/olap/task/engine_publish_version_task.cpp | 8 ++--- be/src/olap/task/index_builder.cpp | 2 +- be/src/olap/txn_manager.cpp | 2 +- be/src/olap/utils.cpp | 4 +-- be/src/runtime/snapshot_loader.cpp | 2 +- be/src/service/point_query_executor.cpp | 2 +- .../aggregate_function_java_udaf.h | 16 ++++----- .../aggregate_functions/aggregate_function_rpc.h | 2 +- .../data_types/serde/data_type_nullable_serde.cpp | 2 +- be/src/vec/exec/format/json/new_json_reader.cpp | 10 +++--- .../exec/format/parquet/delta_bit_pack_decoder.cpp | 2 +- .../exec/format/parquet/delta_bit_pack_decoder.h | 6 ++-- be/src/vec/exec/scan/vfile_scanner.cpp | 2 +- be/src/vec/functions/array/function_array_nary.h | 3 +- .../vec/functions/array/function_arrays_overlap.h | 2 +- be/src/vec/functions/function_jsonb.cpp | 2 +- be/src/vec/functions/function_struct_element.cpp | 2 +- be/src/vec/olap/vertical_block_reader.cpp | 2 +- be/src/vec/olap/vertical_block_reader.h | 2 +- be/src/vec/sink/autoinc_buffer.cpp | 2 +- 35 files changed, 89 insertions(+), 93 deletions(-) diff --git a/be/src/common/exception.h b/be/src/common/exception.h index 92d49495a4..325bb67aa6 100644 --- a/be/src/common/exception.h +++ b/be/src/common/exception.h @@ -53,7 +53,7 @@ public: const char* what() const noexcept override { return to_string().c_str(); } - Status to_status() const { return Status::Error(code(), to_string()); } + Status to_status() const { return Status::Error<false>(code(), to_string()); } private: int _code; @@ -97,7 +97,7 @@ inline const std::string& Exception::to_string() const { "PreCatch error code:{}, {}, __FILE__:{}, __LINE__:{}, __FUNCTION__:{}", \ e.code(), e.to_string(), __FILE__, __LINE__, __PRETTY_FUNCTION__)); \ } else { \ - return Status::Error(e.code(), e.to_string()); \ + return Status::Error<false>(e.code(), e.to_string()); \ } \ } \ } while (0) @@ -119,7 +119,7 @@ inline const std::string& Exception::to_string() const { "PreCatch error code:{}, {}, __FILE__:{}, __LINE__:{}, __FUNCTION__:{}", \ e.code(), e.to_string(), __FILE__, __LINE__, __PRETTY_FUNCTION__)); \ } else { \ - return Status::Error(e.code(), e.to_string()); \ + return Status::Error<false>(e.code(), e.to_string()); \ } \ } \ } while (0) diff --git a/be/src/common/status.h b/be/src/common/status.h index b2d5cf7d67..968dbeb9e9 100644 --- a/be/src/common/status.h +++ b/be/src/common/status.h @@ -73,7 +73,6 @@ E(COMPRESS_ERROR, -111); E(DECOMPRESS_ERROR, -112); E(UNKNOWN_COMPRESSION_TYPE, -113); E(MMAP_ERROR, -114); -E(READ_UNENOUGH, -116); E(CANNOT_CREATE_DIR, -117); E(UB_NETWORK_ERROR, -118); E(FILE_FORMAT_ERROR, -119); @@ -96,8 +95,6 @@ E(VERSION_NOT_EXIST, -214); E(TABLE_NOT_FOUND, -215); E(TRY_LOCK_FAILED, -216); E(OUT_OF_BOUND, -218); -E(FILE_DATA_ERROR, -220); -E(TEST_FILE_ERROR, -221); E(INVALID_ROOT_PATH, -222); E(NO_AVAILABLE_ROOT_PATH, -223); E(CHECK_LINES_ERROR, -224); @@ -276,7 +273,7 @@ E(INVERTED_INDEX_BUILD_WAITTING, -6008); // clang-format off // whether to capture stacktrace -inline bool capture_stacktrace(int code) { +consteval bool capture_stacktrace(int code) { return code != ErrorCode::OK && code != ErrorCode::END_OF_FILE && code != ErrorCode::MEM_LIMIT_EXCEEDED @@ -346,7 +343,21 @@ public: template <int code, bool stacktrace = true, typename... Args> Status static Error(std::string_view msg, Args&&... args) { - return Error<stacktrace>(code, msg, std::forward<Args>(args)...); + Status status; + status._code = code; + status._err_msg = std::make_unique<ErrMsg>(); + if constexpr (sizeof...(args) == 0) { + status._err_msg->_msg = msg; + } else { + status._err_msg->_msg = fmt::format(msg, std::forward<Args>(args)...); + } +#ifdef ENABLE_STACKTRACE + if constexpr (stacktrace && capture_stacktrace(code)) { + status._err_msg->_stack = get_stack_trace(); + LOG(WARNING) << "meet error status: " << status; // may print too many stacks. + } +#endif + return status; } template <bool stacktrace = true, typename... Args> @@ -360,7 +371,7 @@ public: status._err_msg->_msg = fmt::format(msg, std::forward<Args>(args)...); } #ifdef ENABLE_STACKTRACE - if (stacktrace && capture_stacktrace(code)) { + if constexpr (stacktrace) { status._err_msg->_stack = get_stack_trace(); LOG(WARNING) << "meet error status: " << status; // may print too many stacks. } @@ -413,17 +424,6 @@ public: bool ok() const { return _code == ErrorCode::OK; } - bool is_io_error() const { - return ErrorCode::IO_ERROR == _code || ErrorCode::READ_UNENOUGH == _code || - ErrorCode::CHECKSUM_ERROR == _code || ErrorCode::FILE_DATA_ERROR == _code || - ErrorCode::TEST_FILE_ERROR == _code; - } - - bool is_invalid_argument() const { return ErrorCode::INVALID_ARGUMENT == _code; } - - bool is_not_found() const { return _code == ErrorCode::NOT_FOUND; } - bool is_not_authorized() const { return code() == TStatusCode::NOT_AUTHORIZED; } - // Convert into TStatus. Call this if 'status_container' contains an optional // TStatus field named 'status'. This also sets __isset.status. template <typename T> @@ -465,12 +465,12 @@ public: // if(!status) or if (status) will use this operator operator bool() const { return this->ok(); } - // Used like if (res == Status::OK()) + // Used like if ASSERT_EQ(res, Status::OK()) // if the state is ok, then both code and precise code is not initialized properly, so that should check ok state // ignore error messages during comparison bool operator==(const Status& st) const { return _code == st._code; } - // Used like if (res != Status::OK()) + // Used like if ASSERT_NE(res, Status::OK()) bool operator!=(const Status& st) const { return _code != st._code; } friend std::ostream& operator<<(std::ostream& ostr, const Status& status); diff --git a/be/src/http/action/download_action.cpp b/be/src/http/action/download_action.cpp index 27ed2ee137..4323b67112 100644 --- a/be/src/http/action/download_action.cpp +++ b/be/src/http/action/download_action.cpp @@ -25,6 +25,7 @@ #include "common/config.h" #include "common/logging.h" +#include "common/status.h" #include "http/http_channel.h" #include "http/http_request.h" #include "http/utils.h" @@ -68,7 +69,7 @@ void DownloadAction::handle_normal(HttpRequest* req, const std::string& file_par status = check_token(req); if (!status.ok()) { std::string error_msg = status.to_string(); - if (status.is_not_authorized()) { + if (status.is<ErrorCode::NOT_AUTHORIZED>()) { HttpChannel::send_reply(req, HttpStatus::UNAUTHORIZED, error_msg); return; } else { @@ -81,10 +82,10 @@ void DownloadAction::handle_normal(HttpRequest* req, const std::string& file_par status = check_path_is_allowed(file_param); if (!status.ok()) { std::string error_msg = status.to_string(); - if (status.is_not_found() || status.is_io_error()) { + if (status.is<ErrorCode::NOT_FOUND>() || status.is<ErrorCode::IO_ERROR>()) { HttpChannel::send_reply(req, HttpStatus::NOT_FOUND, error_msg); return; - } else if (status.is_not_authorized()) { + } else if (status.is<ErrorCode::NOT_AUTHORIZED>()) { HttpChannel::send_reply(req, HttpStatus::UNAUTHORIZED, error_msg); return; } else { @@ -113,7 +114,7 @@ void DownloadAction::handle_error_log(HttpRequest* req, const std::string& file_ Status status = check_log_path_is_allowed(absolute_path); if (!status.ok()) { std::string error_msg = status.to_string(); - if (status.is_not_authorized()) { + if (status.is<ErrorCode::NOT_AUTHORIZED>()) { HttpChannel::send_reply(req, HttpStatus::UNAUTHORIZED, error_msg); return; } else { @@ -126,10 +127,10 @@ void DownloadAction::handle_error_log(HttpRequest* req, const std::string& file_ status = io::global_local_filesystem()->is_directory(absolute_path, &is_dir); if (!status.ok()) { std::string error_msg = status.to_string(); - if (status.is_not_found() || status.is_io_error()) { + if (status.is<ErrorCode::NOT_FOUND>() || status.is<ErrorCode::IO_ERROR>()) { HttpChannel::send_reply(req, HttpStatus::NOT_FOUND, error_msg); return; - } else if (status.is_not_authorized()) { + } else if (status.is<ErrorCode::NOT_AUTHORIZED>()) { HttpChannel::send_reply(req, HttpStatus::UNAUTHORIZED, error_msg); return; } else { diff --git a/be/src/io/fs/benchmark/base_benchmark.h b/be/src/io/fs/benchmark/base_benchmark.h index 6f177482b0..4cd0d5b419 100644 --- a/be/src/io/fs/benchmark/base_benchmark.h +++ b/be/src/io/fs/benchmark/base_benchmark.h @@ -63,13 +63,13 @@ public: void register_bm() { auto bm = benchmark::RegisterBenchmark(_name.c_str(), [&](benchmark::State& state) { Status st = this->init(); - if (st != Status::OK()) { + if (!st.ok()) { bm_log("Benchmark {} init error: {}", _name, st.to_string()); return; } for (auto _ : state) { st = this->run(state); - if (st != Status::OK()) { + if (!st.ok()) { bm_log("Benchmark {} run error: {}", _name, st.to_string()); return; } @@ -128,7 +128,7 @@ public: size_t size = std::min(buffer_size, (size_t)remaining_size); data.size = size; status = reader->read_at(offset, data, &bytes_read); - if (status != Status::OK() || bytes_read < 0) { + if (!status.ok() || bytes_read < 0) { bm_log("reader read_at error: {}", status.to_string()); break; } @@ -171,7 +171,7 @@ public: size_t size = std::min(buffer_size, (size_t)remaining_size); data.size = size; status = writer->append(data); - if (status != Status::OK()) { + if (!status.ok()) { bm_log("writer append error: {}", status.to_string()); break; } diff --git a/be/src/olap/compaction.cpp b/be/src/olap/compaction.cpp index 32c15a3bde..70a9b5ada0 100644 --- a/be/src/olap/compaction.cpp +++ b/be/src/olap/compaction.cpp @@ -542,8 +542,7 @@ Status Compaction::construct_output_rowset_writer(RowsetWriterContext& ctx, bool InvertedIndexDescriptor::get_index_file_name( segment_file, index_meta->index_id()); bool exists = false; - if (fs->exists(inverted_index_src_file_path, &exists) != - Status::OK()) { + if (!fs->exists(inverted_index_src_file_path, &exists).ok()) { LOG(ERROR) << inverted_index_src_file_path << " fs->exists error"; return false; diff --git a/be/src/olap/data_dir.cpp b/be/src/olap/data_dir.cpp index ce244f09a5..39acf420c0 100644 --- a/be/src/olap/data_dir.cpp +++ b/be/src/olap/data_dir.cpp @@ -236,9 +236,7 @@ void DataDir::health_check() { if (!res) { LOG(WARNING) << "store read/write test file occur IO Error. path=" << _path << ", err: " << res; - if (res.is_io_error()) { - _is_used = false; - } + _is_used = !res.is<IO_ERROR>(); } } disks_state->set_value(_is_used ? 1 : 0); diff --git a/be/src/olap/delete_handler.cpp b/be/src/olap/delete_handler.cpp index 1df44e0004..e410c088ce 100644 --- a/be/src/olap/delete_handler.cpp +++ b/be/src/olap/delete_handler.cpp @@ -60,7 +60,7 @@ Status DeleteHandler::generate_delete_predicate(const TabletSchema& schema, // Check whether the delete condition meets the requirements for (const TCondition& condition : conditions) { - if (check_condition_valid(schema, condition) != Status::OK()) { + if (!check_condition_valid(schema, condition).ok()) { // Error will print log, no need to do it manually. return Status::Error<DELETE_INVALID_CONDITION>("invalid condition. condition={}", ThriftDebugString(condition)); diff --git a/be/src/olap/file_header.h b/be/src/olap/file_header.h index ef31bba23f..08fe09aff1 100644 --- a/be/src/olap/file_header.h +++ b/be/src/olap/file_header.h @@ -205,7 +205,7 @@ Status FileHeader<MessageType, ExtraType>::deserialize() { real_file_length = file_reader->size(); if (file_length() != static_cast<uint64_t>(real_file_length)) { - return Status::Error<ErrorCode::FILE_DATA_ERROR>( + return Status::InternalError( "file length is not match. file={}, file_length={}, real_file_length={}", file_reader->path().native(), file_length(), real_file_length); } @@ -219,10 +219,9 @@ Status FileHeader<MessageType, ExtraType>::deserialize() { // Cannot bind packed field '_FixedFileHeaderV2::protobuf_checksum' to 'unsigned int&' // so we need to using unary operator+ to evaluate one value to pass // to status to successfully compile. - return Status::Error<ErrorCode::CHECKSUM_ERROR>( - "checksum is not match. file={}, expect={}, actual={}", - file_reader->path().native(), +_fixed_file_header.protobuf_checksum, - real_protobuf_checksum); + return Status::InternalError("checksum is not match. file={}, expect={}, actual={}", + file_reader->path().native(), + +_fixed_file_header.protobuf_checksum, real_protobuf_checksum); } try { diff --git a/be/src/olap/push_handler.cpp b/be/src/olap/push_handler.cpp index 4b28b2def7..713109b04b 100644 --- a/be/src/olap/push_handler.cpp +++ b/be/src/olap/push_handler.cpp @@ -194,8 +194,8 @@ Status PushHandler::_do_streaming_ingestion(TabletSharedPtr tablet, const TPushR } Status commit_status = StorageEngine::instance()->txn_manager()->commit_txn( request.partition_id, tablet, request.transaction_id, load_id, rowset_to_add, false); - if (commit_status != Status::OK() && !commit_status.is<PUSH_TRANSACTION_ALREADY_EXIST>()) { - res = commit_status; + if (!commit_status.ok() && !commit_status.is<PUSH_TRANSACTION_ALREADY_EXIST>()) { + res = std::move(commit_status); } return res; } @@ -290,7 +290,7 @@ Status PushHandler::_convert_v2(TabletSharedPtr cur_tablet, RowsetSharedPtr* cur reader->close(); } - if (rowset_writer->flush() != Status::OK()) { + if (!rowset_writer->flush().ok()) { LOG(WARNING) << "failed to finalize writer"; break; } diff --git a/be/src/olap/rowset/segcompaction.cpp b/be/src/olap/rowset/segcompaction.cpp index 0df56425d4..b01f2b363a 100644 --- a/be/src/olap/rowset/segcompaction.cpp +++ b/be/src/olap/rowset/segcompaction.cpp @@ -108,7 +108,7 @@ std::unique_ptr<segment_v2::SegmentWriter> SegcompactionWorker::_create_segcompa Status status; std::unique_ptr<segment_v2::SegmentWriter> writer = nullptr; status = _create_segment_writer_for_segcompaction(&writer, begin, end); - if (status != Status::OK() || writer == nullptr) { + if (!status.ok() || writer == nullptr) { LOG(ERROR) << "failed to create segment writer for begin:" << begin << " end:" << end << " path:" << writer->get_data_dir()->path() << " status:" << status; return nullptr; diff --git a/be/src/olap/rowset/segment_v2/inverted_index_compound_directory.cpp b/be/src/olap/rowset/segment_v2/inverted_index_compound_directory.cpp index 55d8253352..6ebe4a95fc 100644 --- a/be/src/olap/rowset/segment_v2/inverted_index_compound_directory.cpp +++ b/be/src/olap/rowset/segment_v2/inverted_index_compound_directory.cpp @@ -424,12 +424,12 @@ void DorisCompoundDirectory::FSIndexOutput::close() { } if (writer) { Status ret = writer->finalize(); - if (ret != Status::OK()) { + if (!ret.ok()) { LOG(WARNING) << "FSIndexOutput close, file writer finalize error: " << ret.to_string(); _CLTHROWA(CL_ERR_IO, ret.to_string().c_str()); } ret = writer->close(); - if (ret != Status::OK()) { + if (!ret.ok()) { LOG(WARNING) << "FSIndexOutput close, file writer close error: " << ret.to_string(); _CLTHROWA(CL_ERR_IO, ret.to_string().c_str()); } diff --git a/be/src/olap/rowset/segment_v2/segment_writer.cpp b/be/src/olap/rowset/segment_v2/segment_writer.cpp index be0ebbea91..6381f89bc2 100644 --- a/be/src/olap/rowset/segment_v2/segment_writer.cpp +++ b/be/src/olap/rowset/segment_v2/segment_writer.cpp @@ -353,7 +353,7 @@ Status SegmentWriter::append_block_with_partial_content(const vectorized::Block* segment_start_pos = _column_writers[cid]->get_next_rowid(); // olap data convertor alway start from id = 0 auto converted_result = _olap_data_convertor->convert_column_data(cid); - if (converted_result.first != Status::OK()) { + if (!converted_result.first.ok()) { return converted_result.first; } if (cid < _num_key_columns) { @@ -484,7 +484,7 @@ Status SegmentWriter::append_block_with_partial_content(const vectorized::Block* cids_missing); for (auto cid : cids_missing) { auto converted_result = _olap_data_convertor->convert_column_data(cid); - if (converted_result.first != Status::OK()) { + if (!converted_result.first.ok()) { return converted_result.first; } if (_tablet_schema->has_sequence_col() && !have_input_seq_column && @@ -660,7 +660,7 @@ Status SegmentWriter::append_block(const vectorized::Block* block, size_t row_po for (size_t id = 0; id < _column_writers.size(); ++id) { // olap data convertor alway start from id = 0 auto converted_result = _olap_data_convertor->convert_column_data(id); - if (converted_result.first != Status::OK()) { + if (!converted_result.first.ok()) { return converted_result.first; } auto cid = _column_ids[id]; diff --git a/be/src/olap/single_replica_compaction.cpp b/be/src/olap/single_replica_compaction.cpp index afe91d9e8e..70284a4bcb 100644 --- a/be/src/olap/single_replica_compaction.cpp +++ b/be/src/olap/single_replica_compaction.cpp @@ -349,7 +349,7 @@ Status SingleReplicaCompaction::_fetch_rowset(const TReplicaInfo& addr, const st // change all rowset ids because they maybe its id same with local rowset auto olap_st = SnapshotManager::instance()->convert_rowset_ids( local_path, _tablet->tablet_id(), _tablet->replica_id(), _tablet->schema_hash()); - if (olap_st != Status::OK()) { + if (!olap_st.ok()) { LOG(WARNING) << "fail to convert rowset ids, path=" << local_path << ", tablet_id=" << _tablet->tablet_id() << ", error=" << olap_st; status = Status::InternalError("Failed to convert rowset ids"); diff --git a/be/src/olap/tablet_manager.cpp b/be/src/olap/tablet_manager.cpp index 6bc5746d7b..d6e4294a17 100644 --- a/be/src/olap/tablet_manager.cpp +++ b/be/src/olap/tablet_manager.cpp @@ -1136,7 +1136,7 @@ Status TabletManager::start_trash_sweep() { (*it)->tablet_meta()->save(meta_file_path); LOG(INFO) << "start to move tablet to trash. " << tablet_path; Status rm_st = (*it)->data_dir()->move_to_trash(tablet_path); - if (rm_st != Status::OK()) { + if (!rm_st.ok()) { LOG(WARNING) << "fail to move dir to trash. " << tablet_path; ++it; continue; diff --git a/be/src/olap/task/engine_checksum_task.cpp b/be/src/olap/task/engine_checksum_task.cpp index 614802e1f0..827515cc99 100644 --- a/be/src/olap/task/engine_checksum_task.cpp +++ b/be/src/olap/task/engine_checksum_task.cpp @@ -77,7 +77,7 @@ Status EngineChecksumTask::_compute_checksum() { { std::shared_lock rdlock(tablet->get_header_lock()); Status acquire_reader_st = tablet->capture_consistent_rowsets(version, &input_rowsets); - if (acquire_reader_st != Status::OK()) { + if (!acquire_reader_st.ok()) { LOG(WARNING) << "fail to captute consistent rowsets. tablet=" << tablet->full_name() << "res=" << acquire_reader_st; return acquire_reader_st; diff --git a/be/src/olap/task/engine_publish_version_task.cpp b/be/src/olap/task/engine_publish_version_task.cpp index 08f7fc33cc..3bafeca033 100644 --- a/be/src/olap/task/engine_publish_version_task.cpp +++ b/be/src/olap/task/engine_publish_version_task.cpp @@ -262,7 +262,7 @@ void TabletPublishTxnTask::handle() { Defer defer {[&] { _rowset->finish_publish(); }}; auto publish_status = StorageEngine::instance()->txn_manager()->publish_txn( _partition_id, _tablet, _transaction_id, _version, &_stats); - if (publish_status != Status::OK()) { + if (!publish_status.ok()) { LOG(WARNING) << "failed to publish version. rowset_id=" << _rowset->rowset_id() << ", tablet_id=" << _tablet_info.tablet_id << ", txn_id=" << _transaction_id << ", res=" << publish_status; @@ -274,7 +274,7 @@ void TabletPublishTxnTask::handle() { int64_t t1 = MonotonicMicros(); publish_status = _tablet->add_inc_rowset(_rowset); _stats.add_inc_rowset_us = MonotonicMicros() - t1; - if (publish_status != Status::OK() && !publish_status.is<PUSH_VERSION_ALREADY_EXIST>()) { + if (!publish_status.ok() && !publish_status.is<PUSH_VERSION_ALREADY_EXIST>()) { LOG(WARNING) << "fail to add visible rowset to tablet. rowset_id=" << _rowset->rowset_id() << ", tablet_id=" << _tablet_info.tablet_id << ", txn_id=" << _transaction_id << ", res=" << publish_status; @@ -314,7 +314,7 @@ void AsyncTabletPublishTask::handle() { Version version(_version, _version); auto publish_status = StorageEngine::instance()->txn_manager()->publish_txn( _partition_id, _tablet, _transaction_id, version, &_stats); - if (publish_status != Status::OK()) { + if (!publish_status.ok()) { LOG(WARNING) << "failed to publish version. rowset_id=" << rowset->rowset_id() << ", tablet_id=" << _tablet->tablet_id() << ", txn_id=" << _transaction_id << ", res=" << publish_status; @@ -325,7 +325,7 @@ void AsyncTabletPublishTask::handle() { int64_t t1 = MonotonicMicros(); publish_status = _tablet->add_inc_rowset(rowset); _stats.add_inc_rowset_us = MonotonicMicros() - t1; - if (publish_status != Status::OK() && !publish_status.is<PUSH_VERSION_ALREADY_EXIST>()) { + if (!publish_status.ok() && !publish_status.is<PUSH_VERSION_ALREADY_EXIST>()) { LOG(WARNING) << "fail to add visible rowset to tablet. rowset_id=" << rowset->rowset_id() << ", tablet_id=" << _tablet->tablet_id() << ", txn_id=" << _transaction_id << ", res=" << publish_status; diff --git a/be/src/olap/task/index_builder.cpp b/be/src/olap/task/index_builder.cpp index 90aeedd931..c621f77f49 100644 --- a/be/src/olap/task/index_builder.cpp +++ b/be/src/olap/task/index_builder.cpp @@ -253,7 +253,7 @@ Status IndexBuilder::_write_inverted_index_data(TabletSchemaSPtr tablet_schema, auto inverted_index = _alter_inverted_indexes[i]; auto index_id = inverted_index.index_id; auto converted_result = _olap_data_convertor->convert_column_data(i); - if (converted_result.first != Status::OK()) { + if (!converted_result.first.ok()) { LOG(WARNING) << "failed to convert block, errcode: " << converted_result.first; return converted_result.first; } diff --git a/be/src/olap/txn_manager.cpp b/be/src/olap/txn_manager.cpp index 0d0504f9f8..99eb040d09 100644 --- a/be/src/olap/txn_manager.cpp +++ b/be/src/olap/txn_manager.cpp @@ -282,7 +282,7 @@ Status TxnManager::commit_txn(OlapMeta* meta, TPartitionId partition_id, if (!is_recovery) { Status save_status = RowsetMetaManager::save(meta, tablet_uid, rowset_ptr->rowset_id(), rowset_ptr->rowset_meta()->get_rowset_pb()); - if (save_status != Status::OK()) { + if (!save_status.ok()) { return Status::Error<ROWSET_SAVE_FAILED>( "save committed rowset failed. when commit txn rowset_id: {}, tablet id: {}, " "txn id: {}", diff --git a/be/src/olap/utils.cpp b/be/src/olap/utils.cpp index 52f9fa8bb8..20099aab92 100644 --- a/be/src/olap/utils.cpp +++ b/be/src/olap/utils.cpp @@ -471,8 +471,8 @@ Status read_write_test_file(const std::string& test_file_path) { size_t bytes_read = 0; RETURN_IF_ERROR(file_reader->read_at(0, {read_buff.get(), TEST_FILE_BUF_SIZE}, &bytes_read)); if (memcmp(write_buff.get(), read_buff.get(), TEST_FILE_BUF_SIZE) != 0) { - return Status::Error<TEST_FILE_ERROR>( - "the test file write_buf and read_buf not equal, file_name={}.", test_file_path); + return Status::IOError("the test file write_buf and read_buf not equal, file_name={}.", + test_file_path); } // delete file return io::global_local_filesystem()->delete_file(test_file_path); diff --git a/be/src/runtime/snapshot_loader.cpp b/be/src/runtime/snapshot_loader.cpp index 3ff8229bc3..b1d0f8e55d 100644 --- a/be/src/runtime/snapshot_loader.cpp +++ b/be/src/runtime/snapshot_loader.cpp @@ -698,7 +698,7 @@ Status SnapshotLoader::move(const std::string& snapshot_path, TabletSharedPtr ta // rename the rowset ids and tabletid info in rowset meta Status convert_status = SnapshotManager::instance()->convert_rowset_ids( snapshot_path, tablet_id, tablet->replica_id(), schema_hash); - if (convert_status != Status::OK()) { + if (!convert_status.ok()) { std::stringstream ss; ss << "failed to convert rowsetids in snapshot: " << snapshot_path << ", tablet path: " << tablet_path; diff --git a/be/src/service/point_query_executor.cpp b/be/src/service/point_query_executor.cpp index 856c65cbdf..4463c0d01a 100644 --- a/be/src/service/point_query_executor.cpp +++ b/be/src/service/point_query_executor.cpp @@ -287,7 +287,7 @@ Status PointQueryExecutor::_lookup_row_key() { st = (_tablet->lookup_row_key(_row_read_ctxs[i]._primary_key, true, specified_rowsets, &location, INT32_MAX /*rethink?*/, segment_caches, rowset_ptr.get())); - if (st.is_not_found()) { + if (st.is<ErrorCode::NOT_FOUND>()) { continue; } RETURN_IF_ERROR(st); diff --git a/be/src/vec/aggregate_functions/aggregate_function_java_udaf.h b/be/src/vec/aggregate_functions/aggregate_function_java_udaf.h index defd33b475..af0ae185a1 100644 --- a/be/src/vec/aggregate_functions/aggregate_function_java_udaf.h +++ b/be/src/vec/aggregate_functions/aggregate_function_java_udaf.h @@ -546,7 +546,7 @@ public: Status st = this->data(_exec_place) .add(places_address, true, columns, row_num, row_num + 1, argument_types, 0); - if (UNLIKELY(st != Status::OK())) { + if (UNLIKELY(!st.ok())) { throw doris::Exception(ErrorCode::INTERNAL_ERROR, st.to_string()); } } @@ -557,7 +557,7 @@ public: Status st = this->data(_exec_place) .add(places_address, false, columns, 0, batch_size, argument_types, place_offset); - if (UNLIKELY(st != Status::OK())) { + if (UNLIKELY(!st.ok())) { throw doris::Exception(ErrorCode::INTERNAL_ERROR, st.to_string()); } } @@ -567,7 +567,7 @@ public: int64_t places_address = reinterpret_cast<int64_t>(place); Status st = this->data(_exec_place) .add(places_address, true, columns, 0, batch_size, argument_types, 0); - if (UNLIKELY(st != Status::OK())) { + if (UNLIKELY(!st.ok())) { throw doris::Exception(ErrorCode::INTERNAL_ERROR, st.to_string()); } } @@ -581,14 +581,14 @@ public: Status st = this->data(_exec_place) .add(places_address, true, columns, frame_start, frame_end, argument_types, 0); - if (UNLIKELY(st != Status::OK())) { + if (UNLIKELY(!st.ok())) { throw doris::Exception(ErrorCode::INTERNAL_ERROR, st.to_string()); } } void reset(AggregateDataPtr place) const override { Status st = this->data(_exec_place).reset(reinterpret_cast<int64_t>(place)); - if (UNLIKELY(st != Status::OK())) { + if (UNLIKELY(!st.ok())) { throw doris::Exception(ErrorCode::INTERNAL_ERROR, st.to_string()); } } @@ -597,7 +597,7 @@ public: Arena*) const override { Status st = this->data(_exec_place).merge(this->data(rhs), reinterpret_cast<int64_t>(place)); - if (UNLIKELY(st != Status::OK())) { + if (UNLIKELY(!st.ok())) { throw doris::Exception(ErrorCode::INTERNAL_ERROR, st.to_string()); } } @@ -605,7 +605,7 @@ public: void serialize(ConstAggregateDataPtr __restrict place, BufferWritable& buf) const override { Status st = this->data(const_cast<AggregateDataPtr&>(_exec_place)) .write(buf, reinterpret_cast<int64_t>(place)); - if (UNLIKELY(st != Status::OK())) { + if (UNLIKELY(!st.ok())) { throw doris::Exception(ErrorCode::INTERNAL_ERROR, st.to_string()); } } @@ -623,7 +623,7 @@ public: void insert_result_into(ConstAggregateDataPtr __restrict place, IColumn& to) const override { Status st = this->data(_exec_place).get(to, _return_type, reinterpret_cast<int64_t>(place)); - if (UNLIKELY(st != Status::OK())) { + if (UNLIKELY(!st.ok())) { throw doris::Exception(ErrorCode::INTERNAL_ERROR, st.to_string()); } } diff --git a/be/src/vec/aggregate_functions/aggregate_function_rpc.h b/be/src/vec/aggregate_functions/aggregate_function_rpc.h index 8a5c77978b..4b75c64d82 100644 --- a/be/src/vec/aggregate_functions/aggregate_function_rpc.h +++ b/be/src/vec/aggregate_functions/aggregate_function_rpc.h @@ -155,7 +155,7 @@ public: PValues* arg = request.add_args(); auto data_type = argument_types[i]; if (auto st = data_type->get_serde()->write_column_to_pb(*columns[i], *arg, start, end); - st != Status::OK()) { + !st.ok()) { return st; } } diff --git a/be/src/vec/data_types/serde/data_type_nullable_serde.cpp b/be/src/vec/data_types/serde/data_type_nullable_serde.cpp index 77d67e764a..0ecc446b6b 100644 --- a/be/src/vec/data_types/serde/data_type_nullable_serde.cpp +++ b/be/src/vec/data_types/serde/data_type_nullable_serde.cpp @@ -109,7 +109,7 @@ Status DataTypeNullableSerDe::read_column_from_pb(IColumn& column, const PValues auto& col = reinterpret_cast<ColumnNullable&>(column); auto& null_map_data = col.get_null_map_data(); auto& nested = col.get_nested_column(); - if (Status st = nested_serde->read_column_from_pb(nested, arg); st != Status::OK()) { + if (Status st = nested_serde->read_column_from_pb(nested, arg); !st.ok()) { return st; } null_map_data.resize(nested.size()); diff --git a/be/src/vec/exec/format/json/new_json_reader.cpp b/be/src/vec/exec/format/json/new_json_reader.cpp index b02c30807d..4cee00e842 100644 --- a/be/src/vec/exec/format/json/new_json_reader.cpp +++ b/be/src/vec/exec/format/json/new_json_reader.cpp @@ -624,8 +624,8 @@ Status NewJsonReader::_vhandle_flat_array_complex_json( } RETURN_IF_ERROR(st); if (*is_empty_row == true) { - if (st == Status::OK()) { - return Status::OK(); + if (st.ok()) { + return st; } if (_total_rows == 0) { continue; @@ -1226,8 +1226,8 @@ Status NewJsonReader::_simdjson_handle_flat_array_complex_json( } RETURN_IF_ERROR(st); if (*is_empty_row == true) { - if (st == Status::OK()) { - return Status::OK(); + if (st.ok()) { + return st; } if (_total_rows == 0) { continue; @@ -1244,7 +1244,7 @@ Status NewJsonReader::_simdjson_handle_flat_array_complex_json( simdjson::ondemand::value val; Status st = JsonFunctions::extract_from_object(cur, _parsed_json_root, &val); if (UNLIKELY(!st.ok())) { - if (st.is_not_found()) { + if (st.is<NOT_FOUND>()) { RETURN_IF_ERROR( _append_error_msg(nullptr, "JsonPath not found", "", nullptr)); ADVANCE_ROW(); diff --git a/be/src/vec/exec/format/parquet/delta_bit_pack_decoder.cpp b/be/src/vec/exec/format/parquet/delta_bit_pack_decoder.cpp index 575fd721eb..f734f3012c 100644 --- a/be/src/vec/exec/format/parquet/delta_bit_pack_decoder.cpp +++ b/be/src/vec/exec/format/parquet/delta_bit_pack_decoder.cpp @@ -174,7 +174,7 @@ void DeltaLengthByteArrayDecoder::_decode_lengths() { // decode all the lengths. all the lengths are buffered in buffered_length_. int ret; Status st = _len_decoder.decode(_buffered_length.data(), num_length, &ret); - if (st != Status::OK()) { + if (!st.ok()) { LOG(FATAL) << "Fail to decode delta length, status: " << st; } DCHECK_EQ(ret, num_length); diff --git a/be/src/vec/exec/format/parquet/delta_bit_pack_decoder.h b/be/src/vec/exec/format/parquet/delta_bit_pack_decoder.h index 021c0cd1dd..464229cda9 100644 --- a/be/src/vec/exec/format/parquet/delta_bit_pack_decoder.h +++ b/be/src/vec/exec/format/parquet/delta_bit_pack_decoder.h @@ -153,7 +153,7 @@ public: void set_data(Slice* slice) override { _bit_reader.reset(new BitReader((const uint8_t*)slice->data, slice->size)); Status st = _init_header(); - if (st != Status::OK()) { + if (!st.ok()) { LOG(FATAL) << "Fail to init delta encoding header for " << st.to_string(); } _data = slice; @@ -165,7 +165,7 @@ public: void set_bit_reader(std::shared_ptr<BitReader> bit_reader) { _bit_reader = std::move(bit_reader); Status st = _init_header(); - if (st != Status::OK()) { + if (!st.ok()) { LOG(FATAL) << "Fail to init delta encoding header for " << st.to_string(); } } @@ -326,7 +326,7 @@ public: _buffered_prefix_length.resize(num_prefix); int ret; Status st = _prefix_len_decoder.decode(_buffered_prefix_length.data(), num_prefix, &ret); - if (st != Status::OK()) { + if (!st.ok()) { LOG(FATAL) << "Fail to decode delta prefix, status: " << st; } DCHECK_EQ(ret, num_prefix); diff --git a/be/src/vec/exec/scan/vfile_scanner.cpp b/be/src/vec/exec/scan/vfile_scanner.cpp index bc439b73d2..2c04a0c92e 100644 --- a/be/src/vec/exec/scan/vfile_scanner.cpp +++ b/be/src/vec/exec/scan/vfile_scanner.cpp @@ -819,7 +819,7 @@ Status VFileScanner::_get_next_reader() { if (_state->query_options().truncate_char_or_varchar_columns && need_to_get_parsed_schema) { Status status = _cur_reader->get_parsed_schema(&_source_file_col_names, &_source_file_col_types); - if (status != Status::OK() && status.code() != TStatusCode::NOT_IMPLEMENTED_ERROR) { + if (!status.ok() && status.code() != TStatusCode::NOT_IMPLEMENTED_ERROR) { return status; } DCHECK(_source_file_col_names.size() == _source_file_col_types.size()); diff --git a/be/src/vec/functions/array/function_array_nary.h b/be/src/vec/functions/array/function_array_nary.h index bc42585439..719890b7ba 100644 --- a/be/src/vec/functions/array/function_array_nary.h +++ b/be/src/vec/functions/array/function_array_nary.h @@ -69,8 +69,7 @@ public: col_const[i] = is_const; extract_column_array_info(*col, datas[i]); } - if (Status st = Impl::execute(res_ptr, datas, col_const, 0, input_rows_count); - st != Status::OK()) { + if (Status st = Impl::execute(res_ptr, datas, col_const, 0, input_rows_count); !st.ok()) { return Status::RuntimeError( fmt::format("function {} execute failed {} ", get_name(), st.to_string())); } diff --git a/be/src/vec/functions/array/function_arrays_overlap.h b/be/src/vec/functions/array/function_arrays_overlap.h index 969773481a..d4b9c8245e 100644 --- a/be/src/vec/functions/array/function_arrays_overlap.h +++ b/be/src/vec/functions/array/function_arrays_overlap.h @@ -233,7 +233,7 @@ public: } } - if (ret == Status::OK()) { + if (ret.ok()) { block.replace_by_position(result, ColumnNullable::create(std::move(dst_nested_col), std::move(dst_null_map))); } diff --git a/be/src/vec/functions/function_jsonb.cpp b/be/src/vec/functions/function_jsonb.cpp index 9fe20e751f..f2ad73f510 100644 --- a/be/src/vec/functions/function_jsonb.cpp +++ b/be/src/vec/functions/function_jsonb.cpp @@ -392,7 +392,7 @@ public: Status st = Impl::vector_vector_v2( context, ldata, loffsets, jsonb_data_const, jsonb_path_columns, path_const, res_data, res_offsets, null_map->get_data(), is_invalid_json_path); - if (st != Status::OK()) { + if (!st.ok()) { return st; } } else { diff --git a/be/src/vec/functions/function_struct_element.cpp b/be/src/vec/functions/function_struct_element.cpp index 4b98522ba6..d3bf0fa164 100644 --- a/be/src/vec/functions/function_struct_element.cpp +++ b/be/src/vec/functions/function_struct_element.cpp @@ -85,7 +85,7 @@ public: auto index_type = block.get_by_position(arguments[1]).type; size_t index; Status res = get_element_index(*struct_type, index_column, index_type, &index); - if (res == Status::OK()) { + if (res.ok()) { ColumnPtr res_column = struct_col->get_column_ptr(index); block.replace_by_position(result, res_column->clone_resized(res_column->size())); return res; diff --git a/be/src/vec/olap/vertical_block_reader.cpp b/be/src/vec/olap/vertical_block_reader.cpp index 7d6f9bc502..5b9f79f337 100644 --- a/be/src/vec/olap/vertical_block_reader.cpp +++ b/be/src/vec/olap/vertical_block_reader.cpp @@ -205,7 +205,7 @@ Status VerticalBlockReader::init(const ReaderParams& read_params) { auto status = _init_collect_iter(read_params); if (!status.ok()) { - if (status.is_io_error()) { + if (status.is<IO_ERROR>()) { _tablet->increase_io_error_times(); } return status; diff --git a/be/src/vec/olap/vertical_block_reader.h b/be/src/vec/olap/vertical_block_reader.h index e945360129..9ba4f9119b 100644 --- a/be/src/vec/olap/vertical_block_reader.h +++ b/be/src/vec/olap/vertical_block_reader.h @@ -60,7 +60,7 @@ public: Status next_block_with_aggregation(Block* block, bool* eof) override { auto res = (this->*_next_block_func)(block, eof); - if (UNLIKELY(res.is_io_error())) { + if (UNLIKELY(res.is<ErrorCode::IO_ERROR>())) { _tablet->increase_io_error_times(); } return res; diff --git a/be/src/vec/sink/autoinc_buffer.cpp b/be/src/vec/sink/autoinc_buffer.cpp index 69c245668a..675f8ee292 100644 --- a/be/src/vec/sink/autoinc_buffer.cpp +++ b/be/src/vec/sink/autoinc_buffer.cpp @@ -68,7 +68,7 @@ Status AutoIncIDBuffer::sync_request_ids(size_t length, } if (length > 0) { _wait_for_prefetching(); - if (_rpc_status != Status::OK()) { + if (!_rpc_status.ok()) { return _rpc_status; } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org