From 9f36f9103a8f4a606ad575ab4b0f05d15857658e Mon Sep 17 00:00:00 2001 From: Zhang Yanpo Date: Fri, 14 Mar 2025 20:42:01 +0800 Subject: [PATCH 1/3] BumpVer: 0.2.0 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index c7ac8c2..8157ac7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "map-api" description = "Raft state machine" -version = "0.1.1" +version = "0.2.0" authors = ["Databend Authors "] license = "Apache-2.0" edition = "2021" From 19db3035185462cdb0fa221478ea16626b3777eb Mon Sep 17 00:00:00 2001 From: Zhang Yanpo Date: Fri, 14 Mar 2025 20:46:09 +0800 Subject: [PATCH 2/3] Change: rename Update to Change and deprecate Update --- src/seq_value/mod.rs | 5 ++++- src/seq_value/update.rs | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/seq_value/mod.rs b/src/seq_value/mod.rs index 3897b83..73fd4a0 100644 --- a/src/seq_value/mod.rs +++ b/src/seq_value/mod.rs @@ -24,4 +24,7 @@ mod update; pub use seq_value_trait::SeqValue; pub use seqv::SeqV; -pub use update::Update; +pub use update::Change; + +#[deprecated(since = "0.2.0", note = "Use `Change` instead")] +pub type Update> = Change; diff --git a/src/seq_value/update.rs b/src/seq_value/update.rs index 10a2545..37a0970 100644 --- a/src/seq_value/update.rs +++ b/src/seq_value/update.rs @@ -16,13 +16,13 @@ use crate::seq_value::SeqV; /// An update event for a key. #[derive(Debug, Clone, PartialEq, Eq)] -pub struct Update> { +pub struct Change> { pub key: String, pub before: Option>, pub after: Option>, } -impl Update { +impl Change { pub fn new(key: String, before: Option>, after: Option>) -> Self { Self { key, before, after } } From 70bb8c13e7e0092dc544c71748aff17313b4284e Mon Sep 17 00:00:00 2001 From: Zhang Yanpo Date: Fri, 14 Mar 2025 20:58:07 +0800 Subject: [PATCH 3/3] Change: rename Transition to BeforeAfter; deprecate Transition --- src/impls/level.rs | 4 ++-- src/lib.rs | 12 ++++++++++-- src/map_api.rs | 6 +++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/impls/level.rs b/src/impls/level.rs index eb1c236..821f7a4 100644 --- a/src/impls/level.rs +++ b/src/impls/level.rs @@ -25,13 +25,13 @@ use std::ops::RangeBounds; use futures_util::StreamExt; use log::warn; +use crate::BeforeAfter; use crate::KVResultStream; use crate::MapApi; use crate::MapApiRO; use crate::MapKey; use crate::Marked; use crate::MarkedOf; -use crate::Transition; /// A simple in-memory implementation of the Map API using a BTreeMap. /// @@ -129,7 +129,7 @@ where M: Clone + Unpin + Send + Sync + 'static &mut self, key: String, value: Option<(>::V, Option)>, - ) -> Result>, io::Error> { + ) -> Result>, io::Error> { // The chance it is the bottom level is very low in a loaded system. // Thus, we always tombstone the key if it is None. diff --git a/src/lib.rs b/src/lib.rs index d069456..46da5cc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -84,9 +84,17 @@ pub use crate::map_key::MapKey; pub use crate::map_value::MapValue; pub use crate::marked::Marked; +#[deprecated(since = "0.2.0", note = "Use `BeforeAfter` instead")] +pub type Transition = BeforeAfter; + /// Represents a transition from one state to another. -/// The tuple contains the initial state and the resulting state. -pub type Transition = (T, T); +/// +/// This type is a tuple containing two elements: +/// - The first element represents the state before the transition (initial state) +/// - The second element represents the state after the transition (resulting state) +/// +/// It's commonly used to track changes in values or system states. +pub type BeforeAfter = (T, T); /// A boxed stream that yields `Result` of key-value pairs or an `io::Error`. /// The stream is 'static to ensure it can live for the entire duration of the program. diff --git a/src/map_api.rs b/src/map_api.rs index 5bbfb14..36b44e4 100644 --- a/src/map_api.rs +++ b/src/map_api.rs @@ -22,7 +22,7 @@ use std::io; use crate::map_api_ro::MapApiRO; use crate::map_key::MapKey; -use crate::Transition; +use crate::BeforeAfter; /// Provides a read-write key-value map API, used to access state machine data. /// @@ -80,7 +80,7 @@ where /// /// # Returns /// - /// A [`Transition`] containing: + /// A [`BeforeAfter`] containing: /// - The old value (before the operation) /// - The new value (after the operation) /// @@ -92,5 +92,5 @@ where &mut self, key: K, value: Option<(K::V, Option)>, - ) -> Result>, io::Error>; + ) -> Result>, io::Error>; }