Class ColumnWriter
Writes a Parquet file one aligned batch of columns at a time.
This is the columnar API: the shape for a caller that already holds columns — a query
engine, an Arrow buffer, a bulk converter. Values are handed over as typed arrays addressed
by leaf index or leaf path, an OPTIONAL column carrying its nulls as a Validity
alongside them, and the writer shreds, pages, encodes and compresses them into the file.
try (ParquetFileWriter writer = ParquetFileWriter.create(out, schema)) {
ColumnWriter columns = writer.columnWriter();
columns.writeBatch(batch -> batch
.longs("id", ids)
.doubles("price", prices, priceNulls));
}
A ColumnWriter is not closeable: the ParquetFileWriter it came from owns the file, and
closing it flushes the row group still buffered here along with the footer.
-
Method Summary
Modifier and TypeMethodDescriptionvoidwriteBatch(Consumer<ColumnBatch> filler) Writes one aligned batch of column values, flushing row groups as the buffered data crosses the row-group target.
-
Method Details
-
writeBatch
Writes one aligned batch of column values, flushing row groups as the buffered data crosses the row-group target. A batch that would overflow the current row group is split at the boundary.
The writer creates the batch — bound to the schema — passes it to
fillerto be populated (columns addressed by index or name), then submits it. There is no separate build or submit step to forget.- Parameters:
filler- populates the batch's columns; must cover every column exactly once- Throws:
IOException- if the write failsIllegalArgumentException- if the batch does not cover every column, or its per-layer inputs do not agree on a record countUnsupportedOperationException- if the schema has a shape the writer cannot produceIllegalStateException- if the writer is closed
-