Skip to main content

HanaBatchProcessor

Struct HanaBatchProcessor 

Source
pub struct HanaBatchProcessor { /* private fields */ }
Expand description

Processor that converts HANA rows into Arrow RecordBatches.

Buffers rows until batch_size is reached, then emits a RecordBatch. Implements the BatchProcessor trait with GAT support.

§Example

use hdbconnect_arrow::conversion::HanaBatchProcessor;
use hdbconnect_arrow::traits::streaming::BatchConfig;

let schema = /* Arrow schema */;
let config = BatchConfig::with_batch_size(10000);
let mut processor = HanaBatchProcessor::new(Arc::new(schema), config);

for row in result_set {
    if let Some(batch) = processor.process_row(row)? {
        // Process batch
    }
}

// Don't forget to flush remaining rows
if let Some(batch) = processor.flush()? {
    // Process final batch
}

Implementations§

Source§

impl HanaBatchProcessor

Source

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

Create a new batch processor.

§Arguments
  • schema - Arrow schema for the batches
  • config - Batch processing configuration
Source

pub fn with_defaults(schema: SchemaRef) -> Self

Create with default configuration.

Source

pub fn process_row(&mut self, row: &Row) -> Result<Option<RecordBatch>>

Process a single row.

Returns Ok(Some(batch)) when a batch is ready, Ok(None) when more rows are needed to fill a batch.

§Errors

Returns error if value conversion fails or schema mismatches.

Source

pub fn process_row_generic<R: RowLike>( &mut self, row: &R, ) -> Result<Option<RecordBatch>>

Process a single row using the generic RowLike trait.

This method enables unit testing with MockRow instead of requiring a HANA connection.

Returns Ok(Some(batch)) when a batch is ready, Ok(None) when more rows are needed to fill a batch.

§Errors

Returns error if value conversion fails or schema mismatches.

§Example
use hdbconnect_arrow::traits::row::{MockRow, MockRowBuilder};

let row = MockRowBuilder::new().int(42).string("test").build();
let result = processor.process_row_generic(&row)?;
Source

pub fn flush(&mut self) -> Result<Option<RecordBatch>>

Flush any remaining rows as a final batch.

§Errors

Returns error if RecordBatch creation fails.

Source

pub fn schema(&self) -> SchemaRef

Returns the schema of batches produced by this processor.

Source

pub const fn buffered_rows(&self) -> usize

Returns the current row count in the buffer.

Trait Implementations§

Source§

impl Debug for HanaBatchProcessor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V