public interface Compression
| Modifier and Type | Method and Description |
|---|---|
default boolean |
available()
Indicates whether compression/decompression is available.
|
default byte[] |
compress(byte[] bytes)
Compresses a byte array using the streams returned by
compressingStream(OutputStream). |
default void |
compress(@NotNull BytesIn<?> from,
@NotNull BytesOut<?> to)
Compresses data from
from to to using this implementation's
algorithm. |
static void |
compress(@NotNull CharSequence cs,
@NotNull Bytes<?> uncompressed,
@NotNull Bytes<?> compressed)
Compresses
uncompressed into compressed using the named algorithm. |
OutputStream |
compressingStream(OutputStream output)
Returns a new
OutputStream that compresses any bytes written to it
using this algorithm's strategy. |
InputStream |
decompressingStream(InputStream input)
Returns a new
InputStream that wraps input and will
decompress bytes as they are read. |
default byte[] |
uncompress(byte[] bytes)
Uncompresses a byte array using the stream returned by
decompressingStream(InputStream). |
default void |
uncompress(@NotNull BytesIn<?> from,
@NotNull BytesOut<?> to)
Uncompresses data from the input to the output using the implementing uncompression algorithm.
|
static void |
uncompress(@NotNull CharSequence cs,
@NotNull BytesIn<?> from,
@NotNull BytesOut<?> to)
Decompresses data using the named algorithm.
|
static <T> byte[] |
uncompress(@NotNull CharSequence cs,
T t,
@NotNull net.openhft.chronicle.core.util.ThrowingFunction<T,byte[],net.openhft.chronicle.core.io.IORuntimeException> bytes)
Uncompresses data using the specified algorithm and a custom function to read bytes.
|
static void compress(@NotNull
@NotNull CharSequence cs,
@NotNull
@NotNull Bytes<?> uncompressed,
@NotNull
@NotNull Bytes<?> compressed)
throws IllegalStateException,
BufferOverflowException
uncompressed into compressed using the named algorithm.
Unrecognised names cause a fall back to Compressions.Binary which performs no compression.
Supported aliases are "lzw" and "gzip".cs - the algorithm name, must not be nulluncompressed - the input data to compresscompressed - the destination buffer for compressed dataBufferOverflowException - If there is not enough space in the output buffer.net.openhft.chronicle.core.io.ClosedIllegalStateException - If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionstatic void uncompress(@NotNull
@NotNull CharSequence cs,
@NotNull
@NotNull BytesIn<?> from,
@NotNull
@NotNull BytesOut<?> to)
throws net.openhft.chronicle.core.io.IORuntimeException,
IllegalArgumentException,
IllegalStateException,
BufferOverflowException
"!binary" behaves
the same as "binary". Any other unrecognised name results in an
IllegalArgumentException.cs - the algorithm name, must not be nullfrom - the input compressed datato - the destination for decompressed bytesnet.openhft.chronicle.core.io.IORuntimeException - If an I/O error occurs.IllegalArgumentException - If the algorithm is unsupported.BufferOverflowException - If there is not enough space in the output buffer.net.openhft.chronicle.core.io.ClosedIllegalStateException - If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionstatic <T> byte[] uncompress(@NotNull
@NotNull CharSequence cs,
T t,
@NotNull
@NotNull net.openhft.chronicle.core.util.ThrowingFunction<T,byte[],net.openhft.chronicle.core.io.IORuntimeException> bytes)
throws net.openhft.chronicle.core.io.IORuntimeException
cs - The compression algorithm to be used (e.g. "lzw", "gzip").t - The input data.bytes - A function to read bytes from the input data.net.openhft.chronicle.core.io.IORuntimeException - If an I/O error occurs.default byte[] compress(byte[] bytes)
compressingStream(OutputStream).bytes - the input bytes to compressAssertionError - if an unexpected IOException occursdefault void compress(@NotNull
@NotNull BytesIn<?> from,
@NotNull
@NotNull BytesOut<?> to)
throws IllegalStateException,
BufferOverflowException
from to to using this implementation's
algorithm. The stream wrappers originate from
compressingStream(OutputStream). Unexpected I/O issues are
wrapped in an AssertionError as the streams are memory based.from - The input data to be compressed.to - The output to write the compressed data.BufferOverflowException - If there is not enough space in the output buffer.net.openhft.chronicle.core.io.ClosedIllegalStateException - If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptiondefault byte[] uncompress(byte[] bytes)
throws net.openhft.chronicle.core.io.IORuntimeException
decompressingStream(InputStream).bytes - the compressed datanet.openhft.chronicle.core.io.IORuntimeException - if an I/O error occurs while reading the datadefault void uncompress(@NotNull
@NotNull BytesIn<?> from,
@NotNull
@NotNull BytesOut<?> to)
throws net.openhft.chronicle.core.io.IORuntimeException,
IllegalStateException,
BufferOverflowException
from - The input compressed data.to - The output to write the uncompressed data.net.openhft.chronicle.core.io.IORuntimeException - If an I/O error occurs.BufferOverflowException - If there is not enough space in the output buffer.net.openhft.chronicle.core.io.ClosedIllegalStateException - If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionInputStream decompressingStream(InputStream input) throws net.openhft.chronicle.core.io.IORuntimeException
InputStream that wraps input and will
decompress bytes as they are read. The caller is responsible for closing
the returned stream. Closing the wrapper does not close the underlying
input stream. Future implementations may buffer the input and
callers should not depend on the concrete type of the returned stream.input - the underlying stream supplying compressed datanet.openhft.chronicle.core.io.IORuntimeException - if an I/O error occursOutputStream compressingStream(OutputStream output)
OutputStream that compresses any bytes written to it
using this algorithm's strategy. The caller must close the returned stream
to flush all data. Closing it does not close output. The returned
stream may be wrapped in additional buffering and its exact class is not
guaranteed.output - the underlying stream to receive compressed datadefault boolean available()
Copyright © 2026 Chronicle Software Ltd. All rights reserved.