Class ColumnBatch
One aligned slice of a file's columns. Every column in a batch must have the same number of values, which is the batch's row count.
A batch is not constructed directly: ColumnWriter.writeBatch(Consumer) creates it, bound
to the schema, hands it to a filler that populates the columns, then submits it — so
there is no separate build or submit step to forget. Columns are addressed by index or
by name, and the schema binding lets every identifier be validated as it is added — an
unknown name, an out-of-range index, a column of the wrong physical type, or setting the same column
twice (whether by index or name) all fail eagerly rather than at write time.
The values are checked as eagerly. A value outside the range its column's annotation
declares — 300 on a UINT_8 column, an unscaled value of more digits than a DECIMAL's
precision — is rejected where it is handed over, because writing it produces a file whose
values fall outside the range its own annotation declares. The values at rows a column's
Validity marks null are never encoded, and so are never checked.
columns.writeBatch(b -> b
.ints(0, idColumn)
.ints("value", valueColumn));
An OPTIONAL column carries its nulls as a Validity alongside its values. The values
array is full length — one slot per row — and the entry at a null row is ignored. The
Validity uses the null-centric polarity the reader exposes (Validity#isNull), so a
value read back as null is written by marking that row null. Because Validity is an
interface, the caller picks the representation through its factory: Validity.NO_NULLS
for none, Validity.ofNulls(boolean[]) to bridge a plain boolean[] mask, Validity.of(long[]) for a
packed present-bitmap — and, in the future, a sparse form — all consumed identically by
the writer.
columns.writeBatch(b -> b
.ints(0, idColumn)
.ints("value", valueColumn, valueNulls)); // boolean[] nulls, true = null
The [#ints(int, int[], boolean[])] overload is convenience sugar over
Validity.ofNulls(boolean[]). The mask-less [#ints(int, int[])] setter is the all-present form for
both REQUIRED and OPTIONAL columns; a null mask is only accepted for an OPTIONAL
column.
-
Method Summary
Modifier and TypeMethodDescriptionbooleans(int columnIndex, boolean[] values) Adds the values for aREQUIRED BOOLEANcolumn, addressed by index.booleans(int columnIndex, boolean[] values, boolean[] nulls) Adds the values for anOPTIONAL BOOLEANcolumn, addressed by index, with a plain mask.Adds the values for anOPTIONAL BOOLEANcolumn, addressed by index.Adds the values for aREQUIRED BOOLEANcolumn, addressed by name.Adds the values for anOPTIONAL BOOLEANcolumn, addressed by name, with a plain mask.Adds the values for anOPTIONAL BOOLEANcolumn, addressed by name.bytes(int columnIndex, byte[][] values) Adds the values for aREQUIRED BYTE_ARRAYcolumn, addressed by index.bytes(int columnIndex, byte[][] values, boolean[] nulls) Adds the values for anOPTIONAL BYTE_ARRAYcolumn, addressed by index, with a plain mask.Adds the values for anOPTIONAL BYTE_ARRAYcolumn, addressed by index.Adds the values for aREQUIRED BYTE_ARRAYcolumn, addressed by name.Adds the values for anOPTIONAL BYTE_ARRAYcolumn, addressed by name, with a plain mask.Adds the values for anOPTIONAL BYTE_ARRAYcolumn, addressed by name.doubles(int columnIndex, double[] values) Adds the values for aREQUIRED DOUBLEcolumn, addressed by index.doubles(int columnIndex, double[] values, boolean[] nulls) Adds the values for anOPTIONAL DOUBLEcolumn, addressed by index, with a plain mask.Adds the values for anOPTIONAL DOUBLEcolumn, addressed by index.Adds the values for aREQUIRED DOUBLEcolumn, addressed by name.Adds the values for anOPTIONAL DOUBLEcolumn, addressed by name, with a plain mask.Adds the values for anOPTIONAL DOUBLEcolumn, addressed by name.fixed(int columnIndex, byte[][] values) Adds the values for aREQUIRED FIXED_LEN_BYTE_ARRAYcolumn, addressed by index.fixed(int columnIndex, byte[][] values, boolean[] nulls) Adds the values for anOPTIONAL FIXED_LEN_BYTE_ARRAYcolumn, addressed by index, with a plain mask.Adds the values for anOPTIONAL FIXED_LEN_BYTE_ARRAYcolumn, addressed by index.Adds the values for aREQUIRED FIXED_LEN_BYTE_ARRAYcolumn, addressed by name.Adds the values for anOPTIONAL FIXED_LEN_BYTE_ARRAYcolumn, addressed by name, with a plain mask.Adds the values for anOPTIONAL FIXED_LEN_BYTE_ARRAYcolumn, addressed by name.floats(int columnIndex, float[] values) Adds the values for aREQUIRED FLOATcolumn, addressed by index.floats(int columnIndex, float[] values, boolean[] nulls) Adds the values for anOPTIONAL FLOATcolumn, addressed by index, with a plain mask.Adds the values for anOPTIONAL FLOATcolumn, addressed by index.Adds the values for aREQUIRED FLOATcolumn, addressed by name.Adds the values for anOPTIONAL FLOATcolumn, addressed by name, with a plain mask.Adds the values for anOPTIONAL FLOATcolumn, addressed by name.ints(int columnIndex, int[] values) Adds the values for aREQUIRED INT32column, addressed by index.ints(int columnIndex, int[] values, boolean[] nulls) Adds the values for anOPTIONAL INT32column, addressed by index, with nulls given as a plain mask.Adds the values for anOPTIONAL INT32column, addressed by index.Adds the values for aREQUIRED INT32column, addressed by name.Adds the values for anOPTIONAL INT32column, addressed by name, with nulls given as a plain mask.Adds the values for anOPTIONAL INT32column, addressed by name.Sets the entry offsets of aLIST, addressed by the list group's dot-separated path.Sets the entry offsets of aLISTtogether with its per-instance nulls (which lists are themselves absent), distinct from an empty list carrying a zero-delta offset.longs(int columnIndex, long[] values) Adds the values for aREQUIRED INT64column, addressed by index.longs(int columnIndex, long[] values, boolean[] nulls) Adds the values for anOPTIONAL INT64column, addressed by index, with a plain mask.Adds the values for anOPTIONAL INT64column, addressed by index.Adds the values for aREQUIRED INT64column, addressed by name.Adds the values for anOPTIONAL INT64column, addressed by name, with a plain mask.Adds the values for anOPTIONAL INT64column, addressed by name.Sets the entry offsets of aMAP, addressed by the map group's dot-separated path.Sets the entry offsets of aMAPtogether with its per-instance nulls (which maps are themselves absent), distinct from an empty map carrying a zero-delta offset.Sets the per-instance nulls of anOPTIONALstructgroup, addressed by its dot-separated path.
-
Method Details
-
struct
Sets the per-instance nulls of anOPTIONALstructgroup, addressed by its dot-separated path. Omitting the call leaves every instance of the group present. The values of leaf columns beneath a null struct instance are ignored.- Parameters:
structPath- the group's path (e.g."address")nulls- the group's nulls;nulls.isNull(i)marks instanceiabsent- Returns:
- this batch, for chaining
- Throws:
IllegalArgumentException- if the path does not name anOPTIONALstructgroup, or the group is already set in this batch
-
list
Sets the entry offsets of aLIST, addressed by the list group's dot-separated path.offsetshas lengthparentCount + 1;offsets[i+1] - offsets[i]is the number of entries of listi, and a zero delta is an empty list. The list's element leaf is filled separately throughints(int, int[]), its values holding the concatenated entries.- Parameters:
listPath- the list group's path (e.g."phones")offsets- the entry offsets- Returns:
- this batch, for chaining
- Throws:
IllegalArgumentException- if the path does not name aLIST, the list is already set, oroffsetsis empty
-
list
Sets the entry offsets of aLISTtogether with its per-instance nulls (which lists are themselves absent), distinct from an empty list carrying a zero-delta offset.- Parameters:
listPath- the list group's pathoffsets- the entry offsetsnulls- the list nulls;nulls.isNull(i)marks listiabsent- Returns:
- this batch, for chaining
- Throws:
IllegalArgumentException- if the path does not name anOPTIONALLIST, the list is already set, oroffsetsis empty
-
map
Sets the entry offsets of aMAP, addressed by the map group's dot-separated path. A thin alias over [#list(String, int[])]: the map'skeyandvalueleaves share this one offsets array,offsets[i+1] - offsets[i]being the number of entries of mapi, and a zero delta an empty map. The key and value leaves are filled throughints(int, int[])at<mapPath>.key_value.keyand<mapPath>.key_value.value.- Parameters:
mapPath- the map group's path (e.g."props")offsets- the entry offsets- Returns:
- this batch, for chaining
- Throws:
IllegalArgumentException- if the path does not name aMAP, the map is already set, oroffsetsis empty
-
map
Sets the entry offsets of aMAPtogether with its per-instance nulls (which maps are themselves absent), distinct from an empty map carrying a zero-delta offset.- Parameters:
mapPath- the map group's pathoffsets- the entry offsetsnulls- the map nulls;nulls.isNull(i)marks mapiabsent- Returns:
- this batch, for chaining
- Throws:
IllegalArgumentException- if the path does not name anOPTIONALMAP, the map is already set, oroffsetsis empty
-
ints
Adds the values for a
REQUIRED INT32column, addressed by index.The array is referenced, not copied, so it must not be mutated until the batch has been written. Every physical type has the same setter shapes (
longs,floats,doubles,booleans, …): by index or name, all-present or nullable (Validityorboolean[]mask).- Parameters:
columnIndex- zero-based leaf-column indexvalues- the column's values for this batch- Returns:
- this batch, for chaining
- Throws:
IndexOutOfBoundsException- ifcolumnIndexis not in[0, leaf column count)IllegalArgumentException- if the column is notINT32, the column is already set, a value falls outside the range the column's annotation declares, or the length does not match the other columns in this batch
-
ints
Adds the values for aREQUIRED INT32column, addressed by name.- See Also:
-
ints
Adds the values for anOPTIONAL INT32column, addressed by index. The values array is full length — one slot per row — and the entry at a null row is ignored.- Parameters:
columnIndex- zero-based leaf-column indexvalues- the column's values for this batchnulls- the column's nulls;nulls.isNull(i)marks rowinull- Returns:
- this batch, for chaining
- Throws:
IndexOutOfBoundsException- ifcolumnIndexis not in[0, leaf column count)IllegalArgumentException- if the column is notOPTIONAL INT32, the column is already set, or a value at a present row falls outside the range the column's annotation declares
-
ints
Adds the values for anOPTIONAL INT32column, addressed by name.- See Also:
-
ints
Adds the values for anOPTIONAL INT32column, addressed by index, with nulls given as a plain mask. Convenience sugar over [#ints(int, int[], Validity)] andValidity.ofNulls(boolean[]); unlike theValidityform, the mask length is checked against the values.- Parameters:
columnIndex- zero-based leaf-column indexvalues- the column's values for this batchnulls- the per-row null mask;nulls[i] == truemarks rowinull- Returns:
- this batch, for chaining
- Throws:
IndexOutOfBoundsException- ifcolumnIndexis not in[0, leaf column count)IllegalArgumentException- if the column is notOPTIONAL INT32, the column is already set, or the lengths do not agree
-
ints
Adds the values for anOPTIONAL INT32column, addressed by name, with nulls given as a plain mask.- See Also:
-
longs
Adds the values for aREQUIRED INT64column, addressed by index.- See Also:
-
longs
Adds the values for aREQUIRED INT64column, addressed by name.- See Also:
-
longs
Adds the values for anOPTIONAL INT64column, addressed by index.- See Also:
-
longs
Adds the values for anOPTIONAL INT64column, addressed by name.- See Also:
-
longs
Adds the values for anOPTIONAL INT64column, addressed by index, with a plain mask.- See Also:
-
longs
Adds the values for anOPTIONAL INT64column, addressed by name, with a plain mask.- See Also:
-
floats
Adds the values for aREQUIRED FLOATcolumn, addressed by index.- See Also:
-
floats
Adds the values for aREQUIRED FLOATcolumn, addressed by name.- See Also:
-
floats
Adds the values for anOPTIONAL FLOATcolumn, addressed by index.- See Also:
-
floats
Adds the values for anOPTIONAL FLOATcolumn, addressed by name.- See Also:
-
floats
Adds the values for anOPTIONAL FLOATcolumn, addressed by index, with a plain mask.- See Also:
-
floats
Adds the values for anOPTIONAL FLOATcolumn, addressed by name, with a plain mask.- See Also:
-
doubles
Adds the values for aREQUIRED DOUBLEcolumn, addressed by index.- See Also:
-
doubles
Adds the values for aREQUIRED DOUBLEcolumn, addressed by name.- See Also:
-
doubles
Adds the values for anOPTIONAL DOUBLEcolumn, addressed by index.- See Also:
-
doubles
Adds the values for anOPTIONAL DOUBLEcolumn, addressed by name.- See Also:
-
doubles
Adds the values for anOPTIONAL DOUBLEcolumn, addressed by index, with a plain mask.- See Also:
-
doubles
Adds the values for anOPTIONAL DOUBLEcolumn, addressed by name, with a plain mask.- See Also:
-
booleans
Adds the values for aREQUIRED BOOLEANcolumn, addressed by index.- See Also:
-
booleans
Adds the values for aREQUIRED BOOLEANcolumn, addressed by name.- See Also:
-
booleans
Adds the values for anOPTIONAL BOOLEANcolumn, addressed by index.- See Also:
-
booleans
Adds the values for anOPTIONAL BOOLEANcolumn, addressed by name.- See Also:
-
booleans
Adds the values for anOPTIONAL BOOLEANcolumn, addressed by index, with a plain mask.- See Also:
-
booleans
Adds the values for anOPTIONAL BOOLEANcolumn, addressed by name, with a plain mask.- See Also:
-
bytes
Adds the values for aREQUIRED BYTE_ARRAYcolumn, addressed by index. Each value is abyte[]; the arrays are referenced, not copied.- See Also:
-
bytes
Adds the values for aREQUIRED BYTE_ARRAYcolumn, addressed by name.- See Also:
-
bytes
Adds the values for anOPTIONAL BYTE_ARRAYcolumn, addressed by index.- See Also:
-
bytes
Adds the values for anOPTIONAL BYTE_ARRAYcolumn, addressed by name.- See Also:
-
bytes
Adds the values for anOPTIONAL BYTE_ARRAYcolumn, addressed by index, with a plain mask.- See Also:
-
bytes
Adds the values for anOPTIONAL BYTE_ARRAYcolumn, addressed by name, with a plain mask.- See Also:
-
fixed
Adds the values for aREQUIRED FIXED_LEN_BYTE_ARRAYcolumn, addressed by index. Every present value must be exactly the column's declared type length.- See Also:
-
fixed
Adds the values for aREQUIRED FIXED_LEN_BYTE_ARRAYcolumn, addressed by name.- See Also:
-
fixed
Adds the values for anOPTIONAL FIXED_LEN_BYTE_ARRAYcolumn, addressed by index.- See Also:
-
fixed
Adds the values for anOPTIONAL FIXED_LEN_BYTE_ARRAYcolumn, addressed by name.- See Also:
-
fixed
Adds the values for anOPTIONAL FIXED_LEN_BYTE_ARRAYcolumn, addressed by index, with a plain mask.- See Also:
-
fixed
Adds the values for anOPTIONAL FIXED_LEN_BYTE_ARRAYcolumn, addressed by name, with a plain mask.- See Also:
-