Class ParquetRewriter
java.lang.Object
org.apache.parquet.hadoop.rewrite.ParquetRewriter
- All Implemented Interfaces:
Closeable,AutoCloseable
Rewrites multiple input files into a single output file.
Supported functionality:
- Merging multiple files into a single one
- Applying column transformations
- Joining with extra files with a different schema
Note that the total number of row groups from all input files is preserved in the output file. This may not be optimal if row groups are very small and will not solve small file problems. Instead, it will make it worse to have a large file footer in the output file.
Merging multiple files into a single output files
UseRewriteOptions.Builder's constructor or methods to provide inputFiles.
Please note the schema of all inputFiles must be the same, otherwise the rewrite will fail.
Applying column transformations
Some supported column transformations: pruning, masking, renaming, encrypting, changing a codec. SeeRewriteOptions and RewriteOptions.Builder for the full list with description.
Joining with extra files with a different schema
UseRewriteOptions.Builder's constructor or methods to provide inputFilesToJoin.
Please note the schema of all inputFilesToJoin must be the same, otherwise the rewrite will fail.
Requirements for a joining the main inputFiles(left) and inputFilesToJoin(right):
- the number of files might be different on the left and right,
- the schema of files inside of each group(left/right) must be the same, but those two schemas not necessarily should be equal,
- the total number of row groups must be the same on the left and right,
- the total number of rows must be the same on the left and right,
- the global ordering of rows must be the same on the left and right.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionParquetRewriter(RewriteOptions options) ParquetRewriter(CompressionConverter.TransParquetFileReader reader, ParquetFileWriter writer, ParquetMetadata meta, org.apache.parquet.schema.MessageType outSchema, String originalCreatedBy, org.apache.parquet.hadoop.metadata.CompressionCodecName codecName, List<String> maskColumns, MaskMode maskMode) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidorg.apache.parquet.bytes.BytesInputreadBlock(int length, CompressionConverter.TransParquetFileReader reader) org.apache.parquet.bytes.BytesInputreadBlockAllocate(int length, CompressionConverter.TransParquetFileReader reader)
-
Field Details
-
ORIGINAL_CREATED_BY_KEY
- See Also:
-
-
Constructor Details
-
ParquetRewriter
- Throws:
IOException
-
ParquetRewriter
public ParquetRewriter(CompressionConverter.TransParquetFileReader reader, ParquetFileWriter writer, ParquetMetadata meta, org.apache.parquet.schema.MessageType outSchema, String originalCreatedBy, org.apache.parquet.hadoop.metadata.CompressionCodecName codecName, List<String> maskColumns, MaskMode maskMode)
-
-
Method Details
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
processBlocks
- Throws:
IOException
-
readBlock
public org.apache.parquet.bytes.BytesInput readBlock(int length, CompressionConverter.TransParquetFileReader reader) throws IOException - Throws:
IOException
-
readBlockAllocate
public org.apache.parquet.bytes.BytesInput readBlockAllocate(int length, CompressionConverter.TransParquetFileReader reader) throws IOException - Throws:
IOException
-