Expand description
Sorted, consolidated runs of updates, and operators over sequences of them.
A Chunk is a consolidated, sorted run of (data, time, diff) updates.
A sequence of chunks is also expected to be consolidated and sorted.
The Chunk trait exposes whole-chunk operations, so that the implementor
can internally divert to their best implementations, with amortized overhead.
Each operation is invoked as if “streaming”, providing input and output queues.
An implementor is expected to drain as much as possible of the inputs, and any
chunk written to the output is “committed” and likely to be shipped onward.
§Wiring a Chunk into an arrangement
Implementing Chunk for a type C is the only bespoke code needed; three
aliases then expand into a full trace:
ChunkBatcher<C>— the merge batcher.ChunkBuilder<C>— the batch builder.ChunkSpine<C>— the trace, a spine ofRc-shared batches.
These are the Batcher / Builder / Spine to hand to
arrange_core, along with a
chunker that forms C from the input stream — typically
ContainerChunker<C>.
Trace maintenance needs only Chunk; cursor-driven consumption of the
arrangement additionally asks C for the NavigableChunk capability.
Everything else here (ChunkBatch, ChunkMerger, ChunkBatchMerger,
ChunkBatchCursor, ChunkBatchBuilder) is machinery those aliases expand to and is
not named directly. The vec module is a worked Chunk
that re-exports the three aliases specialized to its layout, and the chunks example
stands one up.
§Bounded footprint
There is a TARGET associated constant that signals the intended chunk size.
The constant should be chosen large enough to amortize overheads, but small
enough that per-chunk work does not “stall” the system when invoked.
The implementor is trusted to make a reasonable choice here.
The Chunk::settle method “settles” sequences of chunks, and is called as
chunks are no longer expected to be needed in the near future. The implementor
should ensure the chunks are “graded”, in that the sequence of chunks are all
at most TARGET in size, any two in order sum to strictly more than TARGET.
This is also an opportunity to compress data, or spill to disk or cloud storage.
The active (un-settled) chunk set is kept small from both sides. Every producer
settles its committed output as it goes (see Chunk::settle), rather than
building a whole sequence and settling at the end. And every walk over a whole
chunk sequence reads only resident metadata — len and
bounds — never a chunk body: the straddle cursor
seeks by galloping the chunks’ bounds from a hint and opens only the chunk(s) a
query touches. Implementors must therefore keep len and bounds cheap even
when a chunk’s body is paged out.
Modules§
Structs§
- Chunk
Batch - A batch is a
Chunksequence plus aDescription. - Chunk
Batch Builder - A
Builderthat collects a chunk sequence into aChunkBatch. - Chunk
Batch Cursor - A cursor over a
ChunkBatch, merging the per-chunk cursors. - Chunk
Batch Merger - The resumable
Batch::MergerforChunkBatch: merges two batches and advances their times to the compaction frontier, a fuel-bounded step at a time. - Chunk
Merger - A merge-batcher
Mergerover chains ofChunks.
Traits§
- Chunk
- A non-empty, bounded, consolidated, sorted sequence of
(data, time, diff). - Navigable
Chunk - The navigation capability: a
Chunkwhose contents can be read by cursor.
Functions§
- is_
graded - Whether
chunkssatisfy theChunk::TARGETgrading invariant: every chunk at mostTARGET, and every adjacent pair summing to more thanTARGET(so no two neighbours could be combined into one legal chunk — a maximal packing). - merge_
chains - Merge two full chains of chunks into one, to completion, appending to
out. - pack
- Maximal-packing driver an implementor’s
Chunk::settlemay delegate to. - settle_
all - Settle
inputto completion into a fresh gradedVec(seeChunk::settle).
Type Aliases§
- Chunk
Batcher - A merge-batcher
Mergerover chains ofChunks. - Chunk
Builder - A reference-counted
ChunkBatchbuilder over chunks of typeC. - Chunk
Spine - A spine of
Rc-sharedChunkBatches of typeC: the trace type forarrange.