Skip to main content

SectorSummary

Struct SectorSummary 

Source
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: SectorState

Current state of the sector.

§sequence: u32

Sequence number from header (0 if erased).

§entry_count: u32

Number 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: u32

Number 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: u32

Next write offset within the sector.

§min_timestamp: u64

Minimum timestamp of entries in this sector.

§max_timestamp: u64

Maximum 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: u64

Bloom 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: u32

Number of times this sector has been erased (from the SD03 header).

Implementations§

Source§

impl SectorSummary

Source

pub fn erased() -> Self

Create a new erased sector summary.

Source

pub fn overlaps_time_range(&self, t_start: u64, t_end: u64) -> bool

Check if a timestamp range overlaps with this sector’s entries.

Source

pub fn record_sensor(&mut self, sensor_id: u16)

Record a sensor ID in this sector’s bloom filter.

Source

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).

Source

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.

Source

pub fn update_timestamps(&mut self, timestamp: u64)

Update timestamp bounds with a new entry.

Trait Implementations§

Source§

impl Clone for SectorSummary

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for SectorSummary

Source§

impl Debug for SectorSummary

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SectorSummary

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Format for SectorSummary

Available on crate feature defmt only.
Source§

fn format(&self, f: Formatter<'_>)

Writes the defmt representation of self to fmt.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.