pub struct StreamingDownsampler { /* private fields */ }Expand description
Boundary-safe downsampling over a sequence of time-ordered batches.
Rows must arrive ascending by timestamp — which is what the query engine’s merge guarantees — so a bucket is complete as soon as a row belonging to a later bucket is seen. Buckets are emitted in order and exactly once.
§Example
let mut ds = StreamingDownsampler::new("value", 60_000_000_000, AggFn::Avg)?;
let mut out = Vec::new();
for batch in batches() {
out.extend(ds.push(&batch)?);
}
out.extend(ds.finish()?);Implementations§
Source§impl StreamingDownsampler
impl StreamingDownsampler
Sourcepub fn new(value_column: &str, interval: i64, function: AggFn) -> Result<Self>
pub fn new(value_column: &str, interval: i64, function: AggFn) -> Result<Self>
Create a downsampler for value_column over interval-wide buckets.
§Errors
Returns an error if interval is not positive.
Sourcepub fn push(&mut self, batch: &RecordBatch) -> Result<Vec<RecordBatch>>
pub fn push(&mut self, batch: &RecordBatch) -> Result<Vec<RecordBatch>>
Fold one batch in, returning any batches of completed buckets.
§Errors
Returns an error if the timestamp or value column is missing or has an unsupported type, or if a row arrives out of timestamp order.
Auto Trait Implementations§
impl Freeze for StreamingDownsampler
impl RefUnwindSafe for StreamingDownsampler
impl Send for StreamingDownsampler
impl Sync for StreamingDownsampler
impl Unpin for StreamingDownsampler
impl UnsafeUnpin for StreamingDownsampler
impl UnwindSafe for StreamingDownsampler
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more