Skip to main content

trim_attr_tail

Function trim_attr_tail 

Source
fn trim_attr_tail(batch: &RecordBatch) -> Result<Cow<'_, RecordBatch>>
Expand description

Write one sealed block’s files into an already-created staging directory.

Split out of publish only so that the failure of any step in it has one place to be cleaned up from. Drop an attribute table’s trailing all-null value columns before it is written.

crate::schema::ATTRS carries a column per AnyValue variant and a row fills exactly one of them, so the other five are null down the whole block. Arrow IPC does not elide those: an all-null Binary column still writes a full offsets buffer and its validity bitmap, 4.125 bytes a row, and a corpus of ordinary string attributes spends 8.25 of its 36.26 bytes a row on the two that are almost never used — bytes holds BytesValue and ser holds slices and maps, and most telemetry emits neither.

Only a suffix is dropped, and only ever down to ATTR_UNGUARDED_COLS. That is the whole reason this costs no reader a line: every surviving column keeps the position the read path indexes it by, which is part of the on-disk format (see the field order note above FORMAT_VERSION), and the two columns that can go are the only ones no reader touches unconditionally.

Here rather than in the builder or in Sealed::with on purpose: the bloom filter and the zone map select attribute tables with Arc::ptr_eq(&schema, &ATTRS), so a projection upstream would silently leave them out of both indexes — and a key missing from the zone map reads as this block has no such value, which prunes blocks that do hold matches. By the time stage runs, both sidecars are built.

Not a format break, and no FORMAT_VERSION bump: the reader already has to treat an absent table as empty, because that is how a block written before a table existed reads back, and a short attribute table is the same tolerance one column at a time. Nothing else is trimmed — another table’s trailing column may carry meaning this cannot see.