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
impl HanaBatchProcessor
Sourcepub fn new(schema: SchemaRef, config: BatchConfig) -> Self
pub fn new(schema: SchemaRef, config: BatchConfig) -> Self
Create a new batch processor.
§Arguments
schema- Arrow schema for the batchesconfig- Batch processing configuration
Sourcepub fn with_defaults(schema: SchemaRef) -> Self
pub fn with_defaults(schema: SchemaRef) -> Self
Create with default configuration.
Sourcepub fn process_row(&mut self, row: &Row) -> Result<Option<RecordBatch>>
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.
Sourcepub fn flush(&mut self) -> Result<Option<RecordBatch>>
pub fn flush(&mut self) -> Result<Option<RecordBatch>>
Sourcepub const fn buffered_rows(&self) -> usize
pub const fn buffered_rows(&self) -> usize
Returns the current row count in the buffer.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for HanaBatchProcessor
impl !RefUnwindSafe for HanaBatchProcessor
impl Send for HanaBatchProcessor
impl !Sync for HanaBatchProcessor
impl Unpin for HanaBatchProcessor
impl !UnwindSafe for HanaBatchProcessor
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
Mutably borrows from an owned value. Read more