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 12, 2024
1 parent caa21c1 commit 880aa21
Show file tree
Hide file tree
Showing 8 changed files with 156 additions and 153 deletions.
16 changes: 8 additions & 8 deletions src/generic/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,16 +553,16 @@ where
/// If less=false, it finds leftmost node such that node.key > key (if allow_equal=false) or
/// node.key >= key (if allow_equal=true).
/// Returns the node found. The bool returned is true if the node has key equal to given key.
unsafe fn find_near<'a, Q>(
&'a self,
unsafe fn find_near<Q>(
&self,
version: Version,
key: &Q,
less: bool,
allow_equal: bool,
) -> (Option<<A::Node as Node>::Pointer>, bool)
where
Q: ?Sized,
C: TypeRefQueryComparator<'a, K, Q>,
C: TypeRefQueryComparator<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, K>,
C: TypeRefComparator<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, K>,
C: TypeRefComparator<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, K>,
C: TypeRefComparator<K>,
{
let nd_key = self
.arena
Expand Down Expand Up @@ -909,7 +909,7 @@ where
upsert: bool,
) -> Result<UpdateOk<'a, 'b, K, V, C, A, R>, Among<K::Error, E, Error>>
where
C: TypeRefComparator<'a, K>,
C: TypeRefComparator<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, K>,
C: TypeRefComparator<K>,
{
match this {
Among::Right(key) => match other {
Expand Down
50 changes: 27 additions & 23 deletions src/generic/list/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ use core::{
ops::{Bound, RangeBounds},
};

use dbutils::{buffer::VacantBuffer, equivalentor::TypeRefQueryComparator, types::Type};
use dbutils::{
buffer::VacantBuffer,
equivalentor::{TypeRefComparator, TypeRefQueryComparator},
types::Type,
};
use rarena_allocator::Allocator as _;

use crate::{
Expand Down Expand Up @@ -166,58 +170,58 @@ where
/// This method will return `false` if the entry is marked as removed. If you want to check if the key exists even if it is marked as removed,
/// you can use [`contains_key_with_tombstone`](SkipList::contains_key_with_tombstone).
#[inline]
pub fn contains_key<'a, Q>(&'a self, version: Version, key: &Q) -> bool
pub fn contains_key<Q>(&self, version: Version, key: &Q) -> bool
where
Q: ?Sized,
C: TypeRefQueryComparator<'a, K, Q>,
C: TypeRefQueryComparator<K, Q>,
{
self.get(version, key).is_some()
}

/// Returns `true` if the key exists in the map, even if it is marked as removed.
#[inline]
pub fn contains_key_with_tombstone<'a, Q>(&'a self, version: Version, key: &Q) -> bool
pub fn contains_key_with_tombstone<Q>(&self, version: Version, key: &Q) -> bool
where
Q: ?Sized,
C: TypeRefQueryComparator<'a, K, Q>,
C: TypeRefQueryComparator<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, C, A, RC>>
pub fn first(&self, version: Version) -> Option<EntryRef<'_, K, V, Active, C, A, RC>>
where
C: TypeRefQueryComparator<'a, K, K::Ref<'a>>,
C: TypeRefComparator<K>,
{
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, C, A, RC>>
pub fn last(&self, version: Version) -> Option<EntryRef<'_, K, V, Active, C, A, RC>>
where
C: TypeRefQueryComparator<'a, K, K::Ref<'a>>,
C: TypeRefComparator<K>,
{
self.iter(version).last()
}

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

/// Returns the last entry in the map.
pub fn last_with_tombstone<'a>(
&'a self,
pub fn last_with_tombstone(
&self,
version: Version,
) -> Option<EntryRef<'a, K, V, MaybeTombstone, C, A, RC>>
) -> Option<EntryRef<'_, K, V, MaybeTombstone, C, A, RC>>
where
C: TypeRefQueryComparator<'a, K, K::Ref<'a>>,
C: TypeRefComparator<K>,
{
self.iter_all(version).last()
}
Expand All @@ -233,7 +237,7 @@ where
) -> Option<EntryRef<'a, K, V, Active, C, A, RC>>
where
Q: ?Sized,
C: TypeRefQueryComparator<'a, K, Q>,
C: TypeRefQueryComparator<K, Q>,
{
unsafe {
let (n, eq) = self.find_near(version, key, false, true); // findLessOrEqual.
Expand Down Expand Up @@ -279,7 +283,7 @@ where
) -> Option<EntryRef<'a, K, V, MaybeTombstone, C, A, RC>>
where
Q: ?Sized,
C: TypeRefQueryComparator<'a, K, Q>,
C: TypeRefQueryComparator<K, Q>,
{
unsafe {
let (n, eq) = self.find_near(version, key, false, true); // findLessOrEqual.
Expand Down Expand Up @@ -327,7 +331,7 @@ where
) -> Option<EntryRef<'a, K, V, Active, C, A, RC>>
where
Q: ?Sized,
C: TypeRefQueryComparator<'a, K, Q>,
C: TypeRefQueryComparator<K, Q>,
{
self.iter(version).seek_upper_bound(upper)
}
Expand All @@ -341,7 +345,7 @@ where
) -> Option<EntryRef<'a, K, V, Active, C, A, RC>>
where
Q: ?Sized,
C: TypeRefQueryComparator<'a, K, Q>,
C: TypeRefQueryComparator<K, Q>,
{
self.iter(version).seek_lower_bound(lower)
}
Expand All @@ -355,7 +359,7 @@ where
) -> Option<EntryRef<'a, K, V, MaybeTombstone, C, A, RC>>
where
Q: ?Sized,
C: TypeRefQueryComparator<'a, K, Q>,
C: TypeRefQueryComparator<K, Q>,
{
self.iter_all(version).seek_upper_bound(upper)
}
Expand All @@ -369,7 +373,7 @@ where
) -> Option<EntryRef<'a, K, V, MaybeTombstone, C, A, RC>>
where
Q: ?Sized,
C: TypeRefQueryComparator<'a, K, Q>,
C: TypeRefQueryComparator<K, Q>,
{
self.iter_all(version).seek_lower_bound(lower)
}
Expand Down
20 changes: 10 additions & 10 deletions src/generic/list/api/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ where
value: impl Into<MaybeStructured<'b, V>>,
) -> Result<Option<EntryRef<'a, K, V, Active, C, A, R>>, Among<K::Error, V::Error, Error>>
where
C: TypeRefComparator<'a, K>,
C: TypeRefComparator<K>,
{
self.insert_at_height(version, self.random_height(), key, value)
}
Expand All @@ -53,7 +53,7 @@ where
value: impl Into<MaybeStructured<'b, V>>,
) -> Result<Option<EntryRef<'a, K, V, Active, C, A, R>>, Among<K::Error, V::Error, Error>>
where
C: TypeRefComparator<'a, K>,
C: TypeRefComparator<K>,
{
let key: MaybeStructured<'_, K> = key.into();
let value: MaybeStructured<'_, V> = value.into();
Expand Down Expand Up @@ -107,7 +107,7 @@ where
value_builder: ValueBuilder<impl FnOnce(&mut VacantBuffer<'a>) -> Result<usize, E>>,
) -> Result<Option<EntryRef<'a, K, V, Active, C, A, R>>, Among<K::Error, E, Error>>
where
C: TypeRefComparator<'a, K>,
C: TypeRefComparator<K>,
{
let key: MaybeStructured<'_, K> = key.into();
self
Expand Down Expand Up @@ -150,7 +150,7 @@ where
value: impl Into<MaybeStructured<'b, V>>,
) -> Result<Option<EntryRef<'a, K, V, Active, C, A, R>>, Among<K::Error, V::Error, Error>>
where
C: TypeRefComparator<'a, K>,
C: TypeRefComparator<K>,
{
let key: MaybeStructured<'_, K> = key.into();
let value: MaybeStructured<'_, V> = value.into();
Expand Down Expand Up @@ -204,7 +204,7 @@ where
value_builder: ValueBuilder<impl FnOnce(&mut VacantBuffer<'a>) -> Result<usize, E>>,
) -> Result<Option<EntryRef<'a, K, V, Active, C, A, R>>, Among<K::Error, E, Error>>
where
C: TypeRefComparator<'a, K>,
C: TypeRefComparator<K>,
{
let key: MaybeStructured<'_, K> = key.into();
self
Expand Down Expand Up @@ -252,7 +252,7 @@ where
value_builder: ValueBuilder<impl FnOnce(&mut VacantBuffer<'a>) -> Result<usize, VE>>,
) -> Result<Option<EntryRef<'a, K, V, Active, C, A, R>>, Among<KE, VE, Error>>
where
C: TypeRefComparator<'a, K>,
C: TypeRefComparator<K>,
{
self
.validate(height, key_builder.size(), value_builder.size())
Expand Down Expand Up @@ -308,7 +308,7 @@ where
value_builder: ValueBuilder<impl FnOnce(&mut VacantBuffer<'a>) -> Result<usize, VE>>,
) -> Result<Option<EntryRef<'a, K, V, Active, C, A, R>>, Among<KE, VE, Error>>
where
C: TypeRefComparator<'a, K>,
C: TypeRefComparator<K>,
{
self
.validate(height, key_builder.size(), value_builder.size())
Expand Down Expand Up @@ -365,7 +365,7 @@ where
failure: Ordering,
) -> Result<Option<EntryRef<'a, K, V, Active, C, A, R>>, Either<K::Error, Error>>
where
C: TypeRefComparator<'a, K>,
C: TypeRefComparator<K>,
{
let key: MaybeStructured<'_, K> = key.into();
self
Expand Down Expand Up @@ -418,7 +418,7 @@ where
key: impl Into<MaybeStructured<'b, K>>,
) -> Result<Option<EntryRef<'a, K, V, Active, C, A, R>>, Either<K::Error, Error>>
where
C: TypeRefComparator<'a, K>,
C: TypeRefComparator<K>,
{
let key: MaybeStructured<'_, K> = key.into();
self
Expand Down Expand Up @@ -470,7 +470,7 @@ where
key_builder: KeyBuilder<impl FnOnce(&mut VacantBuffer<'a>) -> Result<usize, E>>,
) -> Result<Option<EntryRef<'a, K, V, Active, C, A, R>>, Either<E, Error>>
where
C: TypeRefComparator<'a, K>,
C: TypeRefComparator<K>,
{
self
.validate(height, key_builder.size(), 0)
Expand Down
2 changes: 1 addition & 1 deletion src/generic/list/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ where
S: State<'a>,
A: Allocator,
R: RefCounter,
C: TypeRefComparator<'a, K>,
C: TypeRefComparator<K>,
{
/// Returns the next entry in the map.
#[inline]
Expand Down
20 changes: 10 additions & 10 deletions src/generic/list/iterator/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ where
S: State<'a>,
A: Allocator,
R: RefCounter,
C: TypeRefComparator<'a, K>,
C: TypeRefComparator<K>,
{
/// Advances to the next position. Returns the key and value if the
/// iterator is pointing at a valid entry, and `None` otherwise.
Expand Down Expand Up @@ -206,7 +206,7 @@ where
S: State<'a>,
A: Allocator,
R: RefCounter,
C: TypeRefComparator<'a, K>,
C: TypeRefComparator<K>,
{
/// Moves the iterator to the highest element whose key is below the given bound.
/// If no such element is found then `None` is returned.
Expand All @@ -218,7 +218,7 @@ where
) -> Option<EntryRef<'a, K, V, S, C, A, R>>
where
QR: ?Sized,
C: TypeRefQueryComparator<'a, K, QR>,
C: TypeRefQueryComparator<K, QR>,
{
self.head = None;
self.tail = None;
Expand All @@ -244,7 +244,7 @@ where
) -> Option<EntryRef<'a, K, V, S, C, A, R>>
where
QR: ?Sized,
C: TypeRefQueryComparator<'a, K, QR>,
C: TypeRefQueryComparator<K, QR>,
{
self.head = None;
self.tail = None;
Expand All @@ -266,7 +266,7 @@ where
fn seek_ge<QR>(&self, key: &QR) -> Option<EntryRef<'a, K, V, S, C, A, R>>
where
QR: ?Sized,
C: TypeRefQueryComparator<'a, K, QR>,
C: TypeRefQueryComparator<K, QR>,
{
unsafe {
let (n, _) = self.map.find_near(self.version, key, false, true);
Expand All @@ -292,7 +292,7 @@ where
fn seek_gt<QR>(&self, key: &QR) -> Option<EntryRef<'a, K, V, S, C, A, R>>
where
QR: ?Sized,
C: TypeRefQueryComparator<'a, K, QR>,
C: TypeRefQueryComparator<K, QR>,
{
unsafe {
let (n, _) = self.map.find_near(Version::MIN, key, false, false);
Expand All @@ -318,7 +318,7 @@ where
fn seek_le<QR>(&self, key: &QR) -> Option<EntryRef<'a, K, V, S, C, A, R>>
where
QR: ?Sized,
C: TypeRefQueryComparator<'a, K, QR>,
C: TypeRefQueryComparator<K, QR>,
{
unsafe {
let (n, _) = self.map.find_near(Version::MIN, key, true, true); // find less or equal.
Expand All @@ -344,7 +344,7 @@ where
fn seek_lt<QR>(&self, key: &QR) -> Option<EntryRef<'a, K, V, S, C, A, R>>
where
QR: ?Sized,
C: TypeRefQueryComparator<'a, K, QR>,
C: TypeRefQueryComparator<K, QR>,
{
unsafe {
let (n, _) = self.map.find_near(self.version, key, true, false); // find less or equal.
Expand Down Expand Up @@ -386,7 +386,7 @@ where
S: State<'a>,
A: Allocator,
R: RefCounter,
C: TypeRefComparator<'a, K>,
C: TypeRefComparator<K>,
{
type Item = EntryRef<'a, K, V, S, C, A, R>;

Expand Down Expand Up @@ -429,7 +429,7 @@ where
S: State<'a>,
A: Allocator,
R: RefCounter,
C: TypeRefComparator<'a, K>,
C: TypeRefComparator<K>,
{
#[inline]
fn next_back(&mut self) -> Option<Self::Item> {
Expand Down
Loading

0 comments on commit 880aa21

Please sign in to comment.