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 bytesvalues: Vec<f64>= 8N bytes
Sparse table storage (B = 64 default block size):
MinMaxstruct = 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§
- Analog
Cache Entry - Wrapper for analog cache with reference counting and lazy initialization.
- Analog
Signal Cache - Cache entry for a single analog signal.
- Cache
Query Result - 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.