ddn.columnar.builder

The builder layer of ddn.df: mutable, single-use buffers that seal into immutable ArrayData chunks (D3; ADR-2026-10-18-09).

A builder owns its buffer, appends values and validity bits, and finish() trims over-allocated capacity, seals through ddn.columnar.memory.sealBytes (never the cast-on-call form GDC miscompiles, fact 18) and nulls its slice so no mutable alias survives. Using a builder after finish asserts.

Types 3

Builds a chunk of a physical element type T (the integer and float types; long for the temporal kinds through the dtype parameter of finish).

Fields
private T[] _values
private BitmapBuilder _validity
private size_t _length
private bool _anyNull
private bool _sealed
Methods
size_t length() const @safe pure nothrowReturns: the number of elements appended so far.
void reserve(size_t n) @safe pure nothrowEnsures capacity for at least `n` elements in total.
void append(T value) @safe pure nothrowAppends one value (a valid slot).
void appendNull() @safe pure nothrowAppends one null slot.
void appendRange(const(T)[] values) @safe pure nothrowAppends a range of values.
void appendValues(const(T)[] values) @safe pure nothrowAppends a dense run of valid values in one copy (the bulk path for gather and rebuild kernels).
void appendValues(const(T)[] values, const(ulong)[] validWords) @safe pure nothrowAppends values with packed validity bits, one bit per slot, LSB-first (`ddn.columnar.vector` layout). Values at invalid slots are copied verbatim: null slots hold arbitrary bits (D14).
void appendNulls(size_t n) @safe pure nothrowAppends `n` null slots in one go.
T[] bulkWindow(size_t n) @safe pure nothrowOpens a bulk-transform window (the parallel-kernel producer, amending ADR-2026-10-18-07 alongside `appendRepeated`): reserves `n` slots at the current end and returns them as a writable window, so ...
void commitBulk(size_t n) @safe pure nothrowCommits `n` slots of the open bulk window as all valid (values already written by the caller's window writes).
void commitBulk(size_t n, const(ulong)[] validWords) @safe pure nothrowDitto, with packed validity words (`1` = valid) for the commit's run - byte-identical to `appendValues(values, validWords)` over the same slots.
void appendRange(const(Nullable!T)[] values) @safe pure nothrowAppends a range of optional values; `null` entries append null slots.
ArrayData finish(DataType dtype = DataType(kindOf!T)) @safe pure nothrowSeals the chunk, trimming capacity and producing the dtype of `T` by default. The temporal kinds pass `DataType.DATETIME` or `DataType.TIME` explicitly (the physical storage is `long`).
private void grow() @safe pure nothrow

Builds a BOOLEAN chunk: packed value bits plus validity.

Fields
private BitmapBuilder _bits
private BitmapBuilder _validity
private size_t _length
private bool _anyNull
private bool _sealed
Methods
size_t length() const @safe pure nothrowReturns: the number of elements appended so far.
void reserve(size_t n) @safe pure nothrowEnsures capacity for at least `n` elements in total.
void append(bool value) @safe pure nothrowAppends one value bit.
void appendNull() @safe pure nothrowAppends one null slot.
void appendBits(ulong valueBits, ulong validBits, size_t n) @safe pure nothrowAppends `n` slots from packed words: one value bit and one validity bit per slot, LSB-first. The bits at or above `n` are ignored. This is the bulk path of the packed-bit kernels.
void appendRange(const(bool)[] values) @safe pure nothrowAppends a range of values.
void appendRange(const(Nullable!bool)[] values) @safe pure nothrowAppends a range of optional values; `null` entries append null slots.
ArrayData finish() @safe pure nothrowSeals the chunk, trimming capacity.

Builds a STRING chunk: UTF-8 payload plus long offsets plus validity.

Fields
private long[] _offsets
private ubyte[] _bytes
private BitmapBuilder _validity
private size_t _length
private bool _anyNull
private bool _sealed
Methods
size_t length() const @safe pure nothrowReturns: the number of elements appended so far.
void reserve(size_t bytes, size_t elements) @safe pure nothrowEnsures capacity for at least `n` more bytes and their offsets.
private size_t _bytesUsed() const @safe pure nothrow
void append(scope const(char)[] value) @safe pure nothrowAppends one string (copied into the payload buffer).
void appendNull() @safe pure nothrowAppends one null slot (an empty, invalid payload window).
void appendRepeated(scope const(char)[] value, size_t n) @safe pure nothrowAppends one string `n` times in one bulk pass (the unpivot amending ADR-2026-10-18-07: bulk producers live INSIDE the builder layer so hot paths never hand-assemble chunks). The payload tiles throu...
void appendRange(const(string)[] values) @safe pure nothrowAppends a range of strings.
void appendRange(const(Nullable!string)[] values) @safe pure nothrowAppends a range of optional strings; `null` entries append null slots.
void appendView(const(StringArray) view) @safe pure nothrowAppends every element of a typed STRING view in one pass: the payload of the valid slots is copied in one block and the offsets re-based, null slots become empty invalid windows. This is the bulk p...
ArrayData finish() @safe pure nothrowSeals the chunk, trimming capacity.

Functions 1

private fnbool anyUnset(const(ulong)[] words, size_t n) @safe pure nothrowWhether any of the first `n` packed bits is clear; the bits past `n` in the last word are ignored.

Templates 1

tmplarrayFrom(T)

Builds a one-chunk ArrayData from values, with no nulls.

Parameters

valuesthe column values

Returns

the sealed chunk.