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>
impl<C: ValueCodec> IoDupSuber<C>
Sourcepub fn new(
db: Arc<LMDBer>,
subkey: &str,
sep: Option<u8>,
verify: bool,
) -> Result<Self, SuberError>
pub fn new( db: Arc<LMDBer>, subkey: &str, sep: Option<u8>, verify: bool, ) -> Result<Self, SuberError>
Creates a new IoDupSuber instance.
Sourcepub fn put<K: AsRef<[u8]>, V: ?Sized + Clone + Into<Vec<u8>>>(
&self,
keys: &[K],
vals: &[&V],
) -> Result<bool, SuberError>
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 keyvals- Slice of values to be stored
§Returns
Result<bool, SuberError>- True if successful, otherwise an error
Sourcepub fn add<K: AsRef<[u8]>, V: ?Sized + Clone + Into<Vec<u8>>>(
&self,
keys: &[K],
val: &V,
) -> Result<bool, SuberError>
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 keyval- Value to be stored
§Returns
Result<bool, SuberError>- True means unique value added among duplications, False means duplicate of same value already exists.
Sourcepub fn pin<K: AsRef<[u8]>, V: ?Sized + Clone + Into<Vec<u8>>>(
&self,
keys: &[K],
vals: &[&V],
) -> Result<bool, SuberError>
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 keyvals- Slice of values to be stored
§Returns
Result<bool, SuberError>- True if successful, otherwise an error
Sourcepub fn get<K: AsRef<[u8]>, R: TryFrom<Vec<u8>>>(
&self,
keys: &[K],
) -> Result<Vec<R>, SuberError>
pub fn get<K: AsRef<[u8]>, R: TryFrom<Vec<u8>>>( &self, keys: &[K], ) -> Result<Vec<R>, SuberError>
Sourcepub fn get_iter<K: AsRef<[u8]>, R: TryFrom<Vec<u8>> + 'static>(
&self,
keys: &[K],
) -> Result<impl Iterator<Item = Result<R, SuberError>>, SuberError>
pub fn get_iter<K: AsRef<[u8]>, R: TryFrom<Vec<u8>> + 'static>( &self, keys: &[K], ) -> Result<impl Iterator<Item = Result<R, SuberError>>, SuberError>
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
Sourcepub fn get_last<K: AsRef<[u8]>, R: TryFrom<Vec<u8>>>(
&self,
keys: &[K],
) -> Result<Option<R>, SuberError>
pub fn get_last<K: AsRef<[u8]>, R: TryFrom<Vec<u8>>>( &self, keys: &[K], ) -> Result<Option<R>, SuberError>
Sourcepub fn rem<K: AsRef<[u8]>, V: ?Sized + Clone + Into<Vec<u8>>>(
&self,
keys: &[K],
val: Option<&V>,
) -> Result<bool, SuberError>
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 keyval- Optional value to remove; if None, removes all values at the key
§Returns
Result<bool, SuberError>- True if successful, False otherwise
Sourcepub fn get_item_iter<K: AsRef<[u8]>>(
&self,
keys: &[K],
topive: bool,
) -> Result<Vec<(Vec<Vec<u8>>, Vec<u8>)>, SuberError>
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 keytopive- If true, treat as partial key tuple ending with separator
§Returns
Result<Vec<(Vec<Vec<u8>>, Vec<u8>)>, SuberError>- Vector of key-value pairs
Sourcepub fn get_full_item_iter<K: AsRef<[u8]>>(
&self,
keys: &[K],
topive: bool,
) -> Result<Vec<(Vec<Vec<u8>>, Vec<u8>)>, SuberError>
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 keytopive- 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
Sourcepub fn trim<K: AsRef<[u8]>>(
&self,
keys: &[K],
topive: bool,
) -> Result<bool, SuberError>
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 keytopive- If true, treat as partial key tuple ending with separator
§Returns
Result<bool, SuberError>- True if successful
Sourcepub fn is_dupsort(&self) -> bool
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