pub struct CompressedVec<I, T> { /* private fields */ }Expand description
Compressed storage vector using Pcodec for lossless numerical compression.
Values are compressed in pages for better space efficiency. Best for sequential access patterns of numerical data. Random access is possible but less efficient than RawVec - prefer the latter for random access workloads.
Implementations§
Source§impl<I, T> CompressedVec<I, T>where
I: StoredIndex,
T: StoredCompressed,
impl<I, T> CompressedVec<I, T>where
I: StoredIndex,
T: StoredCompressed,
Sourcepub fn forced_import(
db: &Database,
name: &str,
version: Version,
) -> Result<Self>
pub fn forced_import( db: &Database, name: &str, version: Version, ) -> Result<Self>
Same as import but will reset the vec under certain errors, so be careful !
Sourcepub fn forced_import_with(options: ImportOptions<'_>) -> Result<Self>
pub fn forced_import_with(options: ImportOptions<'_>) -> Result<Self>
Same as import but will reset the vec under certain errors, so be careful !
pub fn import(db: &Database, name: &str, version: Version) -> Result<Self>
pub fn import_with(options: ImportOptions<'_>) -> Result<Self>
pub fn iter(&self) -> Result<CompressedVecIterator<'_, I, T>>
pub fn clean_iter(&self) -> Result<CleanCompressedVecIterator<'_, I, T>>
pub fn dirty_iter(&self) -> Result<DirtyCompressedVecIterator<'_, I, T>>
pub fn is_dirty(&self) -> bool
Trait Implementations§
Source§impl<I: Allocative, T: Allocative> Allocative for CompressedVec<I, T>
impl<I: Allocative, T: Allocative> Allocative for CompressedVec<I, T>
Source§impl<I, T> AnyCollectableVec for CompressedVec<I, T>where
I: StoredIndex,
T: StoredCompressed,
impl<I, T> AnyCollectableVec for CompressedVec<I, T>where
I: StoredIndex,
T: StoredCompressed,
fn collect_range_json_bytes( &self, from: Option<usize>, to: Option<usize>, ) -> Vec<u8> ⓘ
fn collect_range_string( &self, from: Option<usize>, to: Option<usize>, ) -> Vec<String>
Source§impl<I, T> AnyIterableVec<I, T> for CompressedVec<I, T>where
I: StoredIndex,
T: StoredCompressed,
impl<I, T> AnyIterableVec<I, T> for CompressedVec<I, T>where
I: StoredIndex,
T: StoredCompressed,
fn boxed_iter(&self) -> BoxedVecIterator<'_, I, T>
fn iter(&self) -> BoxedVecIterator<'_, I, T>where
I: StoredIndex,
T: StoredRaw,
Source§impl<I, T> AnyStoredVec for CompressedVec<I, T>where
I: StoredIndex,
T: StoredCompressed,
impl<I, T> AnyStoredVec for CompressedVec<I, T>where
I: StoredIndex,
T: StoredCompressed,
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 stored_len(&self) -> usize
fn stored_len(&self) -> usize
The effective stored length (may differ from real_stored_len during truncation).
Source§fn real_stored_len(&self) -> usize
fn real_stored_len(&self) -> usize
The actual length stored on disk.
fn flush(&mut self) -> Result<()>
fn serialize_changes(&self) -> Result<Vec<u8>>
Source§fn safe_flush(&mut self, exit: &Exit) -> Result<()>
fn safe_flush(&mut self, exit: &Exit) -> Result<()>
Flushes while holding the exit lock to ensure consistency during shutdown.
fn update_stamp(&mut self, stamp: Stamp)
fn stamp(&self) -> Stamp
fn stamped_flush(&mut self, stamp: Stamp) -> Result<()>
Source§impl<I, T> AnyVec for CompressedVec<I, T>where
I: StoredIndex,
T: StoredCompressed,
impl<I, T> AnyVec for CompressedVec<I, T>where
I: StoredIndex,
T: StoredCompressed,
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 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 index_to_name(&self) -> String
fn index_to_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> Clone for CompressedVec<I, T>
impl<I, T> Clone for CompressedVec<I, T>
Source§impl<I, T> GenericStoredVec<I, T> for CompressedVec<I, T>where
I: StoredIndex,
T: StoredCompressed,
impl<I, T> GenericStoredVec<I, T> for CompressedVec<I, T>where
I: StoredIndex,
T: StoredCompressed,
Source§fn read_at(&self, index: usize, reader: &Reader<'_>) -> Result<T>
fn read_at(&self, index: usize, reader: &Reader<'_>) -> Result<T>
Reads value at usize index using provided reader.
Source§fn mut_pushed(&mut self) -> &mut Vec<T>
fn mut_pushed(&mut self) -> &mut Vec<T>
Returns a mutable reference to the current pushed (uncommitted) values.
Source§fn mut_holes(&mut self) -> &mut BTreeSet<usize>
fn mut_holes(&mut self) -> &mut BTreeSet<usize>
Returns a mutable reference to the set of holes.
Source§fn updated(&self) -> &BTreeMap<usize, T>
fn updated(&self) -> &BTreeMap<usize, T>
Returns the map of updated (uncommitted modifications to stored) values.
Source§fn mut_updated(&mut self) -> &mut BTreeMap<usize, T>
fn mut_updated(&mut self) -> &mut BTreeMap<usize, T>
Returns a mutable reference to the map of updated values.
const SIZE_OF_T: usize = _
Source§fn create_reader(&self) -> Reader<'_>
fn create_reader(&self) -> Reader<'_>
Creates a reader with lifetime tied to self.
Be careful with deadlocks - drop the reader before mutable ops.
Source§fn create_static_reader(&self) -> Reader<'static>
fn create_static_reader(&self) -> Reader<'static>
Creates a reader with ’static lifetime.
Be careful with deadlocks - drop the reader before mutable ops.
Source§fn read(&self, index: I, reader: &Reader<'_>) -> Result<T>
fn read(&self, index: I, reader: &Reader<'_>) -> Result<T>
Reads value at index using provided reader.
Source§fn read_once(&self, index: I) -> Result<T>
fn read_once(&self, index: I) -> Result<T>
Reads value at index, creating a temporary reader.
For multiple reads, prefer
read() with a reused reader.Source§fn read_at_once(&self, index: usize) -> Result<T>
fn read_at_once(&self, index: usize) -> Result<T>
Reads value at usize index, creating a temporary reader.
For multiple reads, prefer
read_at() with a reused reader.Source§fn read_unwrap(&self, index: I, reader: &Reader<'_>) -> T
fn read_unwrap(&self, index: I, reader: &Reader<'_>) -> T
Reads value at index using provided reader. Panics if read fails.
Source§fn read_unwrap_once(&self, index: I) -> T
fn read_unwrap_once(&self, index: I) -> T
Reads value at index, creating a temporary reader. Panics if read fails.
For multiple reads, prefer
read_unwrap() with a reused reader.Source§fn read_at_unwrap(&self, index: usize, reader: &Reader<'_>) -> T
fn read_at_unwrap(&self, index: usize, reader: &Reader<'_>) -> T
Reads value at usize index using provided reader. Panics if read fails.
Source§fn read_at_unwrap_once(&self, index: usize) -> T
fn read_at_unwrap_once(&self, index: usize) -> T
Reads value at usize index, creating a temporary reader. Panics if read fails.
For multiple reads, prefer
read_at_unwrap() with a reused reader.Source§fn get_or_read(&self, index: I, reader: &Reader<'_>) -> Result<Option<T>>
fn get_or_read(&self, index: I, reader: &Reader<'_>) -> Result<Option<T>>
Gets value from any layer (updated, pushed, or storage) using provided reader.
Returns None if index is in holes or beyond available data.
Source§fn get_or_read_once(&self, index: I) -> Result<Option<T>>
fn get_or_read_once(&self, index: I) -> Result<Option<T>>
Gets value from any layer, creating a temporary reader if needed.
For multiple reads, prefer
get_or_read() with a reused reader.Source§fn get_or_read_at(&self, index: usize, reader: &Reader<'_>) -> Result<Option<T>>
fn get_or_read_at(&self, index: usize, reader: &Reader<'_>) -> Result<Option<T>>
Gets value from any layer at usize index using provided reader.
Returns None if index is in holes or beyond available data.
Source§fn get_or_read_at_once(&self, index: usize) -> Result<Option<T>>
fn get_or_read_at_once(&self, index: usize) -> Result<Option<T>>
Gets value from any layer at usize index, creating a temporary reader.
For multiple reads, prefer
get_or_read_at() with a reused reader.Source§fn get_or_read_unwrap(&self, index: I, reader: &Reader<'_>) -> T
fn get_or_read_unwrap(&self, index: I, reader: &Reader<'_>) -> T
Gets value from any layer using provided reader. Panics on error.
Source§fn get_or_read_unwrap_once(&self, index: I) -> T
fn get_or_read_unwrap_once(&self, index: I) -> T
Gets value from any layer, creating a temporary reader. Panics on error.
Source§fn get_pushed_or_read(&self, index: I, reader: &Reader<'_>) -> Result<Option<T>>
fn get_pushed_or_read(&self, index: I, reader: &Reader<'_>) -> Result<Option<T>>
Gets value from pushed layer or storage using provided reader.
Does not check the updated layer.
Source§fn get_pushed_or_read_once(&self, index: I) -> Result<Option<T>>
fn get_pushed_or_read_once(&self, index: I) -> Result<Option<T>>
Gets value from pushed layer or storage, creating a temporary reader.
For multiple reads, prefer
get_pushed_or_read() with a reused reader.Source§fn get_pushed_or_read_at(
&self,
index: usize,
reader: &Reader<'_>,
) -> Result<Option<T>>
fn get_pushed_or_read_at( &self, index: usize, reader: &Reader<'_>, ) -> Result<Option<T>>
Gets value from pushed layer or storage at usize index using provided reader.
Does not check the updated layer.
Source§fn get_pushed_or_read_at_once(&self, index: usize) -> Result<Option<T>>
fn get_pushed_or_read_at_once(&self, index: usize) -> Result<Option<T>>
Gets value from pushed layer or storage at usize index, creating a temporary reader.
For multiple reads, prefer
get_pushed_or_read_at() with a reused reader.Source§fn get_pushed_at(&self, index: usize, stored_len: usize) -> Option<&T>
fn get_pushed_at(&self, index: usize, stored_len: usize) -> Option<&T>
Gets value from pushed layer only (no disk reads).
Source§fn len_(&self) -> usize
fn len_(&self) -> usize
Returns the length including both stored and pushed (uncommitted) values.
Named
len_ to avoid conflict with AnyVec::len.Source§fn pushed_len(&self) -> usize
fn pushed_len(&self) -> usize
Returns the number of pushed (uncommitted) values.
Source§fn is_pushed_empty(&self) -> bool
fn is_pushed_empty(&self) -> bool
Returns true if there are no pushed (uncommitted) values.
Source§fn push_if_needed(&mut self, index: I, value: T) -> Result<()>
fn push_if_needed(&mut self, index: I, value: T) -> Result<()>
Pushes a value if the index equals the current length, otherwise does nothing if already exists.
Returns an error if the index is too high.
Source§fn forced_push(&mut self, index: I, value: T, exit: &Exit) -> Result<()>
fn forced_push(&mut self, index: I, value: T, exit: &Exit) -> Result<()>
Pushes a value at the given index, truncating if necessary, and flushes if cache is full.
Source§fn forced_push_at(&mut self, index: usize, value: T, exit: &Exit) -> Result<()>
fn forced_push_at(&mut self, index: usize, value: T, exit: &Exit) -> Result<()>
Pushes a value at the given usize index, truncating if necessary, and flushes if cache is full.
Source§fn update_at(&mut self, index: usize, value: T) -> Result<()>
fn update_at(&mut self, index: usize, value: T) -> Result<()>
Updates the value at the given usize index.
Source§fn update_or_push(&mut self, index: I, value: T) -> Result<()>
fn update_or_push(&mut self, index: I, value: T) -> Result<()>
Updates the value at the given index if it exists, or pushes it if the index equals length.
Source§fn get_first_empty_index(&self) -> I
fn get_first_empty_index(&self) -> I
Returns the first empty index (either the first hole or the length).
Source§fn fill_first_hole_or_push(&mut self, value: T) -> Result<I>
fn fill_first_hole_or_push(&mut self, value: T) -> Result<I>
Fills the first hole with the value, or pushes if there are no holes. Returns the index used.
Source§fn take(&mut self, index: I, reader: &Reader<'_>) -> Result<Option<T>>
fn take(&mut self, index: I, reader: &Reader<'_>) -> Result<Option<T>>
Takes (removes and returns) the value at the given index using provided reader.
Source§fn take_at(&mut self, index: usize, reader: &Reader<'_>) -> Result<Option<T>>
fn take_at(&mut self, index: usize, reader: &Reader<'_>) -> Result<Option<T>>
Takes (removes and returns) the value at the given usize index using provided reader.
Source§fn delete_at(&mut self, index: usize)
fn delete_at(&mut self, index: usize)
Deletes the value at the given usize index (marks it as a hole).
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_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 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 reset_unsaved(&mut self)
fn reset_unsaved(&mut self)
Resets uncommitted changes (pushed, holes, and updated layers).
Source§fn validate_computed_version_or_reset(&mut self, version: Version) -> Result<()>
fn validate_computed_version_or_reset(&mut self, version: Version) -> Result<()>
Validates the computed version against the stored version, resetting if they don’t match.
Source§fn collect_holed(&self) -> Result<Vec<Option<T>>>
fn collect_holed(&self) -> Result<Vec<Option<T>>>
Collects all values into a Vec, with None for holes.
Source§fn collect_holed_range(
&self,
from: Option<usize>,
to: Option<usize>,
) -> Result<Vec<Option<T>>>
fn collect_holed_range( &self, from: Option<usize>, to: Option<usize>, ) -> Result<Vec<Option<T>>>
Collects values in the given range into a Vec, with None for holes.
Source§fn is_dirty(&mut self) -> bool
fn is_dirty(&mut self) -> bool
Returns true if there are uncommitted changes (pushed or updated values).
Source§fn changes_path(&self) -> PathBuf
fn changes_path(&self) -> PathBuf
Returns the path to the changes directory for this vector.
Source§fn stamped_flush_maybe_with_changes(
&mut self,
stamp: Stamp,
with_changes: bool,
) -> Result<()>
fn stamped_flush_maybe_with_changes( &mut self, stamp: Stamp, with_changes: bool, ) -> Result<()>
Flushes with the given stamp, optionally saving changes for rollback.
Source§fn stamped_flush_with_changes(&mut self, stamp: Stamp) -> Result<()>
fn stamped_flush_with_changes(&mut self, stamp: Stamp) -> Result<()>
Flushes with the given stamp, saving changes to enable rollback.
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 deserialize_then_undo_changes(&mut self, bytes: &[u8]) -> Result<()>
fn deserialize_then_undo_changes(&mut self, bytes: &[u8]) -> Result<()>
Deserializes change data and undoes those changes.
Source§fn vec_region_name(&self) -> String
fn vec_region_name(&self) -> String
Returns the region name for this vector.
Source§fn vec_region_name_with(name: &str) -> String
fn vec_region_name_with(name: &str) -> String
Returns the region name for the given vector name.
MUST BE in sync with AnyVec::index_to_name
Source§fn holes_region_name(&self) -> String
fn holes_region_name(&self) -> String
Returns the region name for the holes of this vector.
Source§fn holes_region_name_with(name: &str) -> String
fn holes_region_name_with(name: &str) -> String
Returns the region name for the holes of the given vector name.
Source§impl<'a, I, T> IntoIterator for &'a CompressedVec<I, T>where
I: StoredIndex,
T: StoredCompressed,
impl<'a, I, T> IntoIterator for &'a CompressedVec<I, T>where
I: StoredIndex,
T: StoredCompressed,
Auto Trait Implementations§
impl<I, T> Freeze for CompressedVec<I, T>
impl<I, T> !RefUnwindSafe for CompressedVec<I, T>
impl<I, T> Send for CompressedVec<I, T>
impl<I, T> Sync for CompressedVec<I, T>
impl<I, T> Unpin for CompressedVec<I, T>
impl<I, T> !UnwindSafe for CompressedVec<I, T>
Blanket Implementations§
Source§impl<I, T, U> AnyCloneableIterableVec<I, T> for Uwhere
U: 'static + AnyIterableVec<I, T> + Clone,
impl<I, T, U> AnyCloneableIterableVec<I, T> for Uwhere
U: 'static + AnyIterableVec<I, T> + Clone,
fn boxed_clone(&self) -> Box<dyn AnyCloneableIterableVec<I, T>>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<I, T, V> CollectableVec<I, T> for V
impl<I, T, V> CollectableVec<I, T> for V
Source§fn iter_range(
&self,
from: Option<usize>,
to: Option<usize>,
) -> impl Iterator<Item = T>
fn iter_range( &self, from: Option<usize>, to: Option<usize>, ) -> impl Iterator<Item = T>
Returns an iterator over the specified range.
Source§fn iter_signed_range(
&self,
from: Option<i64>,
to: Option<i64>,
) -> impl Iterator<Item = T>
fn iter_signed_range( &self, from: Option<i64>, to: Option<i64>, ) -> impl Iterator<Item = T>
Returns an iterator over the specified range using signed indices (supports negative indexing).
Source§fn collect_range(&self, from: Option<usize>, to: Option<usize>) -> Vec<T>
fn collect_range(&self, from: Option<usize>, to: Option<usize>) -> Vec<T>
Collects values in the specified range into a Vec.
Source§fn collect_signed_range(&self, from: Option<i64>, to: Option<i64>) -> Vec<T>
fn collect_signed_range(&self, from: Option<i64>, to: Option<i64>) -> Vec<T>
Collects values in the specified range into a Vec using signed indices.
Source§fn collect_range_json_bytes(
&self,
from: Option<usize>,
to: Option<usize>,
) -> Vec<u8> ⓘ
fn collect_range_json_bytes( &self, from: Option<usize>, to: Option<usize>, ) -> Vec<u8> ⓘ
Collects values in the specified range as JSON bytes.
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