Skip to main content

SuffixBag

Struct SuffixBag 

Source
pub struct SuffixBag { /* private fields */ }
Expand description

Contiguous storage for key suffixes.

Implementations§

Source§

impl SuffixBag

Source

pub fn compact_with_permuter<P: PermutationProvider>( &mut self, perm: &P, exclude_slot: Option<usize>, ) -> usize

Compact using a permutation to determine active slots.

§Returns

The number of bytes reclaimed.

Source§

impl SuffixBag

Source

pub fn new() -> Self

Create a new suffix bag with initial capacity.

Source

pub fn with_capacity(capacity: usize) -> Self

Create a new suffix bag with specified capacity.

Source

pub fn from_vec(data: Vec<u8>) -> Self

Construct SuffixBag by reusing an existing Vec<u8> buffer.

Source

pub const fn capacity(&self) -> usize

Return the current capacity of the data buffer.

Source

pub const fn used(&self) -> usize

Return the number of bytes currently used.

Source

pub const fn count(&self) -> usize

Return the number of slots that have suffixes.

Source

pub fn reserve(&mut self, additional: usize)

Reserve additional capacity for suffix data.

Source

pub fn try_assign(&mut self, slot: usize, suffix: &[u8]) -> bool

Assign a suffix with smart space management.

§Panics

Panics if suffix.len() > u16::MAX (65535 bytes).

Source

pub fn has_suffix(&self, slot: usize) -> bool

Check if a slot has a suffix.

§Panics

Panics if slot >= 15.

Source

pub fn get(&self, slot: usize) -> Option<&[u8]>

Get the suffix for a slot, or None if no suffix.

§Panics

Panics if slot >= 15.

Source

pub fn get_or_empty(&self, slot: usize) -> &[u8]

Get the suffix for a slot, or empty slice if no suffix.

§Panics

Panics if slot >= 15.

Source

pub fn try_assign_append_only(&mut self, slot: usize, suffix: &[u8]) -> bool

Append-only suffix assignment for concurrent use.

Unlike try_assign_in_place, this method never overwrites existing suffix bytes. New data is always appended to the end of the buffer, so concurrent OCC readers reading old offsets see stable data. Old suffix space becomes dead until drain-and-rebuild.

§Panics

Panics if slot >= 15 or if suffix length exceeds u16::MAX.

Source

pub fn try_assign_in_place(&mut self, slot: usize, suffix: &[u8]) -> bool

Try to assign a suffix to a slot in-place, without growing the buffer.

This method may overwrite existing suffix bytes in-place when the new suffix fits. It is NOT safe for concurrent use (readers may observe partially-written data). Use try_assign_append_only for the concurrent path.

§Panics

Panics if slot >= 15 or if suffix length exceeds u16::MAX.

Source

pub fn assign(&mut self, slot: usize, suffix: &[u8])

Assign a suffix to a slot.

§Panics

Panics if slot >= 15 or if suffix length exceeds u16::MAX.

Source

pub fn clear(&mut self, slot: usize)

Clear the suffix for a slot.

§Panics

Panics if slot >= 15.

Source

pub fn suffix_equals(&self, slot: usize, suffix: &[u8]) -> bool

Check if a slot’s suffix equals the given suffix.

Source

pub fn suffix_compare(&self, slot: usize, suffix: &[u8]) -> Option<Ordering>

Compare a slot’s suffix with the given suffix.

Trait Implementations§

Source§

impl Clone for SuffixBag

Source§

fn clone(&self) -> Self

Clone with compaction, only copies active suffix data.

This avoids copying dead/garbage data from the original buffer.

1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SuffixBag

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SuffixBag

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.