Compression

sealed trait Compression[F[_]] extends CompressionPlatform[F]

Provides the capability to compress/decompress using deflate and gzip. On JVM an instance is available given a Sync[F]. On Node.js an instance is available for Async[F] by importing fs2.io.compression._.

Companion:
object
trait CompressionPlatform[F]
class Object
trait Matchable
class Any

Value members

Abstract methods

def deflate(deflateParams: DeflateParams): (F, Byte) => Byte
def inflate(inflateParams: InflateParams): (F, Byte) => Byte

Inherited methods

def gunzip(inflateParams: InflateParams): Stream[F, Byte] => Stream[F, GunzipResult[F]]

Returns a pipe that incrementally decompresses input according to the GZIP format as defined by RFC 1952 at https://www.ietf.org/rfc/rfc1952.txt. Any errors in decompression will be sequenced as exceptions into the output stream. Decompression is handled in a streaming and async fashion without any thread blockage.

Returns a pipe that incrementally decompresses input according to the GZIP format as defined by RFC 1952 at https://www.ietf.org/rfc/rfc1952.txt. Any errors in decompression will be sequenced as exceptions into the output stream. Decompression is handled in a streaming and async fashion without any thread blockage.

The chunk size here is actually really important. Matching the input stream largest chunk size, or roughly 8 KB (whichever is larger) is a good rule of thumb.

Value parameters:
inflateParams

See compression.InflateParams

Returns:

See compression.GunzipResult

Inherited from:
CompressionPlatform
def gunzip(bufferSize: Int): Stream[F, Byte] => Stream[F, GunzipResult[F]]

Returns a pipe that incrementally decompresses input according to the GZIP format as defined by RFC 1952 at https://www.ietf.org/rfc/rfc1952.txt. Any errors in decompression will be sequenced as exceptions into the output stream. Decompression is handled in a streaming and async fashion without any thread blockage.

Returns a pipe that incrementally decompresses input according to the GZIP format as defined by RFC 1952 at https://www.ietf.org/rfc/rfc1952.txt. Any errors in decompression will be sequenced as exceptions into the output stream. Decompression is handled in a streaming and async fashion without any thread blockage.

The chunk size here is actually really important. Matching the input stream largest chunk size, or roughly 8 KB (whichever is larger) is a good rule of thumb.

Value parameters:
bufferSize

The bounding size of the input buffer. This should roughly match the size of the largest chunk in the input stream. This will also be the chunk size in the output stream. Default size is 32 KB.

Returns:

See compression.GunzipResult

Inherited from:
CompressionPlatform
def gzip(fileName: Option[String], modificationTime: Option[Instant], comment: Option[String], deflateParams: DeflateParams): (F, Byte) => Byte

Returns a pipe that incrementally compresses input into the GZIP format as defined by RFC 1952 at https://www.ietf.org/rfc/rfc1952.txt. Output is compatible with the GNU utils gunzip utility, as well as really anything else that understands GZIP. Note, however, that the GZIP format is not "stable" in the sense that all compressors will produce identical output given identical input. Part of the header seeding is arbitrary and chosen by the compression implementation. For this reason, the exact bytes produced by this pipe will differ in insignificant ways from the exact bytes produced by a tool like the GNU utils gzip.

Returns a pipe that incrementally compresses input into the GZIP format as defined by RFC 1952 at https://www.ietf.org/rfc/rfc1952.txt. Output is compatible with the GNU utils gunzip utility, as well as really anything else that understands GZIP. Note, however, that the GZIP format is not "stable" in the sense that all compressors will produce identical output given identical input. Part of the header seeding is arbitrary and chosen by the compression implementation. For this reason, the exact bytes produced by this pipe will differ in insignificant ways from the exact bytes produced by a tool like the GNU utils gzip.

GZIP wraps a deflate stream with file attributes and stream integrity validation. Therefore, GZIP is a good choice for compressing finite, complete, readily-available, continuous or file streams. A simpler deflate stream may be better suited to real-time, intermittent, fragmented, interactive or discontinuous streams where network protocols typically provide stream integrity validation.

Value parameters:
comment

optional file comment

deflateParams

see compression.DeflateParams

fileName

optional file name

modificationTime

optional file modification time

Inherited from:
CompressionPlatform
def gzip(bufferSize: Int, deflateLevel: Option[Int], deflateStrategy: Option[Int], modificationTime: Option[Instant], fileName: Option[String], comment: Option[String]): (F, Byte) => Byte

Returns a pipe that incrementally compresses input into the GZIP format as defined by RFC 1952 at https://www.ietf.org/rfc/rfc1952.txt. Output is compatible with the GNU utils gunzip utility, as well as really anything else that understands GZIP. Note, however, that the GZIP format is not "stable" in the sense that all compressors will produce identical output given identical input. Part of the header seeding is arbitrary and chosen by the compression implementation. For this reason, the exact bytes produced by this pipe will differ in insignificant ways from the exact bytes produced by a tool like the GNU utils gzip.

Returns a pipe that incrementally compresses input into the GZIP format as defined by RFC 1952 at https://www.ietf.org/rfc/rfc1952.txt. Output is compatible with the GNU utils gunzip utility, as well as really anything else that understands GZIP. Note, however, that the GZIP format is not "stable" in the sense that all compressors will produce identical output given identical input. Part of the header seeding is arbitrary and chosen by the compression implementation. For this reason, the exact bytes produced by this pipe will differ in insignificant ways from the exact bytes produced by a tool like the GNU utils gzip.

GZIP wraps a deflate stream with file attributes and stream integrity validation. Therefore, GZIP is a good choice for compressing finite, complete, readily-available, continuous or file streams. A simpler deflate stream may be better suited to real-time, intermittent, fragmented, interactive or discontinuous streams where network protocols typically provide stream integrity validation.

Value parameters:
bufferSize

The buffer size which will be used to page data into chunks. This will be the chunk size of the output stream. You should set it to be equal to the size of the largest chunk in the input stream. Setting this to a size which is ''smaller'' than the chunks in the input stream will result in performance degradation of roughly 50-75%. Default size is 32 KB.

comment

optional file comment

deflateLevel

level the compression level (0-9)

deflateStrategy

strategy compression strategy -- see java.util.zip.Deflater for details

fileName

optional file name

modificationTime

optional file modification time

Inherited from:
CompressionPlatform