Skip to main content

BatchProcessor

Trait BatchProcessor 

Source
pub trait BatchProcessor {
    type Config;
    type Error: Error;
    type Batch<'a>
       where Self: 'a;

    // Required methods
    fn new(config: Self::Config, schema: SchemaRef) -> Self;
    fn process<'a>(
        &'a mut self,
        rows: &[Row],
    ) -> Result<Self::Batch<'a>, Self::Error>;
    fn flush(&mut self) -> Result<Option<RecordBatch>, Self::Error>;
}
Expand description

A batch processor that transforms input rows into Arrow RecordBatches.

Uses GATs to allow flexible lifetime relationships between the processor and the batches it produces.

Required Associated Types§

Source

type Config

Configuration type for this processor.

Source

type Error: Error

Error type produced by this processor.

Source

type Batch<'a> where Self: 'a

The batch type produced, which may borrow from the processor.

Required Methods§

Source

fn new(config: Self::Config, schema: SchemaRef) -> Self

Create a new processor with the given configuration.

Source

fn process<'a>( &'a mut self, rows: &[Row], ) -> Result<Self::Batch<'a>, Self::Error>

Process a chunk of rows into a batch.

§Errors

Returns an error if processing fails.

Source

fn flush(&mut self) -> Result<Option<RecordBatch>, Self::Error>

Flush any buffered data and return the final batch.

§Errors

Returns an error if flushing fails.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§