pub enum DatasetAdapter {
InMemory(InMemoryAdapter),
Streaming(StreamingAdapter),
}Expand description
Adapter providing uniform access to Arrow datasets for TUI rendering
Supports two modes:
InMemory: All batches loaded upfront, fast random accessStreaming: Lazy batch loading for large datasets (OOM prevention)
§Example
ⓘ
use alimentar::tui::DatasetAdapter;
use alimentar::ArrowDataset;
let dataset = ArrowDataset::from_parquet("data.parquet")?;
let adapter = DatasetAdapter::from_dataset(&dataset)?;
println!("Rows: {}", adapter.row_count());
println!("Columns: {}", adapter.column_count());
if let Some(value) = adapter.get_cell(0, 0)? {
println!("First cell: {}", value);
}Variants§
InMemory(InMemoryAdapter)
All batches loaded in memory - fast random access
Streaming(StreamingAdapter)
Lazy batch loading for large datasets
Implementations§
Source§impl DatasetAdapter
impl DatasetAdapter
Sourcepub fn from_dataset(dataset: &ArrowDataset) -> TuiResult<Self>
pub fn from_dataset(dataset: &ArrowDataset) -> TuiResult<Self>
Sourcepub fn from_batches(
batches: Vec<RecordBatch>,
schema: SchemaRef,
) -> TuiResult<Self>
pub fn from_batches( batches: Vec<RecordBatch>, schema: SchemaRef, ) -> TuiResult<Self>
Create in-memory adapter from record batches and schema
Sourcepub fn in_memory_from_batches(
batches: Vec<RecordBatch>,
schema: SchemaRef,
) -> TuiResult<Self>
pub fn in_memory_from_batches( batches: Vec<RecordBatch>, schema: SchemaRef, ) -> TuiResult<Self>
Create in-memory adapter explicitly
Sourcepub fn streaming_from_batches(
batches: Vec<RecordBatch>,
schema: SchemaRef,
) -> TuiResult<Self>
pub fn streaming_from_batches( batches: Vec<RecordBatch>, schema: SchemaRef, ) -> TuiResult<Self>
Create streaming adapter explicitly
Sourcepub fn column_count(&self) -> usize
pub fn column_count(&self) -> usize
Get the column count
Sourcepub fn is_streaming(&self) -> bool
pub fn is_streaming(&self) -> bool
Check if this adapter is in streaming mode
Sourcepub fn get_cell(&self, row: usize, col: usize) -> TuiResult<Option<String>>
pub fn get_cell(&self, row: usize, col: usize) -> TuiResult<Option<String>>
Get a cell value as a formatted string
Sourcepub fn field_name(&self, col: usize) -> Option<&str>
pub fn field_name(&self, col: usize) -> Option<&str>
Get a field name by column index
Sourcepub fn field_type(&self, col: usize) -> Option<String>
pub fn field_type(&self, col: usize) -> Option<String>
Get a field data type description by column index
Sourcepub fn field_nullable(&self, col: usize) -> Option<bool>
pub fn field_nullable(&self, col: usize) -> Option<bool>
Check if a field is nullable
Sourcepub fn calculate_column_widths(
&self,
max_width: u16,
sample_rows: usize,
) -> Vec<u16>
pub fn calculate_column_widths( &self, max_width: u16, sample_rows: usize, ) -> Vec<u16>
Calculate optimal column widths for display
Uses unicode-width for correct visual width calculation.
Sourcepub fn field_names(&self) -> Vec<&str>
pub fn field_names(&self) -> Vec<&str>
Get all field names as a vector
Sourcepub fn locate_row(&self, global_row: usize) -> Option<(usize, usize)>
pub fn locate_row(&self, global_row: usize) -> Option<(usize, usize)>
Locate a row within the batch structure
Trait Implementations§
Source§impl Clone for DatasetAdapter
impl Clone for DatasetAdapter
Source§fn clone(&self) -> DatasetAdapter
fn clone(&self) -> DatasetAdapter
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for DatasetAdapter
impl !RefUnwindSafe for DatasetAdapter
impl Send for DatasetAdapter
impl Sync for DatasetAdapter
impl Unpin for DatasetAdapter
impl UnsafeUnpin for DatasetAdapter
impl !UnwindSafe for DatasetAdapter
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.