Skip to main content

Module chunk

Module chunk 

Source
Expand description

ColumnChunk: differential’s Chunk over Column-shaped updates.

A chunk is a sorted, consolidated run of (D, T, R) updates in the flat columnar layout, in one of two homes:

  • Resident: an Rc-shared Column on the heap. Fresh input, merge output, and small tails live here.
  • Spilled: the serialized body in the process Pool, with the record count and the first and last data items resident. The pool owns residency from there, with slots under a memory budget and compression and device pageout under pressure, and a body that dies before pressure reaches it is freed without I/O.

Reads of a spilled body are copy-out and scoped to the call that needs them: the body is read into caller-owned memory and no reference into pool memory ever exists outside the pool. That contract is what lets the pool evict with no reader accounting at all.

Spilling happens in Chunk::settle, the trait’s designated commit point: chunks moved to settled output are handed to the pool when spilling is enabled (see set_compute_spill_enabled and set_storage_spill_enabled). The spill destination resolves per commit from three pieces of mutable state. A thread-local pool override, for tests and benches, wins outright. Otherwise the compute and storage gates, composed as an OR, route commits to the process pool installed by crate::pool_config, and with no pool installed chunks stay resident. A second thread-local holds the reusable scratch that call-scoped reads of spilled bodies copy into. Grading is by serialized bytes, the ship size Column already targets, rather than by the record-count TARGET, since record count does not bound bytes for variable-width data.

Chunks whose data is a (key, val) pair additionally implement UnloadChunk, the bulk-read capability: sorted probe keys in, matching updates appended to caller-owned staging, with locate answered from the resident fence metadata so a probe set faults only the chunk bodies it actually touches.

Structs§

ChunkChunker
A chunker for arrange_core over ColumnChunks: sorts and consolidates raw input columns through a ColumnChunker and wraps its output chunks.
Lz4Codec
The chunk-side ExtentCodec: a little-endian u32 body-length prefix followed by one lz4 block, the framing lz4_flex::block::compress_prepend_size produces. Every chunk consumer passes LZ4_CODEC at insert; the pool itself has no codec opinion.
SpilledBody
A spilled chunk body: the serialized column in the pool, plus the resident metadata every Chunk must answer without fetching. That metadata is the record count and the first and last data items (the fence entries UnloadChunk::locate consults).
UnchunkBuilder
A batch builder over ColumnChunk input that delegates to a builder over Column input, loading each chunk’s body as it is pushed.

Enums§

ColumnChunk
A sorted, consolidated run of (D, T, R) updates, resident or spilled.

Statics§

LZ4_CODEC
The Lz4Codec instance chunk consumers pass to Pool::insert_with.

Functions§

set_compute_spill_enabled
Enable or disable chunk spilling on behalf of compute’s arrangement batchers.
set_spill_override
Set or unset the pool through which this thread’s chunk spills are routed, taking precedence over the gates and the process pool. None restores the global resolution.
set_storage_spill_enabled
Enable or disable chunk spilling on behalf of storage’s upsert dataflows.