Interface Compression
- All Known Implementing Classes:
Compression.Fixed, Compression.Leveled
How ParquetFileWriter compresses each page body: a codec, and for the codecs that have
them, the level it compresses at.
Obtain one from the factory for its codec, and set a level on the codecs that take one:
WriterConfig config = WriterConfig.builder()
.compression(Compression.zstd().level(9))
.build();
| Factory | Codec | Levels | Default level |
|---|---|---|---|
uncompressed() |
UNCOMPRESSED |
— | — |
snappy() |
SNAPPY |
— | — |
gzip() |
GZIP |
0 (stored, not compressed) to 9 | 6 |
zstd() |
ZSTD |
-131072 to 22; 0 selects the default | 3 |
lz4Raw() |
LZ4_RAW |
1 to 17, through LZ4's high compressor (LZ4 HC) | LZ4's fast compressor |
brotli() |
BROTLI |
0 to 11 | 11 |
A higher level writes a smaller file and takes longer to write; reading the file takes about
as long at any level. Every codec but UNCOMPRESSED and GZIP needs its library on the
classpath, which is checked when the writer is created.
Instances are immutable; equal when their codec and level are.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classA codec without levels.static final classA codec with levels, at its default level or the oneCompression.Leveled.level(int)set. -
Method Summary
Modifier and TypeMethodDescriptionstatic Compression.Leveledbrotli()Brotli at its default quality; seeCompression.Leveled.level(int)for another.codec()The codec page bodies are compressed with.static Compression.Leveledgzip()GZIP at deflate's default level; seeCompression.Leveled.level(int)for another.level()The level the codec compresses at, or empty for its default.static Compression.Leveledlz4Raw()LZ4_RAW through LZ4's fast compressor; seeCompression.Leveled.level(int)for the high compressor.static Compressionof(CompressionCodec codec) The codec at its default level, for a codec chosen at runtime, such as the codec of a file being copied.static Compressionsnappy()Snappy, which has no levels.static CompressionPage bodies stored as they are.static Compression.Leveledzstd()ZSTD at zstd's default level; seeCompression.Leveled.level(int)for another.
-
Method Details
-
codec
CompressionCodec codec()The codec page bodies are compressed with. -
level
OptionalInt level()The level the codec compresses at, or empty for its default. -
uncompressed
Page bodies stored as they are. -
snappy
Snappy, which has no levels. -
gzip
GZIP at deflate's default level; seeCompression.Leveled.level(int)for another. -
zstd
ZSTD at zstd's default level; seeCompression.Leveled.level(int)for another. -
lz4Raw
LZ4_RAW through LZ4's fast compressor; seeCompression.Leveled.level(int)for the high compressor. -
brotli
Brotli at its default quality; seeCompression.Leveled.level(int)for another. -
of
The codec at its default level, for a codec chosen at runtime, such as the codec of a file being copied.- Parameters:
codec- the codec; must be non-null- Returns:
- the compression
- Throws:
IllegalArgumentException- ifcodecisnullUnsupportedOperationException- ifcodecisLZ4, whose Hadoop framing the format has deprecated in favour ofLZ4_RAW, orLZO, which has no maintained JVM implementation; neither is written
-