tonbo 0.4.0-a1

Embedded database for serverless and edge runtimes, storing data as Parquet on S3
Documentation
//! Arrow `RecordBatch` key extraction into zero-copy key views.
//!
//! These APIs are Tonbo-specific shims that turn Arrow batches into the
//! zero-copy key views defined under [`crate::key`]. The compile-time typed
//! record support that previously lived here has been removed; keeping the module
//! focused on extraction keeps the ingest path clear.

mod errors;
mod extractors;

use arrow_array::RecordBatch;
use arrow_schema::SchemaRef;
pub use errors::KeyExtractError;
pub(crate) use extractors::{
    map_view_err, projection_for_columns, projection_for_field, row_from_batch,
};

use crate::key::KeyRow;

/// Schema-validated projection that can materialise logical keys from record batches.
pub trait KeyProjection: Send + Sync {
    /// Ensure the projection is compatible with `schema`.
    fn validate_schema(&self, schema: &SchemaRef) -> Result<(), KeyExtractError>;

    /// Schema describing just the key columns (no MVCC sidecars).
    fn key_schema(&self) -> SchemaRef;

    /// Column indices (in schema order) that form the key projection.
    fn key_indices(&self) -> &[usize];

    /// Project borrowed key views for the requested `rows` (in order) from `batch`.
    fn project_view(
        &self,
        batch: &RecordBatch,
        rows: &[usize],
    ) -> Result<Vec<KeyRow>, KeyExtractError>;
}