Skip to content

Commit

Permalink
Rename some types
Browse files Browse the repository at this point in the history
  • Loading branch information
al8n committed Nov 2, 2024
1 parent 39f42d5 commit f24d3e9
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 66 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "orderwal"
version = "0.5.0"
version = "0.5.1"
edition = "2021"
repository = "https://github.com/al8n/orderwal"
homepage = "https://github.com/al8n/orderwal"
Expand Down
4 changes: 2 additions & 2 deletions src/swmr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ pub mod multiple_version {

pub use crate::{
memtable::arena::TableOptions as ArenaTableOptions,
types::multiple_version::{Entry, Key, MultipleVersionEntry, Value},
types::multiple_version::{Entry, Key, Value, VersionedEntry},
wal::multiple_version::{
Iter, Keys, MultipleVersionIter, MultipleVersionRange, RangeKeys, RangeValues, Reader, Writer,
Iter, IterAll, Keys, RangeAll, RangeKeys, RangeValues, Reader, Writer,
},
};

Expand Down
18 changes: 9 additions & 9 deletions src/types/multiple_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ where
}

/// The reference to an entry in the generic WALs.
pub struct MultipleVersionEntry<'a, E>
pub struct VersionedEntry<'a, E>
where
E: VersionedMemtableEntry<'a>,
E::Key: Type,
Expand All @@ -391,22 +391,22 @@ where
query_version: u64,
}

impl<'a, E> core::fmt::Debug for MultipleVersionEntry<'a, E>
impl<'a, E> core::fmt::Debug for VersionedEntry<'a, E>
where
E: VersionedMemtableEntry<'a> + core::fmt::Debug,
E::Key: Type,
E::Value: Type,
{
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_struct("MultipleVersionEntry")
f.debug_struct("VersionedEntry")
.field("key", &self.key())
.field("value", &self.value())
.field("version", &self.version)
.finish()
}
}

impl<'a, E> Clone for MultipleVersionEntry<'a, E>
impl<'a, E> Clone for VersionedEntry<'a, E>
where
E: VersionedMemtableEntry<'a> + Clone,
E::Key: Type,
Expand All @@ -424,7 +424,7 @@ where
}
}

impl<'a, E> MultipleVersionEntry<'a, E>
impl<'a, E> VersionedEntry<'a, E>
where
E: VersionedMemtableEntry<'a>,
E::Key: Type,
Expand All @@ -447,7 +447,7 @@ where
}
}

impl<'a, E> MultipleVersionEntry<'a, E>
impl<'a, E> VersionedEntry<'a, E>
where
E: VersionedMemtableEntry<'a>,
E::Key: Ord + Type,
Expand Down Expand Up @@ -478,7 +478,7 @@ where
}
}

impl<'a, E> MultipleVersionEntry<'a, E>
impl<'a, E> VersionedEntry<'a, E>
where
E: VersionedMemtableEntry<'a>,
E::Key: Type,
Expand All @@ -502,7 +502,7 @@ where
self
.key
.raw()
.expect("MultipleVersionEntry's raw key cannot be None")
.expect("VersionedEntry's raw key cannot be None")
}

