pub struct BinStatistics<V, I, R> {
pub bin_width: R,
pub bins: BTreeMap<i64, WindowBin<V, I, R>>,
pub anchor: Option<I>,
}
Available on crate feature
std
only.Expand description
Time series data binning. Initialize it with a bin width and it will downsample/re-bin
your data providing each bin as a WindowBin
Fields§
§bin_width: R
§bins: BTreeMap<i64, WindowBin<V, I, R>>
§anchor: Option<I>
Implementations§
Source§impl<T: Copy> BinStatistics<f64, Timestamp<T>, Duration>
impl<T: Copy> BinStatistics<f64, Timestamp<T>, Duration>
pub fn new(bin_width: Duration) -> Self
Sourcepub fn insert(
&mut self,
timestamp: Timestamp<T>,
value: f64,
) -> &WindowBin<f64, Timestamp<T>, Duration>
pub fn insert( &mut self, timestamp: Timestamp<T>, value: f64, ) -> &WindowBin<f64, Timestamp<T>, Duration>
Process and insert a sample into it’s bin. Returns a reference to the bin in which it was inserted with the latest data.
Sourcepub fn remove_data_before(&mut self, timestamp: Timestamp<T>)
pub fn remove_data_before(&mut self, timestamp: Timestamp<T>)
Garbage collection - remove all data older than the specified timestamp’s bin.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn iter( &self, ) -> impl Iterator<Item = (&i64, &WindowBin<f64, Timestamp<T>, Duration>)>
Auto Trait Implementations§
impl<V, I, R> Freeze for BinStatistics<V, I, R>
impl<V, I, R> RefUnwindSafe for BinStatistics<V, I, R>
impl<V, I, R> Send for BinStatistics<V, I, R>
impl<V, I, R> Sync for BinStatistics<V, I, R>
impl<V, I, R> Unpin for BinStatistics<V, I, R>
impl<V, I, R> UnwindSafe for BinStatistics<V, I, R>
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
Mutably borrows from an owned value. Read more