Skip to main content

IoDupSuber

Struct IoDupSuber 

Source
pub struct IoDupSuber<C: ValueCodec = Utf8Codec> { /* private fields */ }
Expand description

IoDupSuber - Sub class of DupSuber that supports Insertion Ordering (IoDup) of duplicates

By automagically prepending and stripping ordinal proem to/from each duplicate value at a given key.

IoDupSuber supports insertion ordered multiple entries at each key (duplicates) with dupsort==True

Do not use if serialized length key + proem + value, is greater than 511 bytes. This is a limitation of dupsort==True sub dbs in LMDB

IoDupSuber may be more performant then IoSetSuber for values that are indices to other sub dbs that fit the size constraint because LMDB support for duplicates is more space efficient and code performant.

Duplicates at a given key preserve insertion order of duplicate. Because lmdb is lexocographic an insertion ordering proem is prepended to all values that makes lexocographic order that same as insertion order.

Duplicates are ordered as a pair of key plus value so prepending proem to each value changes duplicate ordering. Proem is 33 characters long. With 32 character hex string followed by ‘.’ for essentially unlimited number of values which will be limited by memory.

With prepended proem ordinal must explicitly check for duplicate values before insertion. Uses a set for the duplicate inclusion test.

Implementations§

Source§

impl<C: ValueCodec> IoDupSuber<C>

Source

pub fn new( db: Arc<LMDBer>, subkey: &str, sep: Option<u8>, verify: bool, ) -> Result<Self, SuberError>

Creates a new IoDupSuber instance.

Source

pub fn put<K: AsRef<[u8]>, V: ?Sized + Clone + Into<Vec<u8>>>( &self, keys: &[K], vals: &[&V], ) -> Result<bool, SuberError>

Puts all vals idempotently at key made from keys in insertion order using hidden ordinal proem. Idempotently means do not put any val in vals that is already in dup vals at key. Does not overwrite.

§Arguments
  • keys - Slice of key parts to be combined to form the key
  • vals - Slice of values to be stored
§Returns
  • Result<bool, SuberError> - True if successful, otherwise an error
Source

pub fn add<K: AsRef<[u8]>, V: ?Sized + Clone + Into<Vec<u8>>>( &self, keys: &[K], val: &V, ) -> Result<bool, SuberError>

Add val idempotently at key made from keys in insertion order using hidden ordinal proem. Idempotently means do not add val that is already in dup vals at key. Does not overwrite.

§Arguments
  • keys - Slice of key parts to be combined to form the key
  • val - Value to be stored
§Returns
  • Result<bool, SuberError> - True means unique value added among duplications, False means duplicate of same value already exists.
Source

pub fn pin<K: AsRef<[u8]>, V: ?Sized + Clone + Into<Vec<u8>>>( &self, keys: &[K], vals: &[&V], ) -> Result<bool, SuberError>

Pins (sets) vals at key made from keys in insertion order using hidden ordinal proem. Overwrites. Removes all pre-existing vals that share same keys and replaces them with vals

§Arguments
  • keys - Slice of key parts to be combined to form the key
  • vals - Slice of values to be stored
§Returns
  • Result<bool, SuberError> - True if successful, otherwise an error
Source

pub fn get<K: AsRef<[u8]>, R: TryFrom<Vec<u8>>>( &self, keys: &[K], ) -> Result<Vec<R>, SuberError>
where <R as TryFrom<Vec<u8>>>::Error: Debug,

Gets vals dup list in insertion order using key made from keys and hidden ordinal proem on dups.

§Arguments
  • keys - Slice of key parts to be combined to form the key
§Returns
  • Result<Vec<R>, SuberError> - Vector of deserialized values, empty if none found
Source

pub fn get_iter<K: AsRef<[u8]>, R: TryFrom<Vec<u8>> + 'static>( &self, keys: &[K], ) -> Result<impl Iterator<Item = Result<R, SuberError>>, SuberError>
where <R as TryFrom<Vec<u8>>>::Error: Debug, SuberError: From<<R as TryFrom<Vec<u8>>>::Error>,

