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
// A fixed minute. `TimeBucket::parse("1d", Some("Europe/Berlin"))` for a
// calendar bucket — the same type SQL's `time_bucket()` uses.
let bucket = TimeBucket::fixed(Duration::from_secs(60));
let mut ds = StreamingDownsampler::new("value", bucket, 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,
bucket: TimeBucket,
function: AggFn,
) -> Result<Self>
pub fn new( value_column: &str, bucket: TimeBucket, function: AggFn, ) -> Result<Self>
Create a downsampler for value_column over bucket-wide buckets.
§Errors
Never fails today; the signature is fallible because push is, and
callers already handle a Result here.
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