pub struct TableBuilder { /* private fields */ }Expand description
Generic columnar table builder. Implements ColumnarSink so any decoder
can feed it field/value events; at the end it produces an Arrow
RecordBatch.
Implementations§
Source§impl TableBuilder
impl TableBuilder
pub fn new() -> Self
pub fn with_capacity(cap: usize) -> Self
pub fn with_plan(cap: usize, plan: Arc<ExecutionPlan>) -> Self
Sourcepub fn ensure_schema(&mut self, schema: &FrozenSchema) -> Result<()>
pub fn ensure_schema(&mut self, schema: &FrozenSchema) -> Result<()>
Pre-size all columns from a FrozenSchema.
Called by parallel streaming workers so that every chunk’s
TableBuilder has the full column set from construction,
regardless of which fields appear in that chunk.
pub fn num_rows(&self) -> usize
pub fn num_columns(&self) -> usize
pub fn column_names(&self) -> &[String]
Sourcepub fn column_diagnostics(&self) -> Vec<(String, usize, usize)>
pub fn column_diagnostics(&self) -> Vec<(String, usize, usize)>
Diagnostic: (name, bytes_used, bytes_capacity) for each column.
Sourcepub fn estimated_rows(&self) -> usize
pub fn estimated_rows(&self) -> usize
The estimated_rows capacity hint passed to with_plan.
Sourcepub fn finish(&mut self) -> Result<RecordBatch>
pub fn finish(&mut self) -> Result<RecordBatch>
Finalize the builder into an Arrow RecordBatch.
This is also available as the ColumnarSink::finish trait method.
Sourcepub fn normalize(&mut self)
pub fn normalize(&mut self)
Truncate every column back to row_count, dropping any partial-row
values from a mid-field EOF. Idempotent.
Sourcepub fn auto_dict_upgrade(&mut self)
pub fn auto_dict_upgrade(&mut self)
If auto_dict is set, upgrade low-cardinality string columns using the
plan’s threshold/max-size tuning (defaults: 5% ratio, max size 256).
Sourcepub fn sort_columns(&mut self)
pub fn sort_columns(&mut self)
Sort columns according to schema_order. Columns named in
schema_order appear in that order; any other columns keep their
relative first-appearance order after the ordered ones.
Source§impl TableBuilder
impl TableBuilder
Sourcepub fn extend(&mut self, other: TableBuilder) -> Result<()>
pub fn extend(&mut self, other: TableBuilder) -> Result<()>
Merge another builder’s data into this one, consuming other.
New columns discovered in other are null-padded for the existing rows
in self. Columns present in self but absent from other are
null-padded for other’s rows. Column order follows first-appearance
order across both builders.
Columns that disagree on storage variant are reconciled with safe
promotions (int64→float64, string→dictionary); irreconcilable
conflicts return crate::Error::Merge.
Trait Implementations§
Source§impl ColumnarSink for TableBuilder
impl ColumnarSink for TableBuilder
Source§fn put_field_at(&mut self, slot: u32, value: Value<'_>)
fn put_field_at(&mut self, slot: u32, value: Value<'_>)
Push a value directly to a known slot index, bypassing all name
resolution and hash lookups. Used by adapters that verified the
field identity via expect_slot + memcmp on raw bytes.
fn begin_row(&mut self)
fn put_field(&mut self, name: &str, value: Value<'_>)
fn end_row(&mut self)
Source§fn wants(&self, name: &str) -> bool
fn wants(&self, name: &str) -> bool
false to signal that the engine will drop this field.Source§fn resolve<'a>(&'a self, name: &'a str) -> Option<&'a str>
fn resolve<'a>(&'a self, name: &'a str) -> Option<&'a str>
None if dropped.
Default keeps the name as-is. Adapters that do expensive extraction can
call this once and then put_field_resolved to avoid a second
resolve_field inside put_field.Source§fn put_field_resolved(&mut self, resolved_name: &str, value: Value<'_>)
fn put_field_resolved(&mut self, resolved_name: &str, value: Value<'_>)
resolve.
Default delegates to put_field (which will resolve again). Overrides
should bypass the rename/drop lookup.Source§fn resolve_and_put(&mut self, name: &str, value: Value<'_>)
fn resolve_and_put(&mut self, name: &str, value: Value<'_>)
resolve_field that wants + put_field would perform.
Default: resolve then put_field_resolved (with owned clone to satisfy
the borrow checker). Overrides should avoid the allocation.Source§fn row_rejected(&self) -> bool
fn row_rejected(&self) -> bool
Fail, the scanner can byte-jump to
</Details> without further field scanning. Default false.Source§fn row_satisfied(&self) -> bool
fn row_satisfied(&self) -> bool
row_rejected (a row can
be satisfied OR rejected, both short-circuit). Read moreSource§fn wanted_mask(&self) -> u64
fn wanted_mask(&self) -> u64
i is set iff
column i is in the output schema. The adapter can test membership
with (wanted_mask >> slot) & 1 == 1 instead of a virtual call per
field. Returns empty mask (all zeros) when no projection is active.Source§fn finish(&mut self) -> Result<RecordBatch>
fn finish(&mut self) -> Result<RecordBatch>
RecordBatch.Source§fn expect_slot(&self, ordinal: u32) -> Option<(u32, &[u8])>
fn expect_slot(&self, ordinal: u32) -> Option<(u32, &[u8])>
Source§fn record_slot(&mut self, ordinal: u32, slot: u32, raw_name: &[u8])
fn record_slot(&mut self, ordinal: u32, slot: u32, raw_name: &[u8])
ordinal so the engine
can cache it for subsequent rows. Called after the adapter resolves
a field via the generic path (wants + resolve + put_field_resolved).Source§fn layout_broken(&mut self, ordinal: u32)
fn layout_broken(&mut self, ordinal: u32)
ordinal did not match.
The engine should invalidate its cached expectation and fall back to
generic resolution for subsequent rows.Source§fn reset_child_ordinal(&mut self)
fn reset_child_ordinal(&mut self)
Source§fn resolve_raw<'a>(&'a self, raw_name: &'a [u8]) -> Option<&'a str>
fn resolve_raw<'a>(&'a self, raw_name: &'a [u8]) -> Option<&'a str>
String.Source§fn resolve_and_put_raw(&mut self, raw_name: &[u8], value: Value<'_>)
fn resolve_and_put_raw(&mut self, raw_name: &[u8], value: Value<'_>)
Source§fn needs_value(&self) -> bool
fn needs_value(&self) -> bool
Auto Trait Implementations§
impl Freeze for TableBuilder
impl RefUnwindSafe for TableBuilder
impl Send for TableBuilder
impl Sync for TableBuilder
impl Unpin for TableBuilder
impl UnsafeUnpin for TableBuilder
impl UnwindSafe for TableBuilder
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
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> ⓘ
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 more