Class CompressionCodec

java.lang.Object
dev.frostlake.functions.scalar.encoding.CompressionCodec

public final class CompressionCodec extends Object
The four compression algorithms behind COMPRESS / DECOMPRESS_STRING / DECOMPRESS_BINARY.

Byte fidelity against a live Snowflake account (probed, see CompressionByteFidelityTest for the captured values):

  • snappy — byte-identical (raw Snappy block format, no framing).
  • zlib — byte-identical on every probed input at the default level and at levels 2-9; level 1 and some longer inputs differ because Snowflake's deflate implementation makes different match choices. The output is always a well-formed zlib stream either way.
  • zstd — byte-identical at the default level once the frame's content checksum is stripped (see stripZstdContentChecksum(byte[])); Snowflake does not emit one and aircompressor always does. Explicit levels are accepted but cannot be honoured — aircompressor exposes no level knob — so zstd(19) produces the default-level frame. Still round-trip compatible in both directions.
  • bz2 — round-trip compatible only, never byte-identical: aircompressor's Huffman table selection differs from Snowflake's, and its block size is fixed at 9 whereas Snowflake defaults to 5. Verified live that Snowflake decompresses our BZh9 output and that we decompress its BZh5 output.
  • Method Details

    • compress

      public static byte[] compress(byte[] input, CompressionMethod method)
    • decompress

      public static byte[] decompress(byte[] compressed, CompressionMethod method)