/// Returns the value of the entry.
Expand All @@ -518,7 +518,7 @@ where
None => None,
Some(v) => Some(
v.raw()
.expect("MultipleVersionEntry's raw value cannot be None if value exists"),
.expect("VersionedEntry's raw value cannot be None if value exists"),
),
}
}
Expand Down
58 changes: 21 additions & 37 deletions src/wal/multiple_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::{
memtable::{BaseTable, MultipleVersionMemtable, VersionedMemtableEntry},
sealed::{Constructable, MultipleVersionWalReader, Wal},
types::{
multiple_version::{Entry, MultipleVersionEntry},
multiple_version::{Entry, VersionedEntry},
BufWriter, KeyBuilder, ValueBuilder,
},
Options,
Expand Down Expand Up @@ -135,7 +135,7 @@ pub trait Reader: Constructable {
fn iter_all_versions(
&self,
version: u64,
) -> MultipleVersionIter<
) -> IterAll<
'_,
<<Self::Wal as Wal<Self::Checksumer>>::Memtable as MultipleVersionMemtable>::IterAll<'_>,
Self::Memtable,
Expand All @@ -148,7 +148,7 @@ pub trait Reader: Constructable {
<Self::Memtable as BaseTable>::Value: Type,
for<'a> <Self::Memtable as BaseTable>::Item<'a>: VersionedMemtableEntry<'a>,
{
MultipleVersionIter::new(MultipleVersionBaseIter::new(
IterAll::new(MultipleVersionBaseIter::new(
version,
self.as_wal().iter_all_versions(version),
))
Expand Down Expand Up @@ -185,7 +185,7 @@ pub trait Reader: Constructable {
&'a self,
version: u64,
range: R,
) -> MultipleVersionRange<'a, R, Q, <Self::Wal as Wal<Self::Checksumer>>::Memtable>
) -> RangeAll<'a, R, Q, <Self::Wal as Wal<Self::Checksumer>>::Memtable>
where
R: RangeBounds<Q> + 'a,
Q: ?Sized + Comparable<<<Self::Memtable as BaseTable>::Key as Type>::Ref<'a>>,
Expand All @@ -198,7 +198,7 @@ pub trait Reader: Constructable {
for<'b> <Self::Memtable as MultipleVersionMemtable>::VersionedItem<'b>:
VersionedMemtableEntry<'b>,
{
MultipleVersionRange::new(MultipleVersionBaseIter::new(
RangeAll::new(MultipleVersionBaseIter::new(
version,
self
.as_wal()
Expand Down Expand Up @@ -329,9 +329,7 @@ pub trait Reader: Constructable {
fn first_versioned(
&self,
version: u64,
) -> Option<
MultipleVersionEntry<'_, <Self::Memtable as MultipleVersionMemtable>::VersionedItem<'_>>,
>
) -> Option<VersionedEntry<'_, <Self::Memtable as MultipleVersionMemtable>::VersionedItem<'_>>>
where
Self::Memtable: MultipleVersionMemtable,
<Self::Memtable as BaseTable>::Key: Type + Ord,
Expand All @@ -345,7 +343,7 @@ pub trait Reader: Constructable {
self
.as_wal()
.first_versioned(version)
.map(|ent| MultipleVersionEntry::with_version(ent, version))
.map(|ent| VersionedEntry::with_version(ent, version))
}

/// Returns the last key-value pair in the map. The key in this pair is the maximum key in the wal.
Expand Down Expand Up @@ -373,9 +371,7 @@ pub trait Reader: Constructable {
fn last_versioned(
&self,
version: u64,
) -> Option<
MultipleVersionEntry<'_, <Self::Memtable as MultipleVersionMemtable>::VersionedItem<'_>>,
>
) -> Option<VersionedEntry<'_, <Self::Memtable as MultipleVersionMemtable>::VersionedItem<'_>>>
where
Self::Memtable: MultipleVersionMemtable,
<Self::Memtable as BaseTable>::Key: Type + Ord,
Expand All @@ -389,7 +385,7 @@ pub trait Reader: Constructable {
self
.as_wal()
.last_versioned(version)
.map(|ent| MultipleVersionEntry::with_version(ent, version))
.map(|ent| VersionedEntry::with_version(ent, version))
}

/// Returns `true` if the key exists in the WAL.
Expand Down Expand Up @@ -507,9 +503,7 @@ pub trait Reader: Constructable {
&'a self,
version: u64,
key: &Q,
) -> Option<
MultipleVersionEntry<'a, <Self::Memtable as MultipleVersionMemtable>::VersionedItem<'a>>,
>
) -> Option<VersionedEntry<'a, <Self::Memtable as MultipleVersionMemtable>::VersionedItem<'a>>>
where
Q: ?Sized + Comparable<<<Self::Memtable as BaseTable>::Key as Type>::Ref<'a>>,
Self::Memtable: MultipleVersionMemtable,
Expand All @@ -524,7 +518,7 @@ pub trait Reader: Constructable {
self
.as_wal()
.get_versioned(version, Query::<_, Q>::ref_cast(key))
.map(|ent| MultipleVersionEntry::with_version(ent, version))
.map(|ent| VersionedEntry::with_version(ent, version))
}

/// Gets the value associated with the key.
Expand Down Expand Up @@ -565,9 +559,7 @@ pub trait Reader: Constructable {
&self,
version: u64,
key: &[u8],
) -> Option<
MultipleVersionEntry<'_, <Self::Memtable as MultipleVersionMemtable>::VersionedItem<'_>>,
>
) -> Option<VersionedEntry<'_, <Self::Memtable as MultipleVersionMemtable>::VersionedItem<'_>>>
where
Self::Memtable: MultipleVersionMemtable,
<Self::Memtable as BaseTable>::Key: Type + Ord,
Expand All @@ -581,7 +573,7 @@ pub trait Reader: Constructable {
self
.as_wal()
.get_versioned(version, Slice::ref_cast(key))
.map(|ent| MultipleVersionEntry::with_version(ent, version))
.map(|ent| VersionedEntry::with_version(ent, version))
}

/// Returns a value associated to the highest element whose key is below the given bound.
Expand Down Expand Up @@ -618,9 +610,7 @@ pub trait Reader: Constructable {
&'a self,
version: u64,
bound: Bound<&Q>,
) -> Option<
MultipleVersionEntry<'a, <Self::Memtable as MultipleVersionMemtable>::VersionedItem<'a>>,
>
) -> Option<VersionedEntry<'a, <Self::Memtable as MultipleVersionMemtable>::VersionedItem<'a>>>
where
Q: ?Sized + Comparable<<<Self::Memtable as BaseTable>::Key as Type>::Ref<'a>>,
Self::Memtable: MultipleVersionMemtable,
Expand All @@ -635,7 +625,7 @@ pub trait Reader: Constructable {
self
.as_wal()
.upper_bound_versioned(version, bound.map(Query::ref_cast))
.map(|ent| MultipleVersionEntry::with_version(ent, version))
.map(|ent| VersionedEntry::with_version(ent, version))
}

/// Returns a value associated to the highest element whose key is below the given bound.
Expand Down Expand Up @@ -677,9 +667,7 @@ pub trait Reader: Constructable {
&self,
version: u64,
bound: Bound<&[u8]>,
) -> Option<
MultipleVersionEntry<'_, <Self::Memtable as MultipleVersionMemtable>::VersionedItem<'_>>,
>
) -> Option<VersionedEntry<'_, <Self::Memtable as MultipleVersionMemtable>::VersionedItem<'_>>>
where
Self::Memtable: MultipleVersionMemtable,
<Self::Memtable as BaseTable>::Key: Type + Ord,
Expand All @@ -693,7 +681,7 @@ pub trait Reader: Constructable {
self
.as_wal()
.upper_bound_versioned(version, bound.map(Slice::ref_cast))
.map(|ent| MultipleVersionEntry::with_version(ent, version))
.map(|ent| VersionedEntry::with_version(ent, version))
}

/// Returns a value associated to the lowest element whose key is above the given bound.
Expand Down Expand Up @@ -731,9 +719,7 @@ pub trait Reader: Constructable {
&'a self,
version: u64,
bound: Bound<&Q>,
) -> Option<
MultipleVersionEntry<'a, <Self::Memtable as MultipleVersionMemtable>::VersionedItem<'a>>,
>
) -> Option<VersionedEntry<'a, <Self::Memtable as MultipleVersionMemtable>::VersionedItem<'a>>>
where
Q: ?Sized + Comparable<<<Self::Memtable as BaseTable>::Key as Type>::Ref<'a>>,
Self::Memtable: MultipleVersionMemtable,
Expand All @@ -748,7 +734,7 @@ pub trait Reader: Constructable {
self
.as_wal()
.lower_bound_versioned(version, bound.map(Query::ref_cast))
.map(|ent| MultipleVersionEntry::with_version(ent, version))
.map(|ent| VersionedEntry::with_version(ent, version))
}

/// Returns a value associated to the lowest element whose key is above the given bound.
Expand Down Expand Up @@ -791,9 +777,7 @@ pub trait Reader: Constructable {
&self,
version: u64,
bound: Bound<&[u8]>,
) -> Option<
MultipleVersionEntry<'_, <Self::Memtable as MultipleVersionMemtable>::VersionedItem<'_>>,
>
) -> Option<VersionedEntry<'_, <Self::Memtable as MultipleVersionMemtable>::VersionedItem<'_>>>
where
Self::Memtable: MultipleVersionMemtable,
<Self::Memtable as BaseTable>::Key: Type + Ord,
Expand All @@ -810,7 +794,7 @@ pub trait Reader: Constructable {
version,
bound.map(Slice::<<Self::Memtable as BaseTable>::Key>::ref_cast),
)
.map(|ent| MultipleVersionEntry::with_version(ent, version))
.map(|ent| VersionedEntry::with_version(ent, version))
}
}

Expand Down
Loading

0 comments on commit f24d3e9

Please sign in to comment.