Class WriterConfig
Tuning knobs for ParquetFileWriter.
Three size targets govern the writer's output granularity:
- Page target — the writer cuts a data page once the entries it holds would encode to this many bytes. The page is cut before the entry that would cross it, so this is a ceiling rather than something a page overshoots; only a single value larger than the whole target can breach it, a value not being divisible across pages.
- Row-group row target — the writer cuts a row group once it holds this many records. This is the control over how a file is banded, and it is exactly what it says: a row count needs no estimate and does not vary with the data. It binds for narrow records.
- Row-group buffer target — the writer also cuts a row group once the bytes it holds for that group reach this many: its level streams, dictionary indices, value stores and dictionaries. This is the memory control, and it bounds a row group of records wider than expected. A row group passes it by at most one record.
A row group is cut at whichever of the two row-group targets is reached first.
Neither of them is the size of what reaches the file. A row group is encoded and compressed
after it is buffered, and both steps shrink it by a factor of the data's own repetitiveness:
the same buffer target produces a row group a twentieth of its size on dictionary-friendly
data and most of its size on incompressible data. A caller who needs a particular on-disk
size measures one file and scales the setting; a caller who needs a particular banding sets
the row target. See ParquetFileWriter for what bounds memory.
How a column's values are stored is a ColumnEncoding, set file-wide or per leaf column;
how the resulting page bodies are compressed is the CompressionCodec. Both are configured
here rather than on the schema.
A file's created_by identifier and its key-value metadata are set on ParquetFileWriter.
Obtain the defaults with defaults() or override individual knobs through builder().
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final CompressionCodecDefault page compression codec:ZSTDwhen the zstd-jni library is on the classpath, otherwiseUNCOMPRESSED.static final ColumnEncodingDefault encoding policy:ColumnEncoding.AUTO, leaving each column chunk's encoding to the size comparison the writer makes once the row group is buffered.static final intDefault page target: 1 MiB of encoded values per data page.static final PrecisionLossPolicyDefault precision-loss policy: reject a value the column cannot hold exactly, rather than silently dropping the digits that do not fit.static final longDefault row-group buffer target: 128 MiB of buffered values per row group.static final longDefault row-group row target: 1,048,576 records.static final intDefault statistics truncation length:BYTE_ARRAYmin/maxbounds longer than 64 bytes are truncated and flagged inexact. -
Method Summary
Modifier and TypeMethodDescriptionstatic WriterConfig.Builderbuilder()A builder pre-populated with the defaults.codec()The codec each page body is compressed with.The per-column encoding policies, keyed by dotted leaf path.The encoding policy for columns with no override of their own.static WriterConfigdefaults()The default configuration.intEncoded-byte threshold at which a data page is cut.WhatRowWriterdoes with a value carrying more precision than its column can hold.longByte threshold at which a row group is cut, counted as the bytes the writer holds for it.longRecord count at which a row group is cut.intThe maximum length of aBYTE_ARRAYmin/maxstatistics bound before it is truncated (and flagged inexact).
-
Field Details
-
DEFAULT_PAGE_TARGET_BYTES
public static final int DEFAULT_PAGE_TARGET_BYTESDefault page target: 1 MiB of encoded values per data page.- See Also:
-
DEFAULT_ROW_GROUP_BUFFER_TARGET_BYTES
public static final long DEFAULT_ROW_GROUP_BUFFER_TARGET_BYTESDefault row-group buffer target: 128 MiB of buffered values per row group.- See Also:
-
DEFAULT_ROW_GROUP_TARGET_ROWS
public static final long DEFAULT_ROW_GROUP_TARGET_ROWSDefault row-group row target: 1,048,576 records.
Both Arrow implementations cap a row group's records here — DuckDB caps lower, at 122,880 — and on a flat three-column fixture the cap costs a quarter of a percent in file size for four times the banding. It binds wherever a record is narrower than the buffer target's share of it — for anything under about 128 bytes a record — and the buffer target takes over above that, so a narrow schema is banded by its record count and a wide one by what it holds.
- See Also:
-
DEFAULT_STATISTICS_TRUNCATION_LENGTH
public static final int DEFAULT_STATISTICS_TRUNCATION_LENGTHDefault statistics truncation length:BYTE_ARRAYmin/maxbounds longer than 64 bytes are truncated and flagged inexact.- See Also:
-
DEFAULT_CODEC
Default page compression codec:ZSTDwhen the zstd-jni library is on the classpath, otherwiseUNCOMPRESSED. Choosing a codec explicitly throughWriterConfig.Builder.codecstill requires that codec's library and fails at writer creation when it is missing; this default only avoids imposing the ZSTD dependency on callers who did not ask to compress. -
DEFAULT_PRECISION_LOSS_POLICY
Default precision-loss policy: reject a value the column cannot hold exactly, rather than silently dropping the digits that do not fit. -
DEFAULT_ENCODING
Default encoding policy:ColumnEncoding.AUTO, leaving each column chunk's encoding to the size comparison the writer makes once the row group is buffered.
-
-
Method Details
-
defaults
The default configuration. -
builder
A builder pre-populated with the defaults. -
pageTargetBytes
public int pageTargetBytes()Encoded-byte threshold at which a data page is cut. -
rowGroupBufferTargetBytes
public long rowGroupBufferTargetBytes()Byte threshold at which a row group is cut, counted as the bytes the writer holds for it. -
rowGroupTargetRows
public long rowGroupTargetRows()Record count at which a row group is cut. -
defaultEncoding
The encoding policy for columns with no override of their own. -
columnEncodings
The per-column encoding policies, keyed by dotted leaf path. Unmodifiable, and empty where no column was named. -
statisticsTruncationLength
public int statisticsTruncationLength()The maximum length of aBYTE_ARRAYmin/maxstatistics bound before it is truncated (and flagged inexact). -
codec
The codec each page body is compressed with. -
precisionLossPolicy
WhatRowWriterdoes with a value carrying more precision than its column can hold.
-