pub struct TestDB<K, V> {
pub rows: Arc<RwLock<BTreeMap<Vec<u8>, Vec<u8>>>>,
pub name: String,
/* private fields */
}
Expand description
An interface to a btree map backed sally database. This is mainly intended for tests and performing benchmark comparisons
Fields§
§rows: Arc<RwLock<BTreeMap<Vec<u8>, Vec<u8>>>>
§name: String
Implementations§
Trait Implementations§
Source§impl<'a, K, V> Map<'a, K, V> for TestDB<K, V>
impl<'a, K, V> Map<'a, K, V> for TestDB<K, V>
type Error = TypedStoreError
type Iterator = Empty<(K, V)>
type SafeIterator = TestDBIter<'a, K, V>
type Keys = TestDBKeys<'a, K>
type Values = TestDBValues<'a, V>
Source§fn contains_key(&self, key: &K) -> Result<bool, Self::Error>
fn contains_key(&self, key: &K) -> Result<bool, Self::Error>
Returns true if the map contains a value for the specified key.
Source§fn get(&self, key: &K) -> Result<Option<V>, Self::Error>
fn get(&self, key: &K) -> Result<Option<V>, Self::Error>
Returns the value for the given key from the map, if it exists.
Source§fn get_raw_bytes(&self, key: &K) -> Result<Option<Vec<u8>>, Self::Error>
fn get_raw_bytes(&self, key: &K) -> Result<Option<Vec<u8>>, Self::Error>
Returns the raw value (serialized bytes) for the given key from the map,
if it exists.
Source§fn insert(&self, key: &K, value: &V) -> Result<(), Self::Error>
fn insert(&self, key: &K, value: &V) -> Result<(), Self::Error>
Inserts the given key-value pair into the map.
Source§fn remove(&self, key: &K) -> Result<(), Self::Error>
fn remove(&self, key: &K) -> Result<(), Self::Error>
Removes the entry for the given key from the map.
Source§fn delete_file_in_range(&self, from: &K, to: &K) -> Result<(), TypedStoreError>
fn delete_file_in_range(&self, from: &K, to: &K) -> Result<(), TypedStoreError>
Removes every key-value pair from the map by deleting the underlying
file.
Source§fn schedule_delete_all(&self) -> Result<(), TypedStoreError>
fn schedule_delete_all(&self) -> Result<(), TypedStoreError>
Uses delete range on the entire key range
Source§fn unbounded_iter(&'a self) -> Self::Iterator
fn unbounded_iter(&'a self) -> Self::Iterator
Returns an unbounded iterator visiting each key-value pair in the map.
This is potentially unsafe as it can perform a full table scan
Source§fn iter_with_bounds(
&'a self,
_lower_bound: Option<K>,
_upper_bound: Option<K>,
) -> Self::Iterator
fn iter_with_bounds( &'a self, _lower_bound: Option<K>, _upper_bound: Option<K>, ) -> Self::Iterator
Returns an iterator visiting each key-value pair within the specified
bounds in the map.
Source§fn range_iter(&'a self, _range: impl RangeBounds<K>) -> Self::Iterator
fn range_iter(&'a self, _range: impl RangeBounds<K>) -> Self::Iterator
Similar to
iter_with_bounds
but allows specifying
inclusivity/exclusivity of ranges explicitly. TODO: find better nameSource§fn safe_iter(&'a self) -> Self::SafeIterator
fn safe_iter(&'a self) -> Self::SafeIterator
Same as
iter
but performs status check.fn safe_iter_with_bounds( &'a self, _lower_bound: Option<K>, _upper_bound: Option<K>, ) -> Self::SafeIterator
fn safe_range_iter(&'a self, _range: impl RangeBounds<K>) -> Self::SafeIterator
Source§fn try_catch_up_with_primary(&self) -> Result<(), Self::Error>
fn try_catch_up_with_primary(&self) -> Result<(), Self::Error>
Try to catch up with primary when running as secondary
Source§fn multi_contains_keys<J>(
&self,
keys: impl IntoIterator<Item = J>,
) -> Result<Vec<bool>, Self::Error>where
J: Borrow<K>,
fn multi_contains_keys<J>(
&self,
keys: impl IntoIterator<Item = J>,
) -> Result<Vec<bool>, Self::Error>where
J: Borrow<K>,
Returns true if the map contains a value for the specified key.
Source§fn multi_get<J>(
&self,
keys: impl IntoIterator<Item = J>,
) -> Result<Vec<Option<V>>, Self::Error>where
J: Borrow<K>,
fn multi_get<J>(
&self,
keys: impl IntoIterator<Item = J>,
) -> Result<Vec<Option<V>>, Self::Error>where
J: Borrow<K>,
Returns a vector of values corresponding to the keys provided,
non-atomically.
Source§fn multi_get_raw_bytes<J>(
&self,
keys: impl IntoIterator<Item = J>,
) -> Result<Vec<Option<Vec<u8>>>, Self::Error>where
J: Borrow<K>,
fn multi_get_raw_bytes<J>(
&self,
keys: impl IntoIterator<Item = J>,
) -> Result<Vec<Option<Vec<u8>>>, Self::Error>where
J: Borrow<K>,
Returns a vector of raw values corresponding to the keys provided,
non-atomically.
Source§fn chunked_multi_get<J>(
&self,
keys: impl IntoIterator<Item = J>,
_chunk_size: usize,
) -> Result<Vec<Option<V>>, Self::Error>where
J: Borrow<K>,
fn chunked_multi_get<J>(
&self,
keys: impl IntoIterator<Item = J>,
_chunk_size: usize,
) -> Result<Vec<Option<V>>, Self::Error>where
J: Borrow<K>,
Returns a vector of values corresponding to the keys provided,
non-atomically.
Source§fn multi_insert<J, U>(
&self,
key_val_pairs: impl IntoIterator<Item = (J, U)>,
) -> Result<(), Self::Error>
fn multi_insert<J, U>( &self, key_val_pairs: impl IntoIterator<Item = (J, U)>, ) -> Result<(), Self::Error>
Inserts key-value pairs, non-atomically.
Source§fn multi_remove<J>(
&self,
keys: impl IntoIterator<Item = J>,
) -> Result<(), Self::Error>where
J: Borrow<K>,
fn multi_remove<J>(
&self,
keys: impl IntoIterator<Item = J>,
) -> Result<(), Self::Error>where
J: Borrow<K>,
Removes keys, non-atomically.
Auto Trait Implementations§
impl<K, V> Freeze for TestDB<K, V>
impl<K, V> RefUnwindSafe for TestDB<K, V>
impl<K, V> Send for TestDB<K, V>
impl<K, V> Sync for TestDB<K, V>
impl<K, V> Unpin for TestDB<K, V>
impl<K, V> UnwindSafe for TestDB<K, V>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Pipes by value. This is generally the method you want to use. Read more
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
Borrows
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
Mutably borrows
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
Borrows
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
Mutably borrows
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
Borrows
self
, then passes self.deref()
into the pipe function.§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Immutable access to the
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
Mutable access to the
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
Immutable access to the
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
Mutable access to the
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Immutable access to the
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Mutable access to the
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
Calls
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
Calls
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
Calls
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
Calls
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
Calls
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
Calls
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
Calls
.tap_deref()
only in debug builds, and is erased in release
builds.