pub struct SnapshotTable {
pub snapshots: Vec<Snapshot>,
pub diffs: Vec<DiffEntry>,
pub compressed: HashMap<String, Vec<(f64, usize)>>,
}Expand description
Time-indexed table of simulation snapshots with optional RLE compression and differential storage.
Fields§
§snapshots: Vec<Snapshot>Stored snapshots ordered by insertion time.
diffs: Vec<DiffEntry>Differential entries for fields that change sparsely between snapshots.
compressed: HashMap<String, Vec<(f64, usize)>>RLE-compressed versions of field arrays, keyed by "field@time_idx".
Implementations§
Source§impl SnapshotTable
impl SnapshotTable
Sourcepub fn insert(&mut self, snap: Snapshot)
pub fn insert(&mut self, snap: Snapshot)
Insert a snapshot; snapshots are kept in ascending time order.
Sourcepub fn query_time_range(&self, t_lo: f64, t_hi: f64) -> Vec<&Snapshot>
pub fn query_time_range(&self, t_lo: f64, t_hi: f64) -> Vec<&Snapshot>
Return all snapshots whose time falls in \[t_lo, t_hi\].
Sourcepub fn nearest(&self, t: f64) -> Option<&Snapshot>
pub fn nearest(&self, t: f64) -> Option<&Snapshot>
Retrieve a single snapshot whose time is closest to t.
Sourcepub fn compress_field(&mut self, snap_idx: usize, field: &str)
pub fn compress_field(&mut self, snap_idx: usize, field: &str)
Compress a named field of the snapshot at index snap_idx using RLE.
The compressed data is stored internally under the key
"field@snap_idx".
Sourcepub fn decompress_field(&self, snap_idx: usize, field: &str) -> Option<Vec<f64>>
pub fn decompress_field(&self, snap_idx: usize, field: &str) -> Option<Vec<f64>>
Decompress a previously compressed field, returning the flat Vecf64`.
Returns None if the field was not compressed.
Sourcepub fn compute_diff(&mut self, field: &str, snap_idx: usize) -> usize
pub fn compute_diff(&mut self, field: &str, snap_idx: usize) -> usize
Compute the differential between consecutive snapshots for a named field
and store the result in self.diffs.
Returns the number of changed elements.
Sourcepub fn apply_diff(base: &mut [f64], diff: &DiffEntry)
pub fn apply_diff(base: &mut [f64], diff: &DiffEntry)
Apply a stored diff to a base field array, returning the updated array.
base is modified in-place by overwriting the changed indices.
Trait Implementations§
Source§impl Debug for SnapshotTable
impl Debug for SnapshotTable
Source§impl Default for SnapshotTable
impl Default for SnapshotTable
Source§fn default() -> SnapshotTable
fn default() -> SnapshotTable
Auto Trait Implementations§
impl Freeze for SnapshotTable
impl RefUnwindSafe for SnapshotTable
impl Send for SnapshotTable
impl Sync for SnapshotTable
impl Unpin for SnapshotTable
impl UnsafeUnpin for SnapshotTable
impl UnwindSafe for SnapshotTable
Blanket Implementations§
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
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.