Skip to main content

ReadWriteRawVec

Struct ReadWriteRawVec 

Source
pub struct ReadWriteRawVec<I, T, S> { /* private fields */ }
Expand description

Core implementation for raw storage vectors shared by BytesVec and ZeroCopyVec.

Parameterized by serialization strategy S to support different serialization approaches:

  • BytesStrategy: Explicit little-endian serialization (portable)
  • ZeroCopyStrategy: Native byte order via zerocopy (fast but not portable)

Provides holes (deleted indices) and updated values tracking for both vec types.

Implementations§

Source§

impl<I, T, S> ReadWriteRawVec<I, T, S>
where I: VecIndex, T: VecValue, S: RawStrategy<T>,

Source

pub const SIZE_OF_T: usize

Source

pub fn read_only_clone(&self) -> ReadOnlyRawVec<I, T, S>

Source

pub fn forced_import_with( options: ImportOptions<'_>, format: Format, ) -> Result<Self>

§Warning

This will DELETE all existing data on format/version errors. Use with caution.

Source

pub fn import_with(options: ImportOptions<'_>, format: Format) -> Result<Self>

Source

pub fn remove(self) -> Result<()>

Source

pub fn holes(&self) -> &BTreeSet<usize>

Source

pub fn prev_holes(&self) -> &BTreeSet<usize>

Source

pub fn mut_holes(&mut self) -> &mut BTreeSet<usize>

Source

pub fn updated(&self) -> &BTreeMap<usize, T>

Source

pub fn mut_updated(&mut self) -> &mut BTreeMap<usize, T>

Source

pub fn prev_updated(&self) -> &BTreeMap<usize, T>

Source

pub fn pushed(&self) -> &[T]

Source

pub fn mut_pushed(&mut self) -> &mut Vec<T>

Source

pub fn push(&mut self, value: T)

Source

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

Source

pub fn create_reader(&self) -> Reader

Source

pub fn reader(&self) -> VecReader<I, T, S>

Source

pub fn index_to_name(&self) -> String

Source

pub fn unchecked_read_at(&self, index: usize, reader: &Reader) -> T

Source

pub fn read_at(&self, index: usize, reader: &Reader) -> Result<T>

Source

pub fn read_at_once(&self, index: usize) -> Result<T>

Source

pub fn read_once(&self, index: I) -> Result<T>

Source

pub fn get_pushed_or_read( &self, index: I, reader: &VecReader<I, T, S>, ) -> Option<T>

Source

pub fn get_pushed_or_read_at( &self, index: usize, reader: &VecReader<I, T, S>, ) -> Option<T>

Source

pub fn get_any_or_read(&self, index: I, reader: &Reader) -> Result<Option<T>>

Source

pub fn get_any_or_read_at( &self, index: usize, reader: &Reader, ) -> Result<Option<T>>

Source

pub fn collect_holed(&self) -> Result<Vec<Option<T>>>

Source

pub fn collect_holed_range( &self, from: usize, to: usize, ) -> Result<Vec<Option<T>>>

Source

pub fn update(&mut self, index: I, value: T) -> Result<()>

Source

pub fn update_at(&mut self, index: usize, value: T) -> Result<()>

Source

pub fn delete(&mut self, index: I)

Source

pub fn delete_at(&mut self, index: usize)

Source

pub fn get_first_empty_index(&self) -> I

Source

pub fn fill_first_hole_or_push(&mut self, value: T) -> Result<I>

Source

pub fn take(&mut self, index: I, reader: &Reader) -> Result<Option<T>>

Source

pub fn take_at(&mut self, index: usize, reader: &Reader) -> Result<Option<T>>

Source

pub fn fold_stored_io<B, F: FnMut(B, T) -> B>( &self, from: usize, to: usize, init: B, f: F, ) -> B

Source

pub fn fold_stored_mmap<B, F: FnMut(B, T) -> B>( &self, from: usize, to: usize, init: B, f: F, ) -> B

Trait Implementations§

Source§

impl<I, T, S> AnyStoredVec for ReadWriteRawVec<I, T, S>
where I: VecIndex, T: VecValue, S: RawStrategy<T>,

Source§

fn db_path(&self) -> PathBuf

Source§

fn header(&self) -> &Header

Source§

fn mut_header(&mut self) -> &mut Header

Source§

fn saved_stamped_changes(&self) -> u16

Number of stamped change files to keep for rollback support.
Source§

fn real_stored_len(&self) -> usize

The actual length stored on disk.
Source§

fn stored_len(&self) -> usize

The effective stored length (may differ from real_stored_len during truncation).
Source§

fn region(&self) -> &Region

Source§

fn serialize_changes(&self) -> Result<Vec<u8>>

Source§

fn any_stamped_write_with_changes(&mut self, stamp: Stamp) -> Result<()>

Flushes with the given stamp, saving changes to enable rollback. Prefixed with any_ to avoid conflict with WritableVec::stamped_write_with_changes.
Source§

fn remove(self) -> Result<()>

Removes this vector’s region from the database.
Source§

fn any_truncate_if_needed_at(&mut self, index: usize) -> Result<()>

Truncates the vector to the given length if it is longer. Prefixed with any_ to avoid conflict with WritableVec::truncate_if_needed_at.
Source§

fn any_reset(&mut self) -> Result<()>

Resets the vector state, clearing all data.
Source§

fn flush(&mut self) -> Result<()>

Source§

fn update_stamp(&mut self, stamp: Stamp)

Source§

fn stamp(&self) -> Stamp

Source§

fn stamped_write(&mut self, stamp: Stamp) -> Result<()>

Source§

fn any_stamped_write_maybe_with_changes( &mut self, stamp: Stamp, with_changes: bool, ) -> Result<()>

Flushes with the given stamp, optionally saving changes for rollback.
Source§

impl<I, T, S> AnyVec for ReadWriteRawVec<I, T, S>
where I: VecIndex, T: VecValue, S: RawStrategy<T>,

Source§

fn version(&self) -> Version

Source§

fn name(&self) -> &str

Source§

fn len(&self) -> usize

Source§

fn index_type_to_string(&self) -> &'static str

Returns the string representation of the index type.
Source§

fn value_type_to_size_of(&self) -> usize

Returns the size in bytes of the value type.
Source§

fn value_type_to_string(&self) -> &'static str

Returns the short type name of the value type (e.g., “Sats”, “StoredF64”).
Source§

fn region_names(&self) -> Vec<String>

Returns the list of region names used by this vector.
Source§

fn is_empty(&self) -> bool

Source§

fn region_name(&self) -> String

Returns the combined name of the vector.
Source§

fn etag(&self, stamp: Stamp, to: Option<i64>) -> String

Generates an ETag for this vector based on stamp and optional end index.
Source§

fn i64_to_usize(&self, i: i64) -> usize

Converts an i64 index to usize, supporting negative indexing (Python-style).
Source§

impl<I: Debug, T: Debug, S: Debug> Debug for ReadWriteRawVec<I, T, S>

Source§

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

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

impl<I, T, S> ReadableVec<I, T> for ReadWriteRawVec<I, T, S>
where I: VecIndex, T: VecValue, S: RawStrategy<T>,

Source§

fn collect_one_at(&self, index: usize) -> Option<T>

Collects a single value at raw index, or None if out of bounds. Read more
Source§

fn read_into_at(&self, from: usize, to: usize, buf: &mut Vec<T>)

Appends elements in [from, to) to buf. Read more
Source§

fn for_each_range_dyn_at(&self, from: usize, to: usize, f: &mut dyn FnMut(T))

Iterates over [from, to) by raw index, calling f for each value. Read more
Source§

fn fold_range_at<B, F: FnMut(B, T) -> B>( &self, from: usize, to: usize, init: B, f: F, ) -> B
where Self: Sized,

Folds over [from, to) by raw index with an accumulator. Read more
Source§

fn try_fold_range_at<B, E, F: FnMut(B, T) -> Result<B, E>>( &self, from: usize, to: usize, init: B, f: F, ) -> Result<B, E>
where Self: Sized,

Fallible fold over [from, to) by raw index with early exit on error. Read more
Source§

fn read_into(&self, from: I, to: I, buf: &mut Vec<T>)

Appends elements in [from, to) to buf using typed indices.
Source§

fn cursor(&self) -> Cursor<'_, I, T, Self>
where Self: Sized,

Creates a forward-only Cursor that reuses an internal buffer across chunked read_into_at calls. One allocation for the lifetime of the cursor.
Source§

fn for_each_range_dyn(&self, from: I, to: I, f: &mut dyn FnMut(T))

Iterates over [from, to) by typed index, calling f for each value (object-safe).
Source§

fn fold_range<B, F: FnMut(B, T) -> B>(&self, from: I, to: I, init: B, f: F) -> B
where Self: Sized,

Folds over [from, to) by typed index with an accumulator.
Source§

fn try_fold_range<B, E, F: FnMut(B, T) -> Result<B, E>>( &self, from: I, to: I, init: B, f: F, ) -> Result<B, E>
where Self: Sized,

Fallible fold over [from, to) by typed index with early exit on error.
Source§

fn for_each_range<F: FnMut(T)>(&self, from: I, to: I, f: F)
where Self: Sized,

Calls f for each value in [from, to) by typed index. Requires Sized.
Source§

fn collect_range(&self, from: I, to: I) -> Vec<T>
where Self: Sized,

Collects values in [from, to) by typed index into a Vec<T>.
Source§

fn collect_one(&self, index: I) -> Option<T>

Collects a single value at typed index, or None if out of bounds.
Source§

fn min(&self, from: I, to: I) -> Option<T>
where Self: Sized, T: PartialOrd,

Returns the minimum value in [from, to) by typed index, or None if empty.
Source§

fn max(&self, from: I, to: I) -> Option<T>
where Self: Sized, T: PartialOrd,

Returns the maximum value in [from, to) by typed index, or None if empty.
Source§

fn sum(&self, from: I, to: I) -> Option<T>
where Self: Sized, T: AddAssign + From<u8>,

Returns the sum of values in [from, to) by typed index, or None if empty.
Source§

fn for_each_range_at<F: FnMut(T)>(&self, from: usize, to: usize, f: F)
where Self: Sized,

Calls f for each value in [from, to) by raw index. Requires Sized (static dispatch).
Source§

fn try_for_each_range_at<E, F: FnMut(T) -> Result<(), E>>( &self, from: usize, to: usize, f: F, ) -> Result<(), E>
where Self: Sized,

Fallible for-each over [from, to) by raw index with early exit on error.
Source§

fn for_each<F: FnMut(T)>(&self, f: F)
where Self: Sized,

Calls f for every value in the vector.
Source§

fn fold<B, F: FnMut(B, T) -> B>(&self, init: B, f: F) -> B
where Self: Sized,

Folds over all values with an accumulator.
Source§

fn collect_range_at(&self, from: usize, to: usize) -> Vec<T>
where Self: Sized,

Collects values in [from, to) by raw index into a Vec<T>.
Source§

fn collect_range_into_at(&self, from: usize, to: usize, buf: &mut Vec<T>)

Clears buf then fills it with values in [from, to). Reuses the buffer allocation.
Source§

fn collect_range_dyn(&self, from: usize, to: usize) -> Vec<T>

Collects values in [from, to) into a Vec<T> (object-safe).
Source§

fn collect(&self) -> Vec<T>
where Self: Sized,

Collects all values into a Vec<T>.
Source§

fn collect_first(&self) -> Option<T>

Collects the first value, or None if empty.
Source§

fn collect_last(&self) -> Option<T>

Collects the last value, or None if empty.
Source§

fn collect_signed_range(&self, from: Option<i64>, to: Option<i64>) -> Vec<T>
where Self: Sized,

Collects values using signed indices. Negative indices count from the end (Python-style): -1 is the last element, -2 is second-to-last, etc.
Source§

fn collect_signed_range_dyn(&self, from: Option<i64>, to: Option<i64>) -> Vec<T>

Collects values using signed indices (object-safe).
Source§

fn collect_dyn(&self) -> Vec<T>

Collects all values into a Vec<T> (object-safe).
Source§

fn read_sorted_into_at(&self, indices: &[usize], out: &mut Vec<T>)

Reads values at specific sorted indices (ascending), skipping holes. Read more
Source§

fn read_sorted_at(&self, indices: &[usize]) -> Vec<T>

Reads values at specific sorted indices (ascending), returning a new Vec.
Source§

fn read_sorted_into(&self, indices: &[I], out: &mut Vec<T>)

Reads values at specific sorted typed indices, appending to out.
Source§

fn read_sorted(&self, indices: &[I]) -> Vec<T>

Reads values at specific sorted typed indices, returning a new Vec.
Source§

fn min_at(&self, from: usize, to: usize) -> Option<T>
where Self: Sized, T: PartialOrd,

Returns the minimum value in [from, to) by raw index, or None if empty.
Source§

fn min_dyn(&self, from: usize, to: usize) -> Option<T>
where T: PartialOrd,

Returns the minimum value in [from, to), or None if empty (object-safe).
Source§

fn max_at(&self, from: usize, to: usize) -> Option<T>
where Self: Sized, T: PartialOrd,

Returns the maximum value in [from, to) by raw index, or None if empty.
Source§

fn max_dyn(&self, from: usize, to: usize) -> Option<T>
where T: PartialOrd,

Returns the maximum value in [from, to), or None if empty (object-safe).
Source§

fn sum_at(&self, from: usize, to: usize) -> Option<T>
where Self: Sized, T: AddAssign + From<u8>,

Returns the sum of values in [from, to) by raw index, or None if empty.
Source§

fn sum_dyn(&self, from: usize, to: usize) -> Option<T>
where T: AddAssign + From<u8>,

Returns the sum of values in [from, to), or None if empty (object-safe).
Source§

impl<I, T, S> TypedVec for ReadWriteRawVec<I, T, S>
where I: VecIndex, T: VecValue, S: RawStrategy<T>,

Source§

type I = I

The index type used to address elements in this vector.
Source§

type T = T

The value type stored in this vector.
Source§

impl<I, T, S> WritableVec<I, T> for ReadWriteRawVec<I, T, S>
where I: VecIndex, T: VecValue, S: RawStrategy<T>,

Source§

fn push(&mut self, value: T)

Source§

fn pushed(&self) -> &[T]

Returns the current pushed (uncommitted) values.
Source§

fn truncate_if_needed_at(&mut self, index: usize) -> Result<()>

Truncates the vector to the given usize index if the current length exceeds it.
Source§

fn reset(&mut self) -> Result<()>

Resets the vector state.
Source§

fn reset_unsaved(&mut self)

Resets uncommitted changes.
Source§

fn is_dirty(&self) -> bool

Returns true if there are uncommitted changes.
Source§

fn stamped_write_with_changes(&mut self, stamp: Stamp) -> Result<()>

Flushes with the given stamp, saving changes to enable rollback.
Source§

fn rollback(&mut self) -> Result<()>

Rolls back the most recent change set.
Source§

const SIZE_OF_T: usize = _

Source§

fn rollback_before(&mut self, stamp: Stamp) -> Result<Stamp>

Rolls back changes to before the given stamp.
Source§

fn pushed_len(&self) -> usize

Number of pushed (uncommitted) values in the memory buffer.
Source§

fn is_pushed_empty(&self) -> bool

Returns true if there are no pushed (uncommitted) values.
Source§

fn has(&self, index: I) -> bool

Returns true if the typed index is within bounds.
Source§

fn has_at(&self, index: usize) -> bool

Returns true if the usize index is within bounds.
Source§

fn checked_push(&mut self, index: I, value: T) -> Result<()>

Pushes a value at the given index, erroring if index != current length. Use this when you expect to always append in order.
Source§

fn checked_push_at(&mut self, index: usize, value: T) -> Result<()>

Pushes a value at the given usize index, erroring if index != current length. Use this when you expect to always append in order.
Source§

fn truncate_if_needed(&mut self, index: I) -> Result<()>

Truncates the vector to the given index if the current length exceeds it.
Source§

fn truncate_if_needed_with_stamp( &mut self, index: I, stamp: Stamp, ) -> Result<()>

Truncates the vector to the given index if needed, updating the stamp.
Source§

fn clear(&mut self) -> Result<()>

Clears all values from the vector.
Source§

fn batch_limit_reached(&self) -> bool

Returns true if the pushed cache has reached the batch limit (~1GiB). Read more
Source§

fn fill_to(&mut self, target_len: usize, value: T) -> Result<()>
where T: Copy,

Extends the vector to target_len, filling with value. Batches writes in ~1GB chunks to avoid memory explosion.
Source§

fn stamped_write_maybe_with_changes( &mut self, stamp: Stamp, with_changes: bool, ) -> Result<()>

Flushes with the given stamp, optionally saving changes for rollback.
Source§

fn validate_computed_version_or_reset( &mut self, dep_version: Version, ) -> Result<()>

Validates the computed version against the stored version, resetting if they don’t match. Automatically includes the vec’s own version - only pass dependency versions.
Source§

fn validate_and_truncate( &mut self, dep_version: Version, max_from: I, ) -> Result<()>

Validates computed version and truncates to max_from in one call. Read more

Auto Trait Implementations§

§

impl<I, T, S> Freeze for ReadWriteRawVec<I, T, S>

§

impl<I, T, S> !RefUnwindSafe for ReadWriteRawVec<I, T, S>

§

impl<I, T, S> Send for ReadWriteRawVec<I, T, S>
where S: Send, I: Send, T: Send,

§

impl<I, T, S> Sync for ReadWriteRawVec<I, T, S>
where S: Sync, I: Sync, T: Sync,

§

impl<I, T, S> Unpin for ReadWriteRawVec<I, T, S>
where S: Unpin, I: Unpin, T: Unpin,

§

impl<I, T, S> UnsafeUnpin for ReadWriteRawVec<I, T, S>

§

impl<I, T, S> !UnwindSafe for ReadWriteRawVec<I, T, S>

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<V> AnyReadableVec for V
where V: TypedVec + ReadableVec<<V as TypedVec>::I, <V as TypedVec>::T>,

Source§

fn range_count(&self, from: Option<i64>, to: Option<i64>) -> usize

Returns the number of items in the specified range.
Source§

fn range_weight(&self, from: Option<i64>, to: Option<i64>) -> usize

Returns the total size in bytes of items in the specified range.
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.

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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<V, I, T> ReadableOptionVec<I, T> for V
where V: ReadableVec<I, Option<T>>, I: VecIndex, T: VecValue + Default,

Source§

fn collect_or_default(&self) -> Vec<T>

Collect all values, replacing None with T::default().
Source§

fn collect_one_flat(&self, index: I) -> Option<T>

Flattens Option<Option<T>>Option<T>.
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.
Source§

impl<V> AnyExportableVec for V