Package org.apache.parquet.hadoop
Class ParquetOutputFormat<T>
java.lang.Object
org.apache.hadoop.mapreduce.OutputFormat<K,V>
org.apache.hadoop.mapreduce.lib.output.FileOutputFormat<Void,T>
org.apache.parquet.hadoop.ParquetOutputFormat<T>
- Type Parameters:
T- the type of the materialized records
- Direct Known Subclasses:
ExampleOutputFormat
public class ParquetOutputFormat<T>
extends org.apache.hadoop.mapreduce.lib.output.FileOutputFormat<Void,T>
OutputFormat to write to a Parquet file
It requires a WriteSupport to convert the actual records to the underlying format.
It requires the schema of the incoming records. (provided by the write support)
It allows storing extra metadata in the footer (for example: for schema compatibility purpose when converting from a different schema language).
The format configuration settings in the job configuration:
# The block size is the size of a row group being buffered in memory # this limits the memory usage when writing # Larger values will improve the IO when reading but consume more memory when writing parquet.block.size=134217728 # in bytes, default = 128 * 1024 * 1024 # The page size is for compression. When reading, each page can be decompressed independently. # A block is composed of pages. The page is the smallest unit that must be read fully to access a single record. # If this value is too small, the compression will deteriorate parquet.page.size=1048576 # in bytes, default = 1 * 1024 * 1024 # There is one dictionary page per column per row group when dictionary encoding is used. # The dictionary page size works like the page size but for dictionary parquet.dictionary.page.size=1048576 # in bytes, default = 1 * 1024 * 1024 # The compression algorithm used to compress pages parquet.compression=UNCOMPRESSED # one of: UNCOMPRESSED, SNAPPY, GZIP, LZO, ZSTD. Default: UNCOMPRESSED. Supersedes mapred.output.compress* # The write support class to convert the records written to the OutputFormat into the events accepted by the record consumer # Usually provided by a specific ParquetOutputFormat subclass parquet.write.support.class= # fully qualified name # To enable/disable dictionary encoding parquet.enable.dictionary=true # false to disable dictionary encoding # To enable/disable BYTE_STREAM_SPLIT encoding parquet.enable.bytestreamsplit=false # true to enable BYTE_STREAM_SPLIT encoding # To enable/disable summary metadata aggregation at the end of a MR job # The default is true (enabled) parquet.enable.summary-metadata=true # false to disable summary aggregation # Maximum size (in bytes) allowed as padding to align row groups # This is also the minimum size of a row group. Default: 8388608 parquet.writer.max-padding=8388608 # 8 MB
If parquet.compression is not set, the following properties are checked (FileOutputFormat behavior). Note that we explicitely disallow custom Codecs
mapred.output.compress=true mapred.output.compression.codec=org.apache.hadoop.io.compress.SomeCodec # the codec must be one of Snappy, GZip or LZO
if none of those is set the data is uncompressed.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.apache.hadoop.mapreduce.lib.output.FileOutputFormat
org.apache.hadoop.mapreduce.lib.output.FileOutputFormat.Counter -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringDeprecated.static final Stringstatic final StringMust be one of the values inParquetOutputFormat.JobSummaryLevel(case insensitive)static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from class org.apache.hadoop.mapreduce.lib.output.FileOutputFormat
BASE_OUTPUT_NAME, COMPRESS, COMPRESS_CODEC, COMPRESS_TYPE, OUTDIR, PART -
Constructor Summary
ConstructorsConstructorDescriptionused when directly using the output format and configuring the write support implementation using parquet.write.support.classParquetOutputFormat(S writeSupport) constructor used when this OutputFormat in wrapped in another one (In Pig for example) -
Method Summary
Modifier and TypeMethodDescriptionstatic FileEncryptionPropertiescreateEncryptionProperties(org.apache.hadoop.conf.Configuration fileHadoopConfig, org.apache.hadoop.fs.Path tempFilePath, WriteSupport.WriteContext fileWriteContext) static booleangetAdaptiveBloomFilterEnabled(org.apache.hadoop.conf.Configuration conf) static intgetBlockSize(org.apache.hadoop.conf.Configuration configuration) Deprecated.static intgetBlockSize(org.apache.hadoop.mapreduce.JobContext jobContext) static booleangetBloomFilterEnabled(org.apache.hadoop.conf.Configuration conf) static intgetBloomFilterMaxBytes(org.apache.hadoop.conf.Configuration conf) static booleangetByteStreamSplitEnabled(org.apache.hadoop.conf.Configuration configuration) static org.apache.parquet.hadoop.metadata.CompressionCodecNamegetCompression(org.apache.hadoop.conf.Configuration configuration) static org.apache.parquet.hadoop.metadata.CompressionCodecNamegetCompression(org.apache.hadoop.mapreduce.JobContext jobContext) static intgetDictionaryPageSize(org.apache.hadoop.conf.Configuration configuration) static intgetDictionaryPageSize(org.apache.hadoop.mapreduce.JobContext jobContext) static booleangetEnableDictionary(org.apache.hadoop.conf.Configuration configuration) static booleangetEnableDictionary(org.apache.hadoop.mapreduce.JobContext jobContext) static booleangetEstimatePageSizeCheck(org.apache.hadoop.conf.Configuration configuration) getJobSummaryLevel(org.apache.hadoop.conf.Configuration conf) static longgetLongBlockSize(org.apache.hadoop.conf.Configuration configuration) static intgetMaxRowCountForPageSizeCheck(org.apache.hadoop.conf.Configuration configuration) static MemoryManagerstatic intgetMinRowCountForPageSizeCheck(org.apache.hadoop.conf.Configuration configuration) org.apache.hadoop.mapreduce.OutputCommittergetOutputCommitter(org.apache.hadoop.mapreduce.TaskAttemptContext context) static intgetPageSize(org.apache.hadoop.conf.Configuration configuration) static intgetPageSize(org.apache.hadoop.mapreduce.JobContext jobContext) static booleangetPageWriteChecksumEnabled(org.apache.hadoop.conf.Configuration conf) getRecordWriter(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path file, org.apache.parquet.hadoop.metadata.CompressionCodecName codec) getRecordWriter(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path file, org.apache.parquet.hadoop.metadata.CompressionCodecName codec, ParquetFileWriter.Mode mode) getRecordWriter(org.apache.hadoop.mapreduce.TaskAttemptContext taskAttemptContext) getRecordWriter(org.apache.hadoop.mapreduce.TaskAttemptContext taskAttemptContext, org.apache.hadoop.fs.Path file) getRecordWriter(org.apache.hadoop.mapreduce.TaskAttemptContext taskAttemptContext, org.apache.hadoop.fs.Path file, ParquetFileWriter.Mode mode) getRecordWriter(org.apache.hadoop.mapreduce.TaskAttemptContext taskAttemptContext, ParquetFileWriter.Mode mode) static booleangetSizeStatisticsEnabled(org.apache.hadoop.conf.Configuration conf) static booleangetSizeStatisticsEnabled(org.apache.hadoop.conf.Configuration conf, String path) static booleangetStatisticsEnabled(org.apache.hadoop.conf.Configuration conf) static booleangetStatisticsEnabled(org.apache.hadoop.conf.Configuration conf, String columnPath) static booleangetValidation(org.apache.hadoop.conf.Configuration configuration) static booleangetValidation(org.apache.hadoop.mapreduce.JobContext jobContext) static intgetValueCountThreshold(org.apache.hadoop.conf.Configuration configuration) static org.apache.parquet.column.ParquetProperties.WriterVersiongetWriterVersion(org.apache.hadoop.conf.Configuration configuration) getWriteSupport(org.apache.hadoop.conf.Configuration configuration) static Class<?>getWriteSupportClass(org.apache.hadoop.conf.Configuration configuration) static booleanisCompressionSet(org.apache.hadoop.conf.Configuration configuration) static booleanisCompressionSet(org.apache.hadoop.mapreduce.JobContext jobContext) static voidsetBlockRowCountLimit(org.apache.hadoop.conf.Configuration conf, int rowCount) static voidsetBlockRowCountLimit(org.apache.hadoop.mapreduce.JobContext jobContext, int rowCount) static voidsetBlockSize(org.apache.hadoop.mapreduce.Job job, int blockSize) static voidsetColumnCompression(org.apache.hadoop.mapreduce.Job job, String columnPath, org.apache.parquet.hadoop.metadata.CompressionCodecName codec) static voidsetColumnCompressionLevel(org.apache.hadoop.mapreduce.Job job, String columnPath, int level) static voidsetColumnIndexTruncateLength(org.apache.hadoop.conf.Configuration conf, int length) static voidsetColumnIndexTruncateLength(org.apache.hadoop.mapreduce.JobContext jobContext, int length) static voidsetCompression(org.apache.hadoop.mapreduce.Job job, org.apache.parquet.hadoop.metadata.CompressionCodecName compression) static voidsetDictionaryPageSize(org.apache.hadoop.mapreduce.Job job, int pageSize) static voidsetEnableDictionary(org.apache.hadoop.mapreduce.Job job, boolean enableDictionary) static voidsetMaxPaddingSize(org.apache.hadoop.conf.Configuration conf, int maxPaddingSize) static voidsetMaxPaddingSize(org.apache.hadoop.mapreduce.JobContext jobContext, int maxPaddingSize) static voidsetPageRowCountLimit(org.apache.hadoop.conf.Configuration conf, int rowCount) static voidsetPageRowCountLimit(org.apache.hadoop.mapreduce.JobContext jobContext, int rowCount) static voidsetPageSize(org.apache.hadoop.mapreduce.Job job, int pageSize) static voidsetPageWriteChecksumEnabled(org.apache.hadoop.conf.Configuration conf, boolean val) static voidsetPageWriteChecksumEnabled(org.apache.hadoop.mapreduce.JobContext jobContext, boolean val) static voidsetSizeStatisticsEnabled(org.apache.hadoop.conf.Configuration conf, boolean enabled) static voidsetSizeStatisticsEnabled(org.apache.hadoop.conf.Configuration conf, String path, boolean enabled) static voidsetStatisticsEnabled(org.apache.hadoop.mapreduce.JobContext jobContext, boolean enabled) static voidsetStatisticsEnabled(org.apache.hadoop.mapreduce.JobContext jobContext, String columnPath, boolean enabled) static voidsetStatisticsTruncateLength(org.apache.hadoop.mapreduce.JobContext jobContext, int length) static voidsetValidation(org.apache.hadoop.conf.Configuration configuration, boolean validating) static voidsetValidation(org.apache.hadoop.mapreduce.JobContext jobContext, boolean validating) static voidsetWriteSupportClass(org.apache.hadoop.mapred.JobConf job, Class<?> writeSupportClass) static voidsetWriteSupportClass(org.apache.hadoop.mapreduce.Job job, Class<?> writeSupportClass) Methods inherited from class org.apache.hadoop.mapreduce.lib.output.FileOutputFormat
checkOutputSpecs, getCompressOutput, getDefaultWorkFile, getOutputCompressorClass, getOutputName, getOutputPath, getPathForWorkFile, getUniqueFile, getWorkOutputPath, setCompressOutput, setOutputCompressorClass, setOutputName, setOutputPath
-
Field Details
-
ENABLE_JOB_SUMMARY
Deprecated.An alias for JOB_SUMMARY_LEVEL, where true means ALL and false means NONE- See Also:
-
JOB_SUMMARY_LEVEL
Must be one of the values inParquetOutputFormat.JobSummaryLevel(case insensitive)- See Also:
-
BLOCK_SIZE
- See Also:
-
PAGE_SIZE
- See Also:
-
COMPRESSION
- See Also:
-
WRITE_SUPPORT_CLASS
- See Also:
-
DICTIONARY_PAGE_SIZE
- See Also:
-
ENABLE_DICTIONARY
- See Also:
-
ENABLE_BYTE_STREAM_SPLIT
- See Also:
-
VALIDATION
- See Also:
-
WRITER_VERSION
- See Also:
-
MEMORY_POOL_RATIO
- See Also:
-
MIN_MEMORY_ALLOCATION
- See Also:
-
MAX_PADDING_BYTES
- See Also:
-
MIN_ROW_COUNT_FOR_PAGE_SIZE_CHECK
- See Also:
-
MAX_ROW_COUNT_FOR_PAGE_SIZE_CHECK
- See Also:
-
PAGE_VALUE_COUNT_THRESHOLD
- See Also:
-
ESTIMATE_PAGE_SIZE_CHECK
- See Also:
-
COLUMN_INDEX_TRUNCATE_LENGTH
- See Also:
-
STATISTICS_TRUNCATE_LENGTH
- See Also:
-
BLOOM_FILTER_ENABLED
- See Also:
-
BLOOM_FILTER_EXPECTED_NDV
- See Also:
-
BLOOM_FILTER_MAX_BYTES
- See Also:
-
BLOOM_FILTER_FPP
- See Also:
-
ADAPTIVE_BLOOM_FILTER_ENABLED
- See Also:
-
BLOOM_FILTER_CANDIDATES_NUMBER
- See Also:
-
BLOCK_ROW_COUNT_LIMIT
- See Also:
-
PAGE_ROW_COUNT_LIMIT
- See Also:
-
PAGE_WRITE_CHECKSUM_ENABLED
- See Also:
-
STATISTICS_ENABLED
- See Also:
-
SIZE_STATISTICS_ENABLED
- See Also:
-
COLUMN_COMPRESSION_LEVEL_PREFIX
- See Also:
-
-
Constructor Details
-
ParquetOutputFormat
public ParquetOutputFormat(S writeSupport) constructor used when this OutputFormat in wrapped in another one (In Pig for example)- Type Parameters:
S- the Java write support type- Parameters:
writeSupport- the class used to convert the incoming records
-
ParquetOutputFormat
public ParquetOutputFormat()used when directly using the output format and configuring the write support implementation using parquet.write.support.class- Type Parameters:
S- the Java write support type
-
-
Method Details
-
getJobSummaryLevel
public static ParquetOutputFormat.JobSummaryLevel getJobSummaryLevel(org.apache.hadoop.conf.Configuration conf) -
setWriteSupportClass
public static void setWriteSupportClass(org.apache.hadoop.mapreduce.Job job, Class<?> writeSupportClass) -
setWriteSupportClass
public static void setWriteSupportClass(org.apache.hadoop.mapred.JobConf job, Class<?> writeSupportClass) -
getWriteSupportClass
-
setBlockSize
public static void setBlockSize(org.apache.hadoop.mapreduce.Job job, int blockSize) -
setPageSize
public static void setPageSize(org.apache.hadoop.mapreduce.Job job, int pageSize) -
setDictionaryPageSize
public static void setDictionaryPageSize(org.apache.hadoop.mapreduce.Job job, int pageSize) -
setCompression
public static void setCompression(org.apache.hadoop.mapreduce.Job job, org.apache.parquet.hadoop.metadata.CompressionCodecName compression) -
setColumnCompression
public static void setColumnCompression(org.apache.hadoop.mapreduce.Job job, String columnPath, org.apache.parquet.hadoop.metadata.CompressionCodecName codec) -
setColumnCompressionLevel
public static void setColumnCompressionLevel(org.apache.hadoop.mapreduce.Job job, String columnPath, int level) -
setEnableDictionary
public static void setEnableDictionary(org.apache.hadoop.mapreduce.Job job, boolean enableDictionary) -
getEnableDictionary
public static boolean getEnableDictionary(org.apache.hadoop.mapreduce.JobContext jobContext) -
getBloomFilterMaxBytes
public static int getBloomFilterMaxBytes(org.apache.hadoop.conf.Configuration conf) -
getBloomFilterEnabled
public static boolean getBloomFilterEnabled(org.apache.hadoop.conf.Configuration conf) -
getAdaptiveBloomFilterEnabled
public static boolean getAdaptiveBloomFilterEnabled(org.apache.hadoop.conf.Configuration conf) -
getBlockSize
public static int getBlockSize(org.apache.hadoop.mapreduce.JobContext jobContext) -
getPageSize
public static int getPageSize(org.apache.hadoop.mapreduce.JobContext jobContext) -
getDictionaryPageSize
public static int getDictionaryPageSize(org.apache.hadoop.mapreduce.JobContext jobContext) -
getCompression
public static org.apache.parquet.hadoop.metadata.CompressionCodecName getCompression(org.apache.hadoop.mapreduce.JobContext jobContext) -
isCompressionSet
public static boolean isCompressionSet(org.apache.hadoop.mapreduce.JobContext jobContext) -
setValidation
public static void setValidation(org.apache.hadoop.mapreduce.JobContext jobContext, boolean validating) -
getValidation
public static boolean getValidation(org.apache.hadoop.mapreduce.JobContext jobContext) -
getEnableDictionary
public static boolean getEnableDictionary(org.apache.hadoop.conf.Configuration configuration) -
getByteStreamSplitEnabled
public static boolean getByteStreamSplitEnabled(org.apache.hadoop.conf.Configuration configuration) -
getMinRowCountForPageSizeCheck
public static int getMinRowCountForPageSizeCheck(org.apache.hadoop.conf.Configuration configuration) -
getMaxRowCountForPageSizeCheck
public static int getMaxRowCountForPageSizeCheck(org.apache.hadoop.conf.Configuration configuration) -
getValueCountThreshold
public static int getValueCountThreshold(org.apache.hadoop.conf.Configuration configuration) -
getEstimatePageSizeCheck
public static boolean getEstimatePageSizeCheck(org.apache.hadoop.conf.Configuration configuration) -
getBlockSize
Deprecated. -
getLongBlockSize
public static long getLongBlockSize(org.apache.hadoop.conf.Configuration configuration) -
getPageSize
public static int getPageSize(org.apache.hadoop.conf.Configuration configuration) -
getDictionaryPageSize
public static int getDictionaryPageSize(org.apache.hadoop.conf.Configuration configuration) -
getWriterVersion
public static org.apache.parquet.column.ParquetProperties.WriterVersion getWriterVersion(org.apache.hadoop.conf.Configuration configuration) -
getCompression
public static org.apache.parquet.hadoop.metadata.CompressionCodecName getCompression(org.apache.hadoop.conf.Configuration configuration) -
isCompressionSet
public static boolean isCompressionSet(org.apache.hadoop.conf.Configuration configuration) -
setValidation
public static void setValidation(org.apache.hadoop.conf.Configuration configuration, boolean validating) -
getValidation
public static boolean getValidation(org.apache.hadoop.conf.Configuration configuration) -
setMaxPaddingSize
public static void setMaxPaddingSize(org.apache.hadoop.mapreduce.JobContext jobContext, int maxPaddingSize) -
setMaxPaddingSize
public static void setMaxPaddingSize(org.apache.hadoop.conf.Configuration conf, int maxPaddingSize) -
setColumnIndexTruncateLength
public static void setColumnIndexTruncateLength(org.apache.hadoop.mapreduce.JobContext jobContext, int length) -
setColumnIndexTruncateLength
public static void setColumnIndexTruncateLength(org.apache.hadoop.conf.Configuration conf, int length) -
setStatisticsTruncateLength
public static void setStatisticsTruncateLength(org.apache.hadoop.mapreduce.JobContext jobContext, int length) -
setBlockRowCountLimit
public static void setBlockRowCountLimit(org.apache.hadoop.mapreduce.JobContext jobContext, int rowCount) -
setBlockRowCountLimit
public static void setBlockRowCountLimit(org.apache.hadoop.conf.Configuration conf, int rowCount) -
setPageRowCountLimit
public static void setPageRowCountLimit(org.apache.hadoop.mapreduce.JobContext jobContext, int rowCount) -
setPageRowCountLimit
public static void setPageRowCountLimit(org.apache.hadoop.conf.Configuration conf, int rowCount) -
setPageWriteChecksumEnabled
public static void setPageWriteChecksumEnabled(org.apache.hadoop.mapreduce.JobContext jobContext, boolean val) -
setPageWriteChecksumEnabled
public static void setPageWriteChecksumEnabled(org.apache.hadoop.conf.Configuration conf, boolean val) -
getPageWriteChecksumEnabled
public static boolean getPageWriteChecksumEnabled(org.apache.hadoop.conf.Configuration conf) -
setStatisticsEnabled
public static void setStatisticsEnabled(org.apache.hadoop.mapreduce.JobContext jobContext, boolean enabled) -
getStatisticsEnabled
public static boolean getStatisticsEnabled(org.apache.hadoop.conf.Configuration conf) -
setStatisticsEnabled
public static void setStatisticsEnabled(org.apache.hadoop.mapreduce.JobContext jobContext, String columnPath, boolean enabled) -
getStatisticsEnabled
public static boolean getStatisticsEnabled(org.apache.hadoop.conf.Configuration conf, String columnPath) -
setSizeStatisticsEnabled
public static void setSizeStatisticsEnabled(org.apache.hadoop.conf.Configuration conf, boolean enabled) -
setSizeStatisticsEnabled
public static void setSizeStatisticsEnabled(org.apache.hadoop.conf.Configuration conf, String path, boolean enabled) -
getSizeStatisticsEnabled
public static boolean getSizeStatisticsEnabled(org.apache.hadoop.conf.Configuration conf) -
getSizeStatisticsEnabled
public static boolean getSizeStatisticsEnabled(org.apache.hadoop.conf.Configuration conf, String path) -
getRecordWriter
public org.apache.hadoop.mapreduce.RecordWriter<Void,T> getRecordWriter(org.apache.hadoop.mapreduce.TaskAttemptContext taskAttemptContext) throws IOException, InterruptedException - Specified by:
getRecordWriterin classorg.apache.hadoop.mapreduce.lib.output.FileOutputFormat<Void,T> - Throws:
IOExceptionInterruptedException
-
getRecordWriter
public org.apache.hadoop.mapreduce.RecordWriter<Void,T> getRecordWriter(org.apache.hadoop.mapreduce.TaskAttemptContext taskAttemptContext, ParquetFileWriter.Mode mode) throws IOException, InterruptedException - Throws:
IOExceptionInterruptedException
-
getRecordWriter
public org.apache.hadoop.mapreduce.RecordWriter<Void,T> getRecordWriter(org.apache.hadoop.mapreduce.TaskAttemptContext taskAttemptContext, org.apache.hadoop.fs.Path file) throws IOException, InterruptedException - Throws:
IOExceptionInterruptedException
-
getRecordWriter
public org.apache.hadoop.mapreduce.RecordWriter<Void,T> getRecordWriter(org.apache.hadoop.mapreduce.TaskAttemptContext taskAttemptContext, org.apache.hadoop.fs.Path file, ParquetFileWriter.Mode mode) throws IOException, InterruptedException - Throws:
IOExceptionInterruptedException
-
getRecordWriter
public org.apache.hadoop.mapreduce.RecordWriter<Void,T> getRecordWriter(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path file, org.apache.parquet.hadoop.metadata.CompressionCodecName codec) throws IOException, InterruptedException - Throws:
IOExceptionInterruptedException
-
getRecordWriter
public org.apache.hadoop.mapreduce.RecordWriter<Void,T> getRecordWriter(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path file, org.apache.parquet.hadoop.metadata.CompressionCodecName codec, ParquetFileWriter.Mode mode) throws IOException, InterruptedException - Throws:
IOExceptionInterruptedException
-
getWriteSupport
- Parameters:
configuration- to find the configuration for the write support class- Returns:
- the configured write support
-
getOutputCommitter
public org.apache.hadoop.mapreduce.OutputCommitter getOutputCommitter(org.apache.hadoop.mapreduce.TaskAttemptContext context) throws IOException - Overrides:
getOutputCommitterin classorg.apache.hadoop.mapreduce.lib.output.FileOutputFormat<Void,T> - Throws:
IOException
-
getMemoryManager
-
createEncryptionProperties
public static FileEncryptionProperties createEncryptionProperties(org.apache.hadoop.conf.Configuration fileHadoopConfig, org.apache.hadoop.fs.Path tempFilePath, WriteSupport.WriteContext fileWriteContext)
-