pub struct LZ4Vec<I, T>(/* private fields */);Expand description
Compressed storage using LZ4 for speed-optimized general-purpose compression.
LZ4 prioritizes compression/decompression speed over ratio, making it ideal for workloads where CPU time matters more than storage space.
§Performance Characteristics
- Extremely fast compression/decompression (hundreds of MB/s)
- Moderate compression ratios (typically 2-3x)
- Works well with any data type
§When to Use
- Speed is more important than storage savings
- Mixed data types (not just numbers)
- Need compression but can’t afford CPU overhead
Trait Implementations§
Source§impl<I, T> AnyStoredVec for LZ4Vec<I, T>where
I: VecIndex,
T: LZ4VecValue,
impl<I, T> AnyStoredVec for LZ4Vec<I, T>where
I: VecIndex,
T: LZ4VecValue,
fn db_path(&self) -> PathBuf
fn region(&self) -> &Region
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 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> AnyVec for LZ4Vec<I, T>where
I: VecIndex,
T: LZ4VecValue,
impl<I, T> AnyVec for LZ4Vec<I, T>where
I: VecIndex,
T: LZ4VecValue,
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> ImportableVec for LZ4Vec<I, T>where
I: VecIndex,
T: LZ4VecValue,
impl<I, T> ImportableVec for LZ4Vec<I, T>where
I: VecIndex,
T: LZ4VecValue,
Source§fn import(db: &Database, name: &str, version: Version) -> Result<Self>
fn import(db: &Database, name: &str, version: Version) -> Result<Self>
Import from database, creating if needed.
Source§fn import_with(options: ImportOptions<'_>) -> Result<Self>
fn import_with(options: ImportOptions<'_>) -> Result<Self>
Import with custom options.
Source§fn forced_import(db: &Database, name: &str, version: Version) -> Result<Self>
fn forced_import(db: &Database, name: &str, version: Version) -> Result<Self>
Import from database, resetting on version/format mismatch.
Source§fn forced_import_with(options: ImportOptions<'_>) -> Result<Self>
fn forced_import_with(options: ImportOptions<'_>) -> Result<Self>
Forced import with custom options.
Source§impl<I, T> ReadableCloneableVec<I, T> for LZ4Vec<I, T>where
I: VecIndex,
T: LZ4VecValue,
impl<I, T> ReadableCloneableVec<I, T> for LZ4Vec<I, T>where
I: VecIndex,
T: LZ4VecValue,
fn read_only_boxed_clone(&self) -> ReadableBoxedVec<I, T>
Source§impl<I, T> ReadableVec<I, T> for LZ4Vec<I, T>where
I: VecIndex,
T: LZ4VecValue,
impl<I, T> ReadableVec<I, T> for LZ4Vec<I, T>where
I: VecIndex,
T: LZ4VecValue,
Source§fn cursor_chunk_size(&self) -> usize
fn cursor_chunk_size(&self) -> usize
Preferred number of values per cursor refill. Read more
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> StoredVec for LZ4Vec<I, T>where
I: VecIndex,
T: LZ4VecValue,
impl<I, T> StoredVec for LZ4Vec<I, T>where
I: VecIndex,
T: LZ4VecValue,
Source§type ReadOnly = ReadOnlyCompressedVec<I, T, LZ4Strategy<T>>
type ReadOnly = ReadOnlyCompressedVec<I, T, LZ4Strategy<T>>
The concrete lean read-only type returned by
read_only_clone.Source§fn read_only_clone(&self) -> Self::ReadOnly
fn read_only_clone(&self) -> Self::ReadOnly
Creates a lean read-only clone that only carries fields needed for disk reads.
Source§impl<I, T> WritableVec<I, T> for LZ4Vec<I, T>where
I: VecIndex,
T: LZ4VecValue,
impl<I, T> WritableVec<I, T> for LZ4Vec<I, T>where
I: VecIndex,
T: LZ4VecValue,
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 debug_checked_push(&mut self, _index: I, value: T)
fn debug_checked_push(&mut self, _index: I, value: T)
Pushes a value and checks its expected index in debug builds.
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> !RefUnwindSafe for LZ4Vec<I, T>
impl<I, T> !UnwindSafe for LZ4Vec<I, T>
impl<I, T> Freeze for LZ4Vec<I, T>
impl<I, T> Send for LZ4Vec<I, T>
impl<I, T> Sync for LZ4Vec<I, T>
impl<I, T> Unpin for LZ4Vec<I, T>
impl<I, T> UnsafeUnpin for LZ4Vec<I, T>
Blanket Implementations§
impl<V> AnyExportableVec for Vwhere
V: AnyVecWithWriter + AnySerializableVec,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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 more