Gets vals dup iterator in insertion order using key made from keys and hidden ordinal proem on dups. All vals in dups that share same key are retrieved in insertion order.

§Arguments
  • keys - Slice of key parts to be combined to form the key
§Returns
  • Result<impl Iterator<Item = Result<R, SuberError>>, SuberError> - Iterator of results
Source

pub fn get_last<K: AsRef<[u8]>, R: TryFrom<Vec<u8>>>( &self, keys: &[K], ) -> Result<Option<R>, SuberError>
where <R as TryFrom<Vec<u8>>>::Error: Debug,

Gets last val inserted at key made from keys in insertion order using hidden ordinal proem.

§Arguments
  • keys - Slice of key parts to be combined to form the key
§Returns
  • Result<Option<R>, SuberError> - The last value if found, None otherwise
Source

pub fn rem<K: AsRef<[u8]>, V: ?Sized + Clone + Into<Vec<u8>>>( &self, keys: &[K], val: Option<&V>, ) -> Result<bool, SuberError>

Removes entry at key made from keys and dup val that matches val if any, notwithstanding hidden ordinal proem. Otherwise deletes all dup values at key if val is None.

§Arguments
  • keys - Slice of key parts to be combined to form the key
  • val - Optional value to remove; if None, removes all values at the key
§Returns
  • Result<bool, SuberError> - True if successful, False otherwise
Source

pub fn cnt<K: AsRef<[u8]>>(&self, keys: &[K]) -> Result<usize, SuberError>

Return count of dup values at key made from keys with hidden ordinal proem. Zero otherwise

§Arguments
  • keys - Slice of key parts to be combined to form the key
§Returns
  • Result<usize, SuberError> - Count of values
Source

pub fn get_item_iter<K: AsRef<[u8]>>( &self, keys: &[K], topive: bool, ) -> Result<Vec<(Vec<Vec<u8>>, Vec<u8>)>, SuberError>

Return iterator over all the items including dup items for all keys in top branch defined by keys where keys may be truncation of full branch.

§Arguments
  • keys - Slice of key parts, potentially a partial key
  • topive - If true, treat as partial key tuple ending with separator
§Returns
  • Result<Vec<(Vec<Vec<u8>>, Vec<u8>)>, SuberError> - Vector of key-value pairs
Source

pub fn get_full_item_iter<K: AsRef<[u8]>>( &self, keys: &[K], topive: bool, ) -> Result<Vec<(Vec<Vec<u8>>, Vec<u8>)>, SuberError>

Returns an iterator over all the items including dup items for all keys in top branch defined by keys where keys may be truncation of full branch. Returns full raw values with ordinal proems.

§Arguments
  • keys - Slice of key parts, potentially a partial key
  • topive - If true, treat as partial key tuple ending with separator
§Returns
  • Result<Vec<(Vec<Vec<u8>>, Vec<u8>)>, SuberError> - Vector of key-value pairs with raw values
Source

pub fn trim<K: AsRef<[u8]>>( &self, keys: &[K], topive: bool, ) -> Result<bool, SuberError>

Removes all entries at keys that are in top branch with key prefix matching keys where keys may be truncation of full branch.

§Arguments
  • keys - Slice of key parts, potentially a partial key
  • topive - If true, treat as partial key tuple ending with separator
§Returns
  • Result<bool, SuberError> - True if successful
Source

pub fn is_dupsort(&self) -> bool

Returns whether this SuberBase is configured to support duplicate values for keys.

§Returns
  • bool - True if duplicates are allowed

Auto Trait Implementations§

§

impl<C> Freeze for IoDupSuber<C>

§

impl<C> RefUnwindSafe for IoDupSuber<C>
where C: RefUnwindSafe,

§

impl<C> Send for IoDupSuber<C>
where C: Send,

§

impl<C> Sync for IoDupSuber<C>
where C: Sync,

§

impl<C> Unpin for IoDupSuber<C>
where C: Unpin,

§

impl<C> UnsafeUnpin for IoDupSuber<C>

§

impl<C> UnwindSafe for IoDupSuber<C>
where C: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more