Skip to main content

Module analog_signal_cache

Module analog_signal_cache 

Source
Expand description

Analog signal cache with fast min/max queries using Blocked RMQ + Binary Search

§Complexity

  • Construction: O(N + N/B · log(N/B))

  • Time queries: O(log N) for binary search + O(1) for min/max

  • Memory: O(N + N/B · log(N/B)) where B is the block size

Per-sample storage (N samples):

  • timestamps: Vec<u64> = 8N bytes
  • values: Vec<f64> = 8N bytes

Sparse table storage (B = 64 default block size):

  • MinMax struct = 24 bytes (8 + 8 + 1 + padding)
  • num_blocks = ⌈N/B⌉
  • num_levels = 1 + ⌊log₂(num_blocks)
  • Sparse table = num_blocks × num_levels × 24 bytes

Total ≈ 16N + (N/64) × (1 + log₂(N/64)) × 24 bytes

§Examples

1M Samples ~ 21.3 MB 100M Samples ~ 2.39 GB

Structs§

AnalogCacheEntry
Wrapper for analog cache with reference counting and lazy initialization.
AnalogSignalCache
Cache entry for a single analog signal.
CacheQueryResult
MinMax 🔒
SignalRMQ 🔒

Constants§

NAN_HIGHIMP
Quiet NaN representing high-impedance (Z) values in analog signals.
NAN_UNDEF
Quiet NaN representing undefined (X) values in analog signals.

Functions§

is_nan_highimp
Check NaN payload to determine if it represents HighImp.