lz4-frame-conduit-0.1.0.1: Conduit implementing the official LZ4 frame streaming format

Safe HaskellNone
LanguageHaskell2010

Codec.Compression.LZ4.Conduit

Contents

Description

TODO: Implement:

  • Block checksumming
  • Dictionary support
Synopsis

Documentation

data ContentChecksum Source #

data FrameInfo Source #

Constructors

FrameInfo 

Fields

compressYieldImmediately :: (MonadUnliftIO m, MonadResource m) => ConduitT ByteString ByteString m () Source #

Compresses the incoming stream of ByteStrings with the lz4 frame format.

Yields every LZ4 output as a ByteString as soon as the lz4 frame library produces it.

Note that this does not imply ZL4 frame autoFlush (which affects when the lz4 frame library produces outputs).

compressWithOutBufferSize :: forall m. (MonadUnliftIO m, MonadResource m) => CSize -> ConduitT ByteString ByteString m () Source #

Compresses the incoming stream of ByteStrings with the lz4 frame format.

This function implements two optimisations to reduce unnecessary allocations:

  • Incoming ByteStrings are processed in blocks of 16 KB, allowing us to use a single intermediate output buffer through the lifetime of the conduit.
  • The bufferSize of the output buffer can controlled by the caller via the bufferSize argument, to reduce the number of small ByteStrings being yielded (especially in the case that the input data compresses very well, e.g. a stream of zeros).

Note that the given bufferSize is not a hard limit, it can only be used to *increase* the amount of output buffer we're allowed to use: The function will choose `max(bufferSize, minBufferSizeNeededByLz4)` as the eventual output buffer size.

Setting `bufferSize = 0` is the legitimate way to set the output buffer size to be the minimum required to compress 16 KB inputs and is still a fast default.

Internals

newtype ScopedLz4FrameCompressionContext Source #