AsViewsIterator

Trait AsViewsIterator 

Source
pub trait AsViewsIterator {
    // Required method
    fn iter_views<T: FromRecordBatch>(
        &self,
    ) -> Result<T::Views<'_>, SchemaError>;
}
Expand description

Extension trait for creating typed view iterators from RecordBatch.

Required Methods§

Source

fn iter_views<T: FromRecordBatch>(&self) -> Result<T::Views<'_>, SchemaError>

Iterate over typed views of rows in this RecordBatch.

This provides zero-copy access to the data as borrowed references.

§Errors

Returns SchemaError if the RecordBatch schema doesn’t match the expected Record type.

§Example
use typed_arrow::prelude::*;

#[derive(Record)]
struct Row {
    id: i32,
    name: String,
}

// Build a RecordBatch
let rows = vec![
    Row {
        id: 1,
        name: "Alice".to_string(),
    },
    Row {
        id: 2,
        name: "Bob".to_string(),
    },
];
let mut b = <Row as BuildRows>::new_builders(rows.len());
b.append_rows(rows);
let arrays = b.finish();
let batch = arrays.into_record_batch();

// Iterate with zero-copy views (using convenience method to handle errors)
let views = batch.iter_views::<Row>()?.try_flatten()?;
for row in views {
    println!("{}: {}", row.id, row.name);
}

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.

Implementations on Foreign Types§

Source§

impl AsViewsIterator for RecordBatch

Available on crate feature views only.

Implementors§