Package org.apache.parquet.hadoop
Class ParquetWriter.Builder<T,SELF extends ParquetWriter.Builder<T,SELF>>
java.lang.Object
org.apache.parquet.hadoop.ParquetWriter.Builder<T,SELF>
- Type Parameters:
T- The type of objects written by the constructed ParquetWriter.SELF- The type of this builder that is returned by builder methods
- Direct Known Subclasses:
ExampleParquetWriter.Builder
- Enclosing class:
- ParquetWriter<T>
public abstract static class ParquetWriter.Builder<T,SELF extends ParquetWriter.Builder<T,SELF>>
extends Object
An abstract builder class for ParquetWriter instances.
Object models should extend this builder to provide writer configuration options.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Build aParquetWriterwith the accumulated configuration.Set a property that will be available to the read path.Enables dictionary encoding for the constructed writer.Enables writing page level checksums for the constructed writer.Enables validation for the constructed writer.protected abstract WriteSupport<T>getWriteSupport(org.apache.hadoop.conf.Configuration conf) Deprecated.protected WriteSupport<T>getWriteSupport(org.apache.parquet.conf.ParquetConfiguration conf) protected abstract SELFself()withAdaptiveBloomFilterEnabled(boolean enabled) When NDV (number of distinct values) for a specified column is not set, whether to use `AdaptiveBloomFilter` to automatically adjust the BloomFilter size according to `parquet.bloom.filter.max.bytes`withAllocator(org.apache.parquet.bytes.ByteBufferAllocator allocator) Sets the ByteBuffer allocator instance to be used for allocating memory for writing.withBloomFilterCandidateNumber(String columnPath, int number) When `AdaptiveBloomFilter` is enabled, set how many bloom filter candidates to use.withBloomFilterEnabled(boolean enabled) Sets the bloom filter enabled/disabledwithBloomFilterEnabled(String columnPath, boolean enabled) Sets the bloom filter enabled/disabled for the specified column.withBloomFilterFPP(String columnPath, double fpp) withBloomFilterNDV(String columnPath, long ndv) Sets the NDV (number of distinct values) for the specified column.withByteStreamSplitEncoding(boolean enableByteStreamSplit) withByteStreamSplitEncoding(String columnPath, boolean enableByteStreamSplit) withCodecFactory(org.apache.parquet.compression.CompressionCodecFactory codecFactory) Set thecodec factoryused by the constructed writer.withColumnIndexTruncateLength(int length) Sets the length to be used for truncating binary values in a binary column index.withCompressionCodec(String columnPath, org.apache.parquet.hadoop.metadata.CompressionCodecName codecName) Override the compression codec for a specific column.withCompressionCodec(org.apache.parquet.hadoop.metadata.CompressionCodecName codecName) Set thecompression codecused by the constructed writer.withCompressionLevel(String columnPath, Integer level) Set the compression level for a specific column.withConf(org.apache.hadoop.conf.Configuration conf) Set theConfigurationused by the constructed writer.withConf(org.apache.parquet.conf.ParquetConfiguration conf) Set theParquetConfigurationused by the constructed writer.withDictionaryEncoding(boolean enableDictionary) Enable or disable dictionary encoding for the constructed writer.withDictionaryEncoding(String columnPath, boolean enableDictionary) Enable or disable dictionary encoding of the specified column for the constructed writer.withDictionaryPageSize(int dictionaryPageSize) Set the Parquet format dictionary page size used by the constructed writer.withEncryption(FileEncryptionProperties encryptionProperties) Set thefile encryption propertiesused by the constructed writer.withExtraMetaData(Map<String, String> extraMetaData) Sets additional metadata entries to be included in the file footer.withFile(org.apache.parquet.io.OutputFile file) Set theOutputFileto be written by the constructed writer.withMaxBloomFilterBytes(int maxBloomFilterBytes) Set max Bloom filter bytes for related columns.withMaxPaddingSize(int maxPaddingSize) Set the maximum amount of padding, in bytes, that will be used to align row groups with blocks in the underlying filesystem.withMaxRowCountForPageSizeCheck(int max) Sets the maximum number of rows to write before a page size check is done.withMinRowCountForPageSizeCheck(int min) Sets the minimum number of rows to write before a page size check is done.withPageRowCountLimit(int rowCount) Sets the Parquet format page row count limit used by the constructed writer.withPageSize(int pageSize) Set the Parquet format page size used by the constructed writer.withPageWriteChecksumEnabled(boolean enablePageWriteChecksum) Enables writing page level checksums for the constructed writer.withRowGroupRowCountLimit(int rowCount) Sets the Parquet format row group row count limit used by the constructed writer.withRowGroupSize(int rowGroupSize) Deprecated.UsewithRowGroupSize(long)insteadwithRowGroupSize(long rowGroupSize) Set the Parquet format row group size used by the constructed writer.withSizeStatisticsEnabled(boolean enabled) Sets whether size statistics are enabled globally.withSizeStatisticsEnabled(String columnPath, boolean enabled) Sets the size statistics enabled/disabled for the specified column.withStatisticsEnabled(boolean enabled) Sets whether statistics are enabled globally.withStatisticsEnabled(String columnPath, boolean enabled) Sets the statistics enabled/disabled for the specified column.withStatisticsTruncateLength(int length) Sets the length which the min/max binary values in row groups are truncated to.withValidation(boolean enableValidation) Enable or disable validation for the constructed writer.Set thewrite modeused when creating the backing file for this writer.withWriterVersion(org.apache.parquet.column.ParquetProperties.WriterVersion version) Set theformat versionused by the constructed writer.
-
Constructor Details
-
Builder
protected Builder() -
Builder
Deprecated. -
Builder
protected Builder(org.apache.parquet.io.OutputFile path)
-
-
Method Details
-
self
- Returns:
- this as the correct subclass of ParquetWriter.Builder.
-
getWriteSupport
@Deprecated protected abstract WriteSupport<T> getWriteSupport(org.apache.hadoop.conf.Configuration conf) Deprecated.UsegetWriteSupport(ParquetConfiguration)instead- Parameters:
conf- a configuration- Returns:
- an appropriate WriteSupport for the object model.
-
getWriteSupport
- Parameters:
conf- a configuration- Returns:
- an appropriate WriteSupport for the object model.
-
withConf
Set theConfigurationused by the constructed writer.- Parameters:
conf- aConfiguration- Returns:
- this builder for method chaining.
-
withConf
Set theParquetConfigurationused by the constructed writer.- Parameters:
conf- aParquetConfiguration- Returns:
- this builder for method chaining.
-
withFile
Set theOutputFileto be written by the constructed writer.- Parameters:
file- aOutputFile- Returns:
- this builder for method chaining.
-
withWriteMode
Set thewrite modeused when creating the backing file for this writer.- Parameters:
mode- aParquetFileWriter.Mode- Returns:
- this builder for method chaining.
-
withCompressionCodec
Set thecompression codecused by the constructed writer.- Parameters:
codecName- aCompressionCodecName- Returns:
- this builder for method chaining.
-
withCompressionCodec
public SELF withCompressionCodec(String columnPath, org.apache.parquet.hadoop.metadata.CompressionCodecName codecName) Override the compression codec for a specific column.- Parameters:
columnPath- dot-string path of the column (e.g."my_col")codecName- the codec to use for that column- Returns:
- this builder for method chaining.
-
withCompressionLevel
Set the compression level for a specific column. The valid range is codec-specific (e.g. ZSTD: negative levels trade ratio for speed, up to 22 for best compression (default 3), GZIP: 0–9 or -1 (default 6), BROTLI: 0–11 (default 1)). Passnullto unset a previously configured level for that column.- Parameters:
columnPath- dot-string path of the column (e.g."my_col")level- codec-specific compression level, ornullto unset- Returns:
- this builder for method chaining.
-
withCodecFactory
Set thecodec factoryused by the constructed writer.- Parameters:
codecFactory- aCompressionCodecFactory- Returns:
- this builder for method chaining.
-
withEncryption
Set thefile encryption propertiesused by the constructed writer.- Parameters:
encryptionProperties- aFileEncryptionProperties- Returns:
- this builder for method chaining.
-
withRowGroupSize
Deprecated.UsewithRowGroupSize(long)insteadSet the Parquet format row group size used by the constructed writer.- Parameters:
rowGroupSize- an integer size in bytes- Returns:
- this builder for method chaining.
-
withRowGroupSize
Set the Parquet format row group size used by the constructed writer.- Parameters:
rowGroupSize- an integer size in bytes- Returns:
- this builder for method chaining.
-
withPageSize
Set the Parquet format page size used by the constructed writer.- Parameters:
pageSize- an integer size in bytes- Returns:
- this builder for method chaining.
-
withRowGroupRowCountLimit
Sets the Parquet format row group row count limit used by the constructed writer.- Parameters:
rowCount- limit for the number of rows stored in a row group- Returns:
- this builder for method chaining
-
withPageRowCountLimit
Sets the Parquet format page row count limit used by the constructed writer.- Parameters:
rowCount- limit for the number of rows stored in a page- Returns:
- this builder for method chaining
-
withDictionaryPageSize
Set the Parquet format dictionary page size used by the constructed writer.- Parameters:
dictionaryPageSize- an integer size in bytes- Returns:
- this builder for method chaining.
-
withMaxPaddingSize
Set the maximum amount of padding, in bytes, that will be used to align row groups with blocks in the underlying filesystem. If the underlying filesystem is not a block filesystem like HDFS, this has no effect.- Parameters:
maxPaddingSize- an integer size in bytes- Returns:
- this builder for method chaining.
-
enableDictionaryEncoding
Enables dictionary encoding for the constructed writer.- Returns:
- this builder for method chaining.
-
withDictionaryEncoding
Enable or disable dictionary encoding for the constructed writer.- Parameters:
enableDictionary- whether dictionary encoding should be enabled- Returns:
- this builder for method chaining.
-
withByteStreamSplitEncoding
-
withByteStreamSplitEncoding
-
withDictionaryEncoding
Enable or disable dictionary encoding of the specified column for the constructed writer.- Parameters:
columnPath- the path of the column (dot-string)enableDictionary- whether dictionary encoding should be enabled- Returns:
- this builder for method chaining.
-
enableValidation
Enables validation for the constructed writer.- Returns:
- this builder for method chaining.
-
withValidation
Enable or disable validation for the constructed writer.- Parameters:
enableValidation- whether validation should be enabled- Returns:
- this builder for method chaining.
-
withWriterVersion
Set theformat versionused by the constructed writer.- Parameters:
version- aWriterVersion- Returns:
- this builder for method chaining.
-
enablePageWriteChecksum
Enables writing page level checksums for the constructed writer.- Returns:
- this builder for method chaining.
-
withPageWriteChecksumEnabled
Enables writing page level checksums for the constructed writer.- Parameters:
enablePageWriteChecksum- whether page checksums should be written out- Returns:
- this builder for method chaining.
-
withMaxBloomFilterBytes
Set max Bloom filter bytes for related columns.- Parameters:
maxBloomFilterBytes- the max bytes of a Bloom filter bitset for a column.- Returns:
- this builder for method chaining
-
withBloomFilterNDV
Sets the NDV (number of distinct values) for the specified column.- Parameters:
columnPath- the path of the column (dot-string)ndv- the NDV of the column- Returns:
- this builder for method chaining.
-
withBloomFilterFPP
-
withAdaptiveBloomFilterEnabled
When NDV (number of distinct values) for a specified column is not set, whether to use `AdaptiveBloomFilter` to automatically adjust the BloomFilter size according to `parquet.bloom.filter.max.bytes`- Parameters:
enabled- whether to write bloom filter for the column
-
withBloomFilterCandidateNumber
When `AdaptiveBloomFilter` is enabled, set how many bloom filter candidates to use.- Parameters:
columnPath- the path of the column (dot-string)number- the number of candidate
-
withBloomFilterEnabled
Sets the bloom filter enabled/disabled- Parameters:
enabled- whether to write bloom filters- Returns:
- this builder for method chaining
-
withBloomFilterEnabled
Sets the bloom filter enabled/disabled for the specified column. If not set for the column specifically the default enabled/disabled state will take place. SeewithBloomFilterEnabled(boolean).- Parameters:
columnPath- the path of the column (dot-string)enabled- whether to write bloom filter for the column- Returns:
- this builder for method chaining
-
withMinRowCountForPageSizeCheck
Sets the minimum number of rows to write before a page size check is done.- Parameters:
min- writes at least `min` rows before invoking a page size check- Returns:
- this builder for method chaining
-
withMaxRowCountForPageSizeCheck
Sets the maximum number of rows to write before a page size check is done.- Parameters:
max- makes a page size check after `max` rows have been written- Returns:
- this builder for method chaining
-
withColumnIndexTruncateLength
Sets the length to be used for truncating binary values in a binary column index.- Parameters:
length- the length to truncate to- Returns:
- this builder for method chaining
-
withStatisticsTruncateLength
Sets the length which the min/max binary values in row groups are truncated to.- Parameters:
length- the length to truncate to- Returns:
- this builder for method chaining
-
withExtraMetaData
Sets additional metadata entries to be included in the file footer.- Parameters:
extraMetaData- a Map of additional stringly-typed metadata entries- Returns:
- this builder for method chaining
-
withAllocator
Sets the ByteBuffer allocator instance to be used for allocating memory for writing.- Parameters:
allocator- the allocator instance- Returns:
- this builder for method chaining
-
config
Set a property that will be available to the read path. For writers that use a Hadoop configuration, this is the recommended way to add configuration values.- Parameters:
property- a String property namevalue- a String property value- Returns:
- this builder for method chaining.
-
withStatisticsEnabled
Sets the statistics enabled/disabled for the specified column. All column statistics are enabled by default.- Parameters:
columnPath- the path of the column (dot-string)enabled- whether to write calculate statistics for the column- Returns:
- this builder for method chaining
-
withStatisticsEnabled
Sets whether statistics are enabled globally. When disabled, statistics will not be collected for any column unless explicitly enabled for specific columns.- Parameters:
enabled- whether to collect statistics globally- Returns:
- this builder for method chaining
-
withSizeStatisticsEnabled
Sets the size statistics enabled/disabled for the specified column. All column size statistics are enabled by default.- Parameters:
columnPath- the path of the column (dot-string)enabled- whether to collect size statistics for the column- Returns:
- this builder for method chaining
-
withSizeStatisticsEnabled
Sets whether size statistics are enabled globally. When disabled, size statistics will not be collected for any column unless explicitly enabled for specific columns.- Parameters:
enabled- whether to collect size statistics globally- Returns:
- this builder for method chaining
-
build
Build aParquetWriterwith the accumulated configuration.- Returns:
- a configured
ParquetWriterinstance. - Throws:
IOException- if there is an error while creating the writer
-
getWriteSupport(ParquetConfiguration)instead