pub struct SectorSummary {
pub state: SectorState,
pub sequence: u32,
pub entry_count: u32,
pub sample_count: u32,
pub write_offset: u32,
pub min_timestamp: u64,
pub max_timestamp: u64,
pub sensor_bloom: u64,
pub erase_count: u32,
}Expand description
In-RAM summary of a sector for fast queries.
Fields§
§state: SectorStateCurrent state of the sector.
sequence: u32Sequence number from header (0 if erased).
entry_count: u32Number of valid entries in this sector.
Entries, not samples: a run is one entry however many
samples it holds. This is the unit replication works in — the spooler
copies entries, and the eviction accounting has to agree with it — so it
is deliberately not the number a reader sees. That is
sample_count.
sample_count: u32Number of samples readable from this sector.
Equal to entry_count unless the sector holds
runs, each of which contributes all of its samples. This is what count
reports and what a query yields, because a run expands transparently.
write_offset: u32Next write offset within the sector.
min_timestamp: u64Minimum timestamp of entries in this sector.
max_timestamp: u64Maximum timestamp of any sample in this sector.
A run reaches past its entry header’s timestamp, so it contributes the timestamp of its last sample. Keeping this the maximum over samples rather than over headers is what lets sector pruning stay exact: a query for a run’s tail must not skip the sector the run began in.
sensor_bloom: u64Bloom filter bitset of sensor IDs present in this sector.
Each sensor ID is hashed to one of 64 bits using Fibonacci hashing. For ≤16 distinct sensors (typical), near-zero false positives. No false negatives by construction.
erase_count: u32Number of times this sector has been erased (from the SD03 header).
Implementations§
Source§impl SectorSummary
impl SectorSummary
Sourcepub fn overlaps_time_range(&self, t_start: u64, t_end: u64) -> bool
pub fn overlaps_time_range(&self, t_start: u64, t_end: u64) -> bool
Check if a timestamp range overlaps with this sector’s entries.
Sourcepub fn record_sensor(&mut self, sensor_id: u16)
pub fn record_sensor(&mut self, sensor_id: u16)
Record a sensor ID in this sector’s bloom filter.
Sourcepub fn might_contain_sensor(&self, sensor_id: u16) -> bool
pub fn might_contain_sensor(&self, sensor_id: u16) -> bool
Check if this sector might contain entries for a given sensor ID.
Returns false only if the sensor is definitely absent (no false negatives).
May return true for absent sensors (false positives possible but rare for ≤16 sensors).
Sourcepub fn record_span(&mut self, first: u64, last: u64)
pub fn record_span(&mut self, first: u64, last: u64)
Widen the sector’s bounds to cover an entry spanning first..=last.
A single sample passes its timestamp twice; a run passes
the timestamps of its first and last samples, which is what keeps
overlaps_time_range exact for a query
aimed at a run’s tail.
Sourcepub fn update_timestamps(&mut self, timestamp: u64)
pub fn update_timestamps(&mut self, timestamp: u64)
Update timestamp bounds with a new entry.
Trait Implementations§
Source§impl Clone for SectorSummary
impl Clone for SectorSummary
impl Copy for SectorSummary
Source§impl Debug for SectorSummary
impl Debug for SectorSummary
Source§impl Default for SectorSummary
impl Default for SectorSummary
Source§impl Format for SectorSummarywhere
SectorState: Format,
Available on crate feature defmt only.
impl Format for SectorSummarywhere
SectorState: Format,
defmt only.