pub struct StreamingEvaluator<'a, T: EvaluationDomain> { /* private fields */ }Expand description
Streaming evaluator with reusable internal buffers.
Created from a borrowed ExpressionEvaluator; all scratch memory
(parameter staging, evaluation stack, result buffer) is allocated
once up front and reused for every row.
§Example
let eval: ExpressionEvaluator<f64> = ExpressionEvaluator::compile(atom)?;
let mut stream = StreamingEvaluator::new(&eval);
let rows = (0..1_000_000).map(|i| [i as f64]);
let n = stream.for_each(rows, |results| {
// consume results (same buffer, valid only within the callback)
})?;
assert_eq!(n, 1_000_000);Implementations§
Source§impl<T: EvaluationDomain + PowfExtension> StreamingEvaluator<'_, T>
impl<T: EvaluationDomain + PowfExtension> StreamingEvaluator<'_, T>
Sourcepub fn new(evaluator: &ExpressionEvaluator<T>) -> StreamingEvaluator<'_, T>
pub fn new(evaluator: &ExpressionEvaluator<T>) -> StreamingEvaluator<'_, T>
Create a streaming evaluator, pre-allocating all buffers.
Sourcepub fn for_each<I, S, F>(&mut self, rows: I, sink: F) -> Result<usize>
pub fn for_each<I, S, F>(&mut self, rows: I, sink: F) -> Result<usize>
Process a stream of input rows, invoking sink with the result
slice for each row.
Each row must contain exactly
param_count values; the
slice passed to sink contains
result_count values and is
only valid for the duration of the callback. Returns the number
of rows processed.
Memory usage is constant: no allocation grows with the number of rows.
§Errors
Returns crate::EvaluationError if a row has the wrong arity
or an arithmetic error occurs during evaluation.
Sourcepub fn evaluate_chunk<S: AsRef<[T]>>(
&mut self,
rows: &[S],
) -> Result<Vec<Vec<T>>>
pub fn evaluate_chunk<S: AsRef<[T]>>( &mut self, rows: &[S], ) -> Result<Vec<Vec<T>>>
Process a chunk of rows and collect all results.
Convenience method for bounded batches; prefer
for_each for unbounded streams.
Returns one result vector per row.
§Errors
Returns crate::EvaluationError if a row has the wrong arity
or an arithmetic error occurs during evaluation.
Auto Trait Implementations§
impl<'a, T> !RefUnwindSafe for StreamingEvaluator<'a, T>
impl<'a, T> !UnwindSafe for StreamingEvaluator<'a, T>
impl<'a, T> Freeze for StreamingEvaluator<'a, T>
impl<'a, T> Send for StreamingEvaluator<'a, T>
impl<'a, T> Sync for StreamingEvaluator<'a, T>where
T: Sync,
impl<'a, T> Unpin for StreamingEvaluator<'a, T>where
T: Unpin,
impl<'a, T> UnsafeUnpin for StreamingEvaluator<'a, T>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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>
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>
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