Skip to main content

Module table_view

Module table_view 

Source
Expand description

§TableV Module - Windowed View over a Table

TableV is a row-aligned, zero-copy view over a Table, holding the window [offset .. offset+len) across all columns.

§Purpose

  • Stream or batch rows without copying full columns.
  • Do per-partition / per-window work with stable schema metadata (Fields).
  • Glue for chunked processing alongside SuperTableV and ArrayV, but focused on windowed zero-copy access within a single Table batch.

§Behaviour

  • Columns are exposed as ArrayV windows with the same (offset, len).
  • Schema (Fields) is retained and shared; column data is not copied.
  • Slicing a TableV (from_self) is O(1) - metadata-only.
  • to_table() materialises an owned Table copy of the window.

§When to use

  • Sliding windows, micro-batching, streaming sinks/sources.
  • Thread-local views where each worker consumes a row range.
  • Building higher-level chunked tables (SuperTableV) from base tables.

§Example

use minarrow::{Table, TableV, fa_i32};
use minarrow::ColumnSelection;  // Re-exported at crate root
use std::sync::Arc;

// Build a simple 2-column table
let a = fa_i32!("a", 1, 2, 3, 4, 5);
let b = fa_i32!("b", 10, 20, 30, 40, 50);
let mut tbl = Table::new("T".to_string(), vec![a,b].into());

// View rows 1..4 (3 rows total)
let tv = TableV::from_table(tbl, 1, 3);
assert_eq!(tv.n_rows(), 3);
assert_eq!(tv.n_cols(), 2);
// Access a column window via ColumnSelection trait
let col0 = tv.col_ix(0).unwrap();
assert_eq!(col0.get::<minarrow::IntegerArray<i32>>(0), Some(2));

// Materialise the window as an owned Table copy
let owned = tv.to_table();
assert_eq!(owned.n_rows, 3);

Structs§

TableV
TableView