Quarkus Snappy

Quarkus Snappy provides Snappy compression and decompression for Quarkus applications.

Snappy is a compression/decompression library that provides very fast compression and decompression with a focus on speed over compression ratio.

Installation

Add the extension to your project:

<dependency>
    <groupId>io.quarkiverse.snappy</groupId>
    <artifactId>quarkus-snappy</artifactId>
    <version>0.1.0</version>
</dependency>

Usage

Once the extension is added, Snappy is automatically available in your application.

import org.xerial.snappy.Snappy;

// Compress
byte[] compressed = Snappy.compress(data);

// Decompress
byte[] decompressed = Snappy.uncompress(compressed);

Native Support

The extension bundles native libraries for Linux, macOS, and Windows, enabling Snappy to work in native images without additional configuration.

Configuration

Snappy’s own knobs are exposed as Quarkus configuration properties. A property left unset keeps Snappy’s own default, so a bare application needs none of them. Unlike setting the underlying org.xerial.snappy.* system properties directly, these are honored in native executables.

# Disable the caching buffer pool used by the framed streams
quarkus.snappy.pool-disable=true

# Extract the bundled native library somewhere executable when /tmp is mounted noexec
quarkus.snappy.temp-dir=/var/tmp

Extension Configuration Reference

Configuration property fixed at build time - All other configuration properties are overridable at runtime

Configuration property

Type

Default

Directory to load the native library from instead of extracting the bundled one. Maps to org.xerial.snappy.lib.path.

Environment variable: QUARKUS_SNAPPY_LIB_PATH

string

Name of the native library file to load from lib-path(). Maps to org.xerial.snappy.lib.name.

Environment variable: QUARKUS_SNAPPY_LIB_NAME

string

Directory the bundled native library is extracted to before loading. Defaults to the JVM’s java.io.tmpdir when unset. Useful when the default temporary directory is mounted noexec. Maps to org.xerial.snappy.tempdir.

Environment variable: QUARKUS_SNAPPY_TEMP_DIR

string

java.io.tmpdir

Load a system-installed libsnappyjava instead of the bundled one. The bundled library is still embedded in a native image. Maps to org.xerial.snappy.use.systemlib.

Environment variable: QUARKUS_SNAPPY_USE_SYSTEM_LIB

boolean

false

Disable the caching buffer pool used by the framed streams, selecting the non-caching QuiescentBufferPool. Maps to org.xerial.snappy.pool.disable.

Environment variable: QUARKUS_SNAPPY_POOL_DISABLE

boolean

false