Struct uwheel::wheels::read::ReaderWheel
source · 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::PartialAggregate>
pub fn combine_range_and_lower( &self, range: impl Into<WheelRange>, ) -> Option<A::PartialAggregate>
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 moresource§impl<'de, A> Deserialize<'de> for ReaderWheel<A>where
A: Aggregator + Default,
impl<'de, A> Deserialize<'de> for ReaderWheel<A>where
A: Aggregator + Default,
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl<A: Aggregator> From<Haw<A>> for ReaderWheel<A>
impl<A: Aggregator> From<Haw<A>> for ReaderWheel<A>
source§impl<A> Serialize for ReaderWheel<A>where
A: Aggregator + Default,
impl<A> Serialize for ReaderWheel<A>where
A: Aggregator + Default,
Auto Trait Implementations§
impl<A> Freeze for ReaderWheel<A>
impl<A> !RefUnwindSafe for ReaderWheel<A>
impl<A> !Send for ReaderWheel<A>
impl<A> !Sync for ReaderWheel<A>
impl<A> Unpin for ReaderWheel<A>
impl<A> !UnwindSafe for ReaderWheel<A>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)