From 67ae013f5a85626827ca35f9a698cce2e0bff490 Mon Sep 17 00:00:00 2001 From: jiacai2050 Date: Fri, 26 Apr 2024 11:43:55 +0800 Subject: [PATCH] move ErrorKind to crate level --- src/analytic_engine/src/error.rs | 23 +++++++++++++++++++ .../src/instance/wal_replayer.rs | 2 +- src/analytic_engine/src/lib.rs | 2 ++ src/analytic_engine/src/memtable/error.rs | 8 ++----- src/analytic_engine/src/memtable/mod.rs | 2 +- 5 files changed, 29 insertions(+), 8 deletions(-) create mode 100644 src/analytic_engine/src/error.rs diff --git a/src/analytic_engine/src/error.rs b/src/analytic_engine/src/error.rs new file mode 100644 index 0000000000..205ef1f0d0 --- /dev/null +++ b/src/analytic_engine/src/error.rs @@ -0,0 +1,23 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +/// Global Error type for analytic engine. +#[derive(Debug, PartialEq, Eq, PartialOrd, Ord)] +pub enum ErrorKind { + KeyTooLarge, + Internal, +} diff --git a/src/analytic_engine/src/instance/wal_replayer.rs b/src/analytic_engine/src/instance/wal_replayer.rs index ecf8750de6..ac1c1a8e5b 100644 --- a/src/analytic_engine/src/instance/wal_replayer.rs +++ b/src/analytic_engine/src/instance/wal_replayer.rs @@ -52,9 +52,9 @@ use crate::{ serial_executor::TableOpSerialExecutor, write::{Error as WriteError, MemTableWriter}, }, - memtable::error::ErrorKind, payload::{ReadPayload, SingleSchemaProviderAdapter, TableSchemaProvider, WalDecoder}, table::data::TableDataRef, + ErrorKind, }; // Metrics of wal replayer diff --git a/src/analytic_engine/src/lib.rs b/src/analytic_engine/src/lib.rs index e363e782cf..c1308d88a8 100644 --- a/src/analytic_engine/src/lib.rs +++ b/src/analytic_engine/src/lib.rs @@ -22,6 +22,7 @@ mod compaction; mod context; mod engine; +pub mod error; mod instance; mod manifest; pub mod memtable; @@ -39,6 +40,7 @@ pub mod table_meta_set_impl; #[cfg(any(test, feature = "test"))] pub mod tests; +use error::ErrorKind; use manifest::details::Options as ManifestOptions; use object_store::config::StorageOptions; use serde::{Deserialize, Serialize}; diff --git a/src/analytic_engine/src/memtable/error.rs b/src/analytic_engine/src/memtable/error.rs index 4697984df2..4389b0e41c 100644 --- a/src/analytic_engine/src/memtable/error.rs +++ b/src/analytic_engine/src/memtable/error.rs @@ -17,6 +17,8 @@ use thiserror::Error; +use crate::ErrorKind; + #[derive(Debug, Error)] #[error(transparent)] pub struct Error(#[from] InnerError); @@ -27,12 +29,6 @@ impl From for Error { } } -#[derive(Debug, PartialEq, Eq, PartialOrd, Ord)] -pub enum ErrorKind { - KeyTooLarge, - Internal, -} - impl Error { pub fn kind(&self) -> ErrorKind { match self.0 { diff --git a/src/analytic_engine/src/memtable/mod.rs b/src/analytic_engine/src/memtable/mod.rs index 7ef7876cef..f53bff149f 100644 --- a/src/analytic_engine/src/memtable/mod.rs +++ b/src/analytic_engine/src/memtable/mod.rs @@ -38,7 +38,7 @@ use common_types::{ time::TimeRange, SequenceNumber, MUTABLE_SEGMENT_SWITCH_THRESHOLD, }; -pub use error::{Error, ErrorKind}; +pub use error::Error; use horaedbproto::manifest; use macros::define_result; use serde::{Deserialize, Serialize};