Skip to content

Commit

Permalink
bumpup dbutils version
Browse files Browse the repository at this point in the history
  • Loading branch information
al8n committed Dec 8, 2024
1 parent 00c4609 commit 23c4cbf
Show file tree
Hide file tree
Showing 16 changed files with 148 additions and 152 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 = "skl"
version = "0.22.7"
version = "0.22.8"
edition = "2021"
rust-version = "1.81.0"
repository = "https://github.com/al8n/skl"
Expand Down
10 changes: 3 additions & 7 deletions src/dynamic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ pub mod entry {
pub use super::list::EntryRef;
}

pub use dbutils::equivalentor::{BytesComparator, BytesEquivalentor, BytesRangeComparator};

/// Ascend is a comparator that compares byte slices in ascending order.
pub type Ascend = dbutils::equivalentor::Ascend<[u8]>;

/// Ascend is a comparator that compares byte slices in ascending order.
pub type Descend = dbutils::equivalentor::Descend<[u8]>;
pub use dbutils::equivalentor::{
Ascend, BytesComparator, BytesEquivalentor, BytesRangeComparator, Descend,
};
2 changes: 1 addition & 1 deletion src/dynamic/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ mod memmap;

/// A builder for creating a dynamic key-value `SkipMap`.
#[derive(Debug, Clone)]
pub struct Builder<C = Ascend<[u8]>> {
pub struct Builder<C = Ascend> {
options: Options,
cmp: C,
}
Expand Down
2 changes: 1 addition & 1 deletion src/dynamic/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type UpdateOk<'a, 'b, A, RC, C> = Either<
/// A fast, cocnurrent map implementation based on skiplist that supports forward
/// and backward iteration.
#[derive(Debug)]
pub struct SkipList<A, R, C = Ascend<[u8]>>
pub struct SkipList<A, R, C = Ascend>
where
A: Allocator,
R: RefCounter,
Expand Down
4 changes: 2 additions & 2 deletions src/dynamic/multiple_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub mod unsync {
///
/// If you want to use in concurrent environment, you can use [`multiple_version::sync::SkipMap`](crate::dynamic::multiple_version::sync::SkipMap).
#[repr(transparent)]
pub struct SkipMap<C = Ascend<[u8]>>(SkipList<C>);
pub struct SkipMap<C = Ascend>(SkipList<C>);

impl<C: Clone> Clone for SkipMap<C> {
#[inline]
Expand Down Expand Up @@ -145,7 +145,7 @@ pub mod sync {
///
/// If you want to use in non-concurrent environment, you can use [`multiple_version::unsync::SkipMap`](crate::dynamic::multiple_version::unsync::SkipMap).
#[repr(transparent)]
pub struct SkipMap<C = Ascend<[u8]>>(SkipList<C>);
pub struct SkipMap<C = Ascend>(SkipList<C>);

impl<C: Clone> Clone for SkipMap<C> {
#[inline]
Expand Down
4 changes: 2 additions & 2 deletions src/dynamic/unique.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub mod unsync {
///
/// If you want to use in concurrent environment, you can use [`unique::sync::SkipMap`](crate::dynamic::unique::sync::SkipMap).
#[repr(transparent)]
pub struct SkipMap<C = Ascend<[u8]>>(SkipList<C>);
pub struct SkipMap<C = Ascend>(SkipList<C>);

impl<C: Clone> Clone for SkipMap<C> {
#[inline]
Expand Down Expand Up @@ -143,7 +143,7 @@ pub mod sync {
///
/// If you want to use in non-concurrent environment, you can use [`unique::unsync::SkipMap`](crate::dynamic::unique::unsync::SkipMap).
#[repr(transparent)]
pub struct SkipMap<C = Ascend<[u8]>>(SkipList<C>);
pub struct SkipMap<C = Ascend>(SkipList<C>);

impl<C: Clone> Clone for SkipMap<C> {
#[inline]
Expand Down
24 changes: 12 additions & 12 deletions src/generic/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ mod memmap;

/// A builder for creating a generic key-value `SkipMap`.
#[derive(Debug)]
pub struct Builder<C = Ascend<[u8]>> {
pub struct Builder<C = Ascend> {
options: Options,
cmp: C,
}
Expand Down Expand Up @@ -57,9 +57,9 @@ impl<C> Builder<C> {
/// ## Example
///
/// ```rust
/// use skl::generic::{Builder, Ascend};
/// use skl::generic::{Builder, Descend};
///
/// let builder = Builder::with(Ascend::<[u8]>::new());
/// let builder = Builder::with(Descend::new());
/// ```
#[inline]
pub const fn with(cmp: C) -> Self {
Expand All @@ -78,7 +78,7 @@ impl<C: Default> Builder<C> {
/// ```rust
/// use skl::generic::{Builder, Ascend};
///
/// let builder = Builder::<Ascend<str>>::new();
/// let builder = Builder::<Ascend>::new();
/// ```
#[inline]
pub fn new() -> Self {
Expand All @@ -97,7 +97,7 @@ impl<C> Builder<C> {
/// ```rust
/// use skl::generic::{Builder, Ascend};
///
/// let builder = Builder::<Ascend<str>>::new().comparator();
/// let builder = Builder::<Ascend>::new().comparator();
/// ```
#[inline]
pub const fn comparator(&self) -> &C {
Expand All @@ -109,11 +109,11 @@ impl<C> Builder<C> {
/// ## Example
///
/// ```rust
/// use skl::generic::{Builder, Ascend};
/// use skl::generic::{Builder, Ascend, Descend};
///
/// let builder = Builder::<Ascend<[u8]>>::new().with_comparator(Ascend::<Vec<u8>>::new());
/// let builder = Builder::<Ascend>::new().with_comparator(Descend::new());
///
/// assert_eq!(builder.comparator(), &Ascend::<Vec<u8>>::new());
/// assert_eq!(builder.comparator(), &Descend::new());
/// ```
#[inline]
pub fn with_comparator<NC>(self, cmp: NC) -> Builder<NC> {
Expand All @@ -128,9 +128,9 @@ impl<C> Builder<C> {
/// ## Example
///
/// ```rust
/// use skl::generic::{Builder, Ascend};
/// use skl::generic::{Builder, Descend};
///
/// let builder = Builder::<Ascend<str>>::new();
/// let builder = Builder::<Descend>::new();
/// let options = builder.options();
/// ```
#[inline]
Expand Down Expand Up @@ -179,9 +179,9 @@ impl<C> Builder<C> {
/// ```rust
/// use skl::generic::{unique::sync, multiple_version::unsync, Builder, Ascend};
///
/// let map = Builder::<Ascend<[u8]>>::new().with_capacity(1024).alloc::<sync::SkipMap<[u8], [u8]>>().unwrap();
/// let map = Builder::<Ascend>::new().with_capacity(1024).alloc::<sync::SkipMap<[u8], [u8]>>().unwrap();
///
/// let arena = Builder::<Ascend<[u8]>>::new().with_capacity(1024).alloc::<unsync::SkipMap<[u8], [u8]>>().unwrap();
/// let arena = Builder::<Ascend>::new().with_capacity(1024).alloc::<unsync::SkipMap<[u8], [u8]>>().unwrap();
/// ```
#[inline]
pub fn alloc<T>(self) -> Result<T, Error>
Expand Down
4 changes: 2 additions & 2 deletions src/generic/builder/memmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ impl<C> Builder<C> {
/// ```rust
/// use skl::generic::{unique::sync, multiple_version::unsync, Builder, Ascend};
///
/// let map = Builder::<Ascend<[u8]>>::new().with_capacity(1024).map_anon::<sync::SkipMap<[u8], [u8]>>().unwrap();
/// let map = Builder::<Ascend>::new().with_capacity(1024).map_anon::<sync::SkipMap<[u8], [u8]>>().unwrap();
///
/// let arena = Builder::<Ascend<[u8]>>::new().with_capacity(1024).map_anon::<unsync::SkipMap<[u8], [u8]>>().unwrap();
/// let arena = Builder::<Ascend>::new().with_capacity(1024).map_anon::<unsync::SkipMap<[u8], [u8]>>().unwrap();
/// ```
#[cfg(all(feature = "memmap", not(target_family = "wasm")))]
#[cfg_attr(docsrs, doc(cfg(all(feature = "memmap", not(target_family = "wasm")))))]
Expand Down
12 changes: 6 additions & 6 deletions src/generic/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ where
) -> (Option<<A::Node as Node>::Pointer>, bool)
where
Q: ?Sized,
C: TypeRefQueryComparator<'a, Q, Type = K>,
C: TypeRefQueryComparator<'a, K, Q>,
{
let mut x = self.head;
let mut level = self.meta().height() as usize - 1;
Expand Down Expand Up @@ -662,7 +662,7 @@ where
returned_when_found: bool,
) -> (bool, Option<Pointer>, Option<<A::Node as Node>::Pointer>)
where
C: TypeRefComparator<'a, Type = K>,
C: TypeRefComparator<'a, K>,
{
let list_height = self.meta().height() as u32;
let mut level = 0;
Expand Down Expand Up @@ -741,7 +741,7 @@ where
start: <A::Node as Node>::Pointer,
) -> FindResult<<A::Node as Node>::Pointer>
where
C: TypeRefComparator<'a, Type = K>,
C: TypeRefComparator<'a, K>,
{
let mut prev = start;

Expand Down Expand Up @@ -847,7 +847,7 @@ where
key: Among<&'a [u8], &'b [u8], &'b K>,
) -> bool
where
C: TypeRefComparator<'a, Type = K>,
C: TypeRefComparator<'a, K>,
{
let nd_key = self
.arena
Expand Down Expand Up @@ -909,7 +909,7 @@ where
upsert: bool,
) -> Result<UpdateOk<'a, 'b, K, V, A, R, C>, Among<K::Error, E, Error>>
where
C: TypeRefComparator<'a, Type = K>,
C: TypeRefComparator<'a, K>,
{
let is_remove = key.is_remove();

Expand Down Expand Up @@ -1334,7 +1334,7 @@ where
other: Either<&'a [u8], &K::Ref<'a>>,
) -> cmp::Ordering
where
C: TypeRefComparator<'a, Type = K>,
C: TypeRefComparator<'a, K>,
{
match this {
Among::Right(key) => match other {
Expand Down
24 changes: 12 additions & 12 deletions src/generic/list/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ where
pub fn contains_key<'a, Q>(&'a self, version: Version, key: &Q) -> bool
where
Q: ?Sized,
C: TypeRefQueryComparator<'a, Q, Type = K>,
C: TypeRefQueryComparator<'a, K, Q>,
{
self.get(version, key).is_some()
}
Expand All @@ -179,23 +179,23 @@ where
pub fn contains_key_with_tombstone<'a, Q>(&'a self, version: Version, key: &Q) -> bool
where
Q: ?Sized,
C: TypeRefQueryComparator<'a, Q, Type = K>,
C: TypeRefQueryComparator<'a, K, Q>,
{
self.get_with_tombstone(version, key).is_some()
}

/// Returns the first entry in the map.
pub fn first<'a>(&'a self, version: Version) -> Option<EntryRef<'a, K, V, Active, A, RC, C>>
where
C: TypeRefQueryComparator<'a, K::Ref<'a>, Type = K>,
C: TypeRefQueryComparator<'a, K, K::Ref<'a>>,
{
self.iter(version).next()
}

/// Returns the last entry in the map.
pub fn last<'a>(&'a self, version: Version) -> Option<EntryRef<'a, K, V, Active, A, RC, C>>
where
C: TypeRefQueryComparator<'a, K::Ref<'a>, Type = K>,
C: TypeRefQueryComparator<'a, K, K::Ref<'a>>,
{
self.iter(version).last()
}
Expand All @@ -206,7 +206,7 @@ where
version: Version,
) -> Option<EntryRef<'a, K, V, MaybeTombstone, A, RC, C>>
where
C: TypeRefQueryComparator<'a, K::Ref<'a>, Type = K>,
C: TypeRefQueryComparator<'a, K, K::Ref<'a>>,
{
self.iter_with_tombstone(version).next()
}
Expand All @@ -217,7 +217,7 @@ where
version: Version,
) -> Option<EntryRef<'a, K, V, MaybeTombstone, A, RC, C>>
where
C: TypeRefQueryComparator<'a, K::Ref<'a>, Type = K>,
C: TypeRefQueryComparator<'a, K, K::Ref<'a>>,
{
self.iter_with_tombstone(version).last()
}
Expand All @@ -233,7 +233,7 @@ where
) -> Option<EntryRef<'a, K, V, Active, A, RC, C>>
where
Q: ?Sized,
C: TypeRefQueryComparator<'a, Q, Type = K>,
C: TypeRefQueryComparator<'a, K, Q>,
{
unsafe {
let (n, eq) = self.find_near(version, key, false, true); // findLessOrEqual.
Expand Down Expand Up @@ -279,7 +279,7 @@ where
) -> Option<EntryRef<'a, K, V, MaybeTombstone, A, RC, C>>
where
Q: ?Sized,
C: TypeRefQueryComparator<'a, Q, Type = K>,
C: TypeRefQueryComparator<'a, K, Q>,
{
unsafe {
let (n, eq) = self.find_near(version, key, false, true); // findLessOrEqual.
Expand Down Expand Up @@ -327,7 +327,7 @@ where
) -> Option<EntryRef<'a, K, V, Active, A, RC, C>>
where
Q: ?Sized,
C: TypeRefQueryComparator<'a, Q, Type = K>,
C: TypeRefQueryComparator<'a, K, Q>,
{
self.iter(version).map().seek_upper_bound(upper)
}
Expand All @@ -341,7 +341,7 @@ where
) -> Option<EntryRef<'a, K, V, Active, A, RC, C>>
where
Q: ?Sized,
C: TypeRefQueryComparator<'a, Q, Type = K>,
C: TypeRefQueryComparator<'a, K, Q>,
{
self.iter(version).map().seek_lower_bound(lower)
}
Expand All @@ -355,7 +355,7 @@ where
) -> Option<EntryRef<'a, K, V, MaybeTombstone, A, RC, C>>
where
Q: ?Sized,
C: TypeRefQueryComparator<'a, Q, Type = K>,
C: TypeRefQueryComparator<'a, K, Q>,
{
self
.iter_with_tombstone(version)
Expand All @@ -372,7 +372,7 @@ where
) -> Option<EntryRef<'a, K, V, MaybeTombstone, A, RC, C>>
where
Q: ?Sized,
C: TypeRefQueryComparator<'a, Q, Type = K>,
C: TypeRefQueryComparator<'a, K, Q>,
{
self
.iter_with_tombstone(version)
Expand Down
Loading

0 comments on commit 23c4cbf

Please sign in to comment.