streamly-lz4-0.1.2: Streamly combinators for LZ4 compression
Copyright(c) 2020 Composewell Technologies
LicenseApache-2.0
Maintainerstreamly@composewell.com
Stabilityexperimental
PortabilityGHC
Safe HaskellNone
LanguageHaskell2010

Streamly.Internal.LZ4

Description

LZ4 compression and decompression routines.

Synopsis

Foreign

c_createStream :: IO (Ptr C_LZ4Stream) Source #

Exported for unit tests

c_freeStream :: Ptr C_LZ4Stream -> IO () Source #

Exported for unit tests

c_createStreamDecode :: IO (Ptr C_LZ4StreamDecode) Source #

Exported for unit tests

c_freeStreamDecode :: Ptr C_LZ4StreamDecode -> IO () Source #

Exported for unit tests

Block compression and decompression

compressChunk :: BlockConfig -> Int -> Ptr C_LZ4Stream -> Array Word8 -> IO (Array Word8) Source #

Compress an array of Word8. The compressed block header depends on the BlockConfig setting.

decompressChunk :: BlockConfig -> Ptr C_LZ4StreamDecode -> Array Word8 -> IO (Array Word8) Source #

Primitive function to decompress a chunk of Word8.

Stream compression and decompression

compressChunksD :: MonadIO m => BlockConfig -> Int -> Stream m (Array Word8) -> Stream m (Array Word8) Source #

See compress for documentation.

resizeChunksD :: MonadIO m => BlockConfig -> FrameConfig -> Stream m (Array Word8) -> Stream m (Array Word8) Source #

Look for a compressed block header and compact the arrays in the input stream to the compressed length specified in the header. The output contains arrays, where each array represents a full single compressed block along with the compression header.

The resize operation is idempotent:

resizeChunksD . resizeChunksD = resizeChunksD

decompressChunksRawD :: MonadIO m => BlockConfig -> Stream m (Array Word8) -> Stream m (Array Word8) Source #

This combinator assumes all the arrays in the incoming stream are properly resized.

This combinator works well with untouched arrays compressed with compressChunksD. A random compressed stream would first need to be resized properly with resizeChunksD.

decompressChunksWithD :: (MonadThrow m, MonadIO m) => Parser m Word8 (BlockConfig, FrameConfig) -> Stream m (Array Word8) -> Stream m (Array Word8) Source #

Parsing LZ4 Frames