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>
impl<I, T, S> ReadWriteRawVec<I, T, S>
pub const SIZE_OF_T: usize
pub fn read_only_clone(&self) -> ReadOnlyRawVec<I, T, S>
Sourcepub fn forced_import_with(
options: ImportOptions<'_>,
format: Format,
) -> Result<Self>
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.
pub fn import_with(options: ImportOptions<'_>, format: Format) -> Result<Self>
pub fn remove(self) -> Result<()>
pub fn holes(&self) -> &BTreeSet<usize>
pub fn prev_holes(&self) -> &BTreeSet<usize>
pub fn mut_holes(&mut self) -> &mut BTreeSet<usize>
pub fn updated(&self) -> &BTreeMap<usize, T>
pub fn mut_updated(&mut self) -> &mut BTreeMap<usize, T>
pub fn prev_updated(&self) -> &BTreeMap<usize, T>
pub fn pushed(&self) -> &[T]
pub fn mut_pushed(&mut self) -> &mut Vec<T>
pub fn push(&mut self, value: T)
pub fn reserve_pushed(&mut self, additional: usize)
pub fn create_reader(&self) -> Reader
pub fn reader(&self) -> VecReader<I, T, S>
pub fn index_to_name(&self) -> String
pub fn unchecked_read_at(&self, index: usize, reader: &Reader) -> T
pub fn read_at(&self, index: usize, reader: &Reader) -> Result<T>
pub fn read_at_once(&self, index: usize) -> Result<T>
pub fn read_once(&self, index: I) -> Result<T>
pub fn get_pushed_or_read( &self, index: I, reader: &VecReader<I, T, S>, ) -> Option<T>
pub fn get_pushed_or_read_at( &self, index: usize, reader: &VecReader<I, T, S>, ) -> Option<T>
pub fn get_any_or_read(&self, index: I, reader: &Reader) -> Result<Option<T>>
pub fn get_any_or_read_at( &self, index: usize, reader: &Reader, ) -> Result<Option<T>>
pub fn collect_holed(&self) -> Result<Vec<Option<T>>>
pub fn collect_holed_range( &self, from: usize, to: usize, ) -> Result<Vec<Option<T>>>
pub fn update(&mut self, index: I, value: T) -> Result<()>
pub fn update_at(&mut self, index: usize, value: T) -> Result<()>
pub fn delete(&mut self, index: I)
pub fn delete_at(&mut self, index: usize)
pub fn get_first_empty_index(&self) -> I
pub fn fill_first_hole_or_push(&mut self, value: T) -> Result<I>
pub fn take(&mut self, index: I, reader: &Reader) -> Result<Option<T>>
pub fn take_at(&mut self, index: usize, reader: &Reader) -> Result<Option<T>>
pub fn fold_stored_io<B, F: FnMut(B, T) -> B>( &self, from: usize, to: usize, init: B, f: F, ) -> B
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>
impl<I, T, S> AnyStoredVec for ReadWriteRawVec<I, T, S>
fn db_path(&self) -> PathBuf
fn header(&self) -> &Header
fn mut_header(&mut self) -> &mut Header
Source§fn saved_stamped_changes(&self) -> u16
fn saved_stamped_changes(&self) -> u16
Number of stamped change files to keep for rollback support.
Source§fn real_stored_len(&self) -> usize
fn real_stored_len(&self) -> usize
The actual length stored on disk.
Source§fn stored_len(&self) -> usize
fn stored_len(&self) -> usize
The effective stored length (may differ from real_stored_len during truncation).
fn region(&self) -> &Region
fn serialize_changes(&self) -> Result<Vec<u8>>
Source§fn any_stamped_write_with_changes(&mut self, stamp: Stamp) -> Result<()>
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 any_truncate_if_needed_at(&mut self, index: usize) -> Result<()>
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.fn flush(&mut self) -> Result<()>
fn update_stamp(&mut self, stamp: Stamp)
fn stamp(&self) -> Stamp
fn stamped_write(&mut self, stamp: Stamp) -> Result<()>
Source§impl<I, T, S> AnyVec for ReadWriteRawVec<I, T, S>
impl<I, T, S> AnyVec for ReadWriteRawVec<I, T, S>
fn version(&self) -> Version
fn name(&self) -> &str
fn len(&self) -> usize
Source§fn index_type_to_string(&self) -> &'static str
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
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
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>
fn region_names(&self) -> Vec<String>
Returns the list of region names used by this vector.
fn is_empty(&self) -> bool
Source§fn region_name(&self) -> String
fn region_name(&self) -> String
Returns the combined name of the vector.
Source§fn etag(&self, stamp: Stamp, to: Option<i64>) -> String
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
fn i64_to_usize(&self, i: i64) -> usize
Converts an i64 index to usize, supporting negative indexing (Python-style).
Source§impl<I, T, S> ReadableVec<I, T> for ReadWriteRawVec<I, T, S>
impl<I, T, S> ReadableVec<I, T> for ReadWriteRawVec<I, T, S>
Source§fn collect_one_at(&self, index: usize) -> Option<T>
fn collect_one_at(&self, index: usize) -> Option<T>
Source§fn fold_range_at<B, F: FnMut(B, T) -> B>(
&self,
from: usize,
to: usize,
init: B,
f: F,
) -> Bwhere
Self: Sized,
fn fold_range_at<B, F: FnMut(B, T) -> B>(
&self,
from: usize,
to: usize,
init: B,
f: F,
) -> Bwhere
Self: Sized,
Folds over
[from, to) by raw index with an accumulator. Read moreSource§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,
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 moreSource§fn read_into(&self, from: I, to: I, buf: &mut Vec<T>)
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,
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))
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) -> Bwhere
Self: Sized,
fn fold_range<B, F: FnMut(B, T) -> B>(&self, from: I, to: I, init: B, f: F) -> Bwhere
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,
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,
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,
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>
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,
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,
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>
fn sum(&self, from: I, to: I) -> Option<T>
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,
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,
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,
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) -> Bwhere
Self: Sized,
fn fold<B, F: FnMut(B, T) -> B>(&self, init: B, f: F) -> Bwhere
Self: Sized,
Folds over all values with an accumulator.
Source§fn collect_range_at(&self, from: usize, to: usize) -> Vec<T>where
Self: Sized,
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>)
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>
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_first(&self) -> Option<T>
fn collect_first(&self) -> Option<T>
Collects the first value, or
None if empty.Source§fn collect_last(&self) -> Option<T>
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,
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>
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>
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>)
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>
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>)
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>
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,
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,
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,
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,
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§impl<I, T, S> TypedVec for ReadWriteRawVec<I, T, S>
impl<I, T, S> TypedVec for ReadWriteRawVec<I, T, S>
Source§impl<I, T, S> WritableVec<I, T> for ReadWriteRawVec<I, T, S>
impl<I, T, S> WritableVec<I, T> for ReadWriteRawVec<I, T, S>
fn push(&mut self, value: T)
Source§fn truncate_if_needed_at(&mut self, index: usize) -> Result<()>
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_unsaved(&mut self)
fn reset_unsaved(&mut self)
Resets uncommitted changes.
Source§fn stamped_write_with_changes(&mut self, stamp: Stamp) -> Result<()>
fn stamped_write_with_changes(&mut self, stamp: Stamp) -> Result<()>
Flushes with the given stamp, saving changes to enable rollback.
const SIZE_OF_T: usize = _
Source§fn rollback_before(&mut self, stamp: Stamp) -> Result<Stamp>
fn rollback_before(&mut self, stamp: Stamp) -> Result<Stamp>
Rolls back changes to before the given stamp.
Source§fn pushed_len(&self) -> usize
fn pushed_len(&self) -> usize
Number of pushed (uncommitted) values in the memory buffer.
Source§fn is_pushed_empty(&self) -> bool
fn is_pushed_empty(&self) -> bool
Returns true if there are no pushed (uncommitted) values.
Source§fn checked_push(&mut self, index: I, value: T) -> Result<()>
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<()>
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<()>
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<()>
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 batch_limit_reached(&self) -> bool
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,
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<()>
fn stamped_write_maybe_with_changes( &mut self, stamp: Stamp, with_changes: bool, ) -> Result<()>
Flushes with the given stamp, optionally saving changes for rollback.
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>
impl<I, T, S> Sync for ReadWriteRawVec<I, T, S>
impl<I, T, S> Unpin for ReadWriteRawVec<I, T, S>
impl<I, T, S> UnsafeUnpin for ReadWriteRawVec<I, T, S>
impl<I, T, S> !UnwindSafe for ReadWriteRawVec<I, T, S>
Blanket Implementations§
Source§impl<V> AnyReadableVec for V
impl<V> AnyReadableVec for V
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> 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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<V, I, T> ReadableOptionVec<I, T> for V
impl<V, I, T> ReadableOptionVec<I, T> for V
Source§fn collect_or_default(&self) -> Vec<T>
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>
fn collect_one_flat(&self, index: I) -> Option<T>
Flattens
Option<Option<T>> → Option<T>.