Expand description
A ContainerBuilder that consolidates (D, T, R) updates and emits columnar containers.
Two-level buffering:
- AoS staging
Vec<(D, T, R)>with a small cap soconsolidate_updatesโn log ncost stays bounded. Cancellations and same-key updates collapse here before reaching the column-shaped storage. A drain-multiple-of-half-cap trick keeps the leftover in staging, so cross-batch keys with the same(D, T)continue consolidating on the next sort. - SoA accumulator: one sub-container per column (
D::Container,T::Container,R::Container). Drains push in fixed-size chunks (DRAIN_CHUNK_ROWS) with three sequential per-column passes per chunk, so the inner pushes autovectorize. After each chunk, check the serialized size; once the accumulator reaches the flush threshold (90% ofOUTPUT_TARGET_WORDS), serialize into an alignedVec<u64>(no zero-fill โ written byindexed::encode) and ship asColumn::Align. Per-chunk granularity bounds overshoot toK * row_words. The trailing partial onfinishships asColumn::Typed.
Generic over (D, T, R): Columnar via the columnar tuple decomposition
<(D, T, R) as Columnar>::Container = (D::Container, T::Container, R::Container).
Structsยง
- Consolidating
Column Builder - A container builder that consolidates
(D, T, R)updates and emitsColumn<(D, T, R)>.
Constantsยง
- DRAIN_
CHUNK_ ๐ROWS - Drain rows from staging in chunks of this size. Inside each chunk we do three sequential
per-column passes โ long enough for autovectorization (4โ8 vector iterations on NEON / SVE2
128-bit / AVX2 / SVE 256-bit) โ while the outer per-chunk size check bounds overshoot to
K * row_words. With a 1 KiB row (128 words) and K=16, worst-case overshoot is 2 KiB, well under the 10% slop budget on a 2 MiB target. - FLUSH_
THRESHOLD_ ๐WORDS - Flush when within 10% of
OUTPUT_TARGET_WORDSโ matchesColumnBuilderโs slop heuristic. Computed at compile time so the hot loop is a singlecmp/jaeinstead of a per-row round-up + divide-by-10. - OUTPUT_
TARGET_ ๐WORDS - Target serialized chunk size in u64 words (2 MiB). Bounded slop matters once we put these behind huge pages.
- STAGING_
BUFFER_ ๐BYTES - Per-buffer byte budget for the staging cap. Matches the 8 KiB basis DDโs
ConsolidatingContainerBuilderuses viatimely::container::buffer::default_capacity.
Functionsยง
- default_
staging_ ๐cap - Default items per staging buffer:
2 * STAGING_BUFFER_BYTES / size_of::<(D, T, R)>(), matching DDโsConsolidatingContainerBuilder. Small enough that O(n log n) sort stays cheap, large enough to amortize the sort + drain overhead across many pushes.