pub struct ReaderWheel<A>where
A: Aggregator,{ /* private fields */ }
Expand description
A reader wheel containing a hierarchical aggregate wheel Haw backed by interior mutability.
By default allows a single reader using RefCell
, and multiple-readers with the sync
flag enabled using parking_lot
Implementations§
Source§impl<A> ReaderWheel<A>where
A: Aggregator,
impl<A> ReaderWheel<A>where
A: Aggregator,
Sourcepub fn new(time: u64) -> Self
pub fn new(time: u64) -> Self
Creates a new Wheel starting from the given time with default configuration
Time is represented as milliseconds
Sourcepub fn with_conf(conf: HawConf) -> Self
pub fn with_conf(conf: HawConf) -> Self
Creates a new Wheel starting from the given configuration
Sourcepub fn from_delta_state(state: DeltaState<A::PartialAggregate>) -> Self
pub fn from_delta_state(state: DeltaState<A::PartialAggregate>) -> Self
Creates a new Wheel from a set of deltas
Sourcepub fn delta_state(&self) -> DeltaState<A::PartialAggregate>
pub fn delta_state(&self) -> DeltaState<A::PartialAggregate>
Returns the current Delta State for the Reader Wheel
Sourcepub fn remaining_ticks(&self) -> u64
pub fn remaining_ticks(&self) -> u64
Returns how many ticks (seconds) are left until the wheel is fully utilised
Sourcepub fn to_prefix_wheels(&self)
pub fn to_prefix_wheels(&self)
Converts all wheels to be prefix-enabled
See Haw::to_prefix_wheels for more information
Sourcepub fn to_simd_wheels(&self)
pub fn to_simd_wheels(&self)
Organizes all wheels to be contigious to support explicit SIMD execution.
See Haw::to_simd_wheels for more information
Sourcepub fn current_time_in_cycle(&self) -> Duration
pub fn current_time_in_cycle(&self) -> Duration
Returns Duration that represents where the wheel currently is in its cycle
Sourcepub fn schedule_once(
&self,
at: u64,
f: impl Fn(&Haw<A>) + 'static,
) -> Result<(), TimerError<TimerAction<A>>>
Available on crate feature timer
only.
pub fn schedule_once( &self, at: u64, f: impl Fn(&Haw<A>) + 'static, ) -> Result<(), TimerError<TimerAction<A>>>
timer
only.Schedules a timer to fire once the given time has been reached
See Haw::schedule_once
for more information.
Sourcepub fn schedule_repeat(
&self,
at: u64,
interval: Duration,
f: impl Fn(&Haw<A>) + 'static,
) -> Result<(), TimerError<TimerAction<A>>>
Available on crate feature timer
only.
pub fn schedule_repeat( &self, at: u64, interval: Duration, f: impl Fn(&Haw<A>) + 'static, ) -> Result<(), TimerError<TimerAction<A>>>
timer
only.Schedules a timer to fire repeatedly
See Haw::schedule_repeat
for more information.
Sourcepub fn delta_advance(
&self,
deltas: impl IntoIterator<Item = Option<A::PartialAggregate>>,
)
pub fn delta_advance( &self, deltas: impl IntoIterator<Item = Option<A::PartialAggregate>>, )
Advances the wheel by applying a set of deltas, each representing the lowest unit.
See Haw::delta_advance
for more information.
Sourcepub fn interval_and_lower(&self, dur: Duration) -> Option<A::Aggregate>
pub fn interval_and_lower(&self, dur: Duration) -> Option<A::Aggregate>
Returns the aggregate in the given time interval
Sourcepub fn interval(&self, dur: Duration) -> Option<A::PartialAggregate>
pub fn interval(&self, dur: Duration) -> Option<A::PartialAggregate>
Returns the partial aggregate in the given time interval
See Haw::interval
for more information.
Sourcepub fn interval_with_ops(
&self,
dur: Duration,
) -> (Option<A::PartialAggregate>, usize)
pub fn interval_with_ops( &self, dur: Duration, ) -> (Option<A::PartialAggregate>, usize)
Returns the partial aggregate in the given time interval and the number of combine operations
Sourcepub fn combine_range(
&self,
range: impl Into<WheelRange>,
) -> Option<A::PartialAggregate>
pub fn combine_range( &self, range: impl Into<WheelRange>, ) -> Option<A::PartialAggregate>
Combines partial aggregates within the given date range [start, end) into a final partial aggregate
Returns None
if the range cannot be answered by the wheel
See Haw::combine_range
for more information.
Sourcepub fn combine_range_and_lower(
&self,
range: impl Into<WheelRange>,
) -> Option<A::Aggregate>
pub fn combine_range_and_lower( &self, range: impl Into<WheelRange>, ) -> Option<A::Aggregate>
Combines aggregates within the given date range [start, end) into a final partial aggregate
Returns None
if the range cannot be answered by the wheel
See Haw::combine_range_and_lower
for more information.
Sourcepub fn group_by(
&self,
range: WheelRange,
interval: Duration,
) -> Option<Vec<(u64, A::Aggregate)>>
pub fn group_by( &self, range: WheelRange, interval: Duration, ) -> Option<Vec<(u64, A::Aggregate)>>
Groups the data into aggregates based on the given range and interval
Returns None
if the range cannot be answered by the wheel
§Arguments
range
- The range to group the data (e.g., 2024-05-06 00:00:00 - 2024-05-10 00:00:00)interval
- The duration which aggregates are grouped into (e.g., 1d)
See Haw::group_by
for more information.
Sourcepub fn range(
&self,
range: impl Into<WheelRange>,
) -> Option<Vec<(u64, A::PartialAggregate)>>
pub fn range( &self, range: impl Into<WheelRange>, ) -> Option<Vec<(u64, A::PartialAggregate)>>
Returns partial aggregates within the given date range [start, end) using the lowest granularity
Returns None
if the range cannot be answered by the wheel
See Haw::range
for more information.
Sourcepub fn range_and_lower(
&self,
range: impl Into<WheelRange>,
) -> Option<Vec<(u64, A::Aggregate)>>
pub fn range_and_lower( &self, range: impl Into<WheelRange>, ) -> Option<Vec<(u64, A::Aggregate)>>
Returns aggregates within the given date range [start, end) using the lowest granularity
Returns None
if the range cannot be answered by the wheel
See Haw::range_and_lower
for more information.
Sourcepub fn landmark(&self) -> Option<A::PartialAggregate>
pub fn landmark(&self) -> Option<A::PartialAggregate>
Executes a Landmark Window that combines total partial aggregates across all wheels
See Haw::landmark
for more information.
Sourcepub fn merge(&self, other: &Self)
pub fn merge(&self, other: &Self)
Merges another ReaderWheel into this one
Trait Implementations§
Source§impl<A> Clone for ReaderWheel<A>where
A: Aggregator + Clone,
impl<A> Clone for ReaderWheel<A>where
A: Aggregator + Clone,
Source§fn clone(&self) -> ReaderWheel<A>
fn clone(&self) -> ReaderWheel<A>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more