TimeWindow

Struct TimeWindow 

Source
pub struct TimeWindow {
    pub window_type: WindowType,
    pub duration: Duration,
    pub start_time: u64,
    pub end_time: u64,
    /* private fields */
}
Expand description

Time-based window for event processing

Fields§

§window_type: WindowType

Window type

§duration: Duration

Window duration

§start_time: u64

Window start time (milliseconds since epoch)

§end_time: u64

Window end time (milliseconds since epoch)

Implementations§

Source§

impl TimeWindow

Source

pub fn new( window_type: WindowType, duration: Duration, start_time: u64, max_events: usize, ) -> Self

Create a new time window

Source

pub fn add_event(&mut self, event: StreamEvent) -> bool

Add event to window if it fits

Source

pub fn contains_timestamp(&self, timestamp: u64) -> bool

Check if timestamp falls within this window

Source

pub fn events(&self) -> &VecDeque<StreamEvent>

Get all events in window

Source

pub fn count(&self) -> usize

Get event count

Source

pub fn is_expired(&self, current_time: u64) -> bool

Check if window is expired

Source

pub fn duration_ms(&self) -> u64

Get window duration in milliseconds

Source

pub fn clear(&mut self)

Clear all events from window

Source

pub fn events_by_type(&self, event_type: &str) -> Vec<&StreamEvent>

Get events filtered by type

Source

pub fn sum(&self, field: &str) -> f64

Calculate sum of numeric field across events

Source

pub fn average(&self, field: &str) -> Option<f64>

Calculate average of numeric field across events

Source

pub fn min(&self, field: &str) -> Option<f64>

Find minimum value of numeric field

Source

pub fn max(&self, field: &str) -> Option<f64>

Find maximum value of numeric field

Source

pub fn latest_timestamp(&self) -> Option<u64>

Get the latest event timestamp

Source

pub fn events_in_range(&self, start: u64, end: u64) -> Vec<&StreamEvent>

Get events within a sub-window

Trait Implementations§

Source§

impl Debug for TimeWindow

Source§

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

Formats the value using the given formatter. Read more

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.