Interface Compression

All Known Implementing Classes:
Compression.Fixed, Compression.Leveled

public sealed interface Compression permits 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.