Class ParquetRewriter
- java.lang.Object
-
- org.apache.parquet.hadoop.rewrite.ParquetRewriter
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class ParquetRewriter extends Object implements Closeable
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 provideinputFiles. Please note the schema of allinputFilesmust be the same, otherwise the rewrite will fail.Applying column transformations
Some supported column transformations: pruning, masking, renaming, encrypting, changing a codec. SeeRewriteOptionsandRewriteOptions.Builderfor the full list with description.Joining with extra files with a different schema
UseRewriteOptions.Builder's constructor or methods to provideinputFilesToJoin. Please note the schema of allinputFilesToJoinmust be the same, otherwise the rewrite will fail. Requirements for a joining the maininputFiles(left) andinputFilesToJoin(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 Modifier and Type Field Description static StringORIGINAL_CREATED_BY_KEY
-
Constructor Summary
Constructors Constructor Description ParquetRewriter(RewriteOptions options)ParquetRewriter(CompressionConverter.TransParquetFileReader reader, ParquetFileWriter writer, ParquetMetadata meta, MessageType outSchema, String originalCreatedBy, CompressionCodecName codecName, List<String> maskColumns, MaskMode maskMode)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidprocessBlocks()BytesInputreadBlock(int length, CompressionConverter.TransParquetFileReader reader)BytesInputreadBlockAllocate(int length, CompressionConverter.TransParquetFileReader reader)
-
-
-
Field Detail
-
ORIGINAL_CREATED_BY_KEY
public static final String ORIGINAL_CREATED_BY_KEY
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ParquetRewriter
public ParquetRewriter(RewriteOptions options) throws IOException
- Throws:
IOException
-
ParquetRewriter
public ParquetRewriter(CompressionConverter.TransParquetFileReader reader, ParquetFileWriter writer, ParquetMetadata meta, MessageType outSchema, String originalCreatedBy, CompressionCodecName codecName, List<String> maskColumns, MaskMode maskMode)
-
-
Method Detail
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
processBlocks
public void processBlocks() throws IOException- Throws:
IOException
-
readBlock
public BytesInput readBlock(int length, CompressionConverter.TransParquetFileReader reader) throws IOException
- Throws:
IOException
-
readBlockAllocate
public BytesInput readBlockAllocate(int length, CompressionConverter.TransParquetFileReader reader) throws IOException
- Throws:
IOException
-
-