Skip to main content

BatchSource

Trait BatchSource 

Source
pub trait BatchSource: Send {
    // Required methods
    fn receive_batch<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = SourceResult<Vec<RecordBatch>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn identifier(&self) -> &str;

    // Provided methods
    fn start<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = SourceResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn close<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = SourceResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

A batch-oriented data source that produces Arrow RecordBatches.

§Lifecycle

  1. start() — initialize (connect, subscribe, bind)
  2. receive_batch() — pull data in a loop
  3. close() — release resources (unsubscribe, close connections)

close() must be idempotent — safe to call multiple times, even before start().

§Empty vs EOF

  • Return Ok(vec![]) when no data is currently available (caller should retry).
  • Return Err(SourceReason::EOF.into()) when the stream has ended.

Required Methods§

Source

fn receive_batch<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = SourceResult<Vec<RecordBatch>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Receive zero or more RecordBatches.

An empty Vec means “no data right now” — the caller should poll again. An error with SourceReason::EOF means the stream has ended.

Source

fn identifier(&self) -> &str

Unique identifier for this source instance (logging / metrics).

Provided Methods§

Source

fn start<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = SourceResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Initialize the source. Called once before the first receive_batch().

Default is a no-op.

Source

fn close<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = SourceResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Close the source and release all resources.

Must be idempotent — safe to call multiple times or before start(). Default is a no-op.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§