Copyright | (c) 2020 Composewell Technologies |
---|---|
License | Apache-2.0 |
Maintainer | streamly@composewell.com |
Stability | experimental |
Portability | GHC |
Safe Haskell | None |
Language | Haskell2010 |
LZ4 compression and decompression routines.
Synopsis
- c_createStream :: IO (Ptr C_LZ4Stream)
- c_freeStream :: Ptr C_LZ4Stream -> IO ()
- c_createStreamDecode :: IO (Ptr C_LZ4StreamDecode)
- c_freeStreamDecode :: Ptr C_LZ4StreamDecode -> IO ()
- compressChunk :: BlockConfig -> Int -> Ptr C_LZ4Stream -> Array Word8 -> IO (Array Word8)
- decompressChunk :: BlockConfig -> Ptr C_LZ4StreamDecode -> Array Word8 -> IO (Array Word8)
- compressChunksD :: MonadIO m => BlockConfig -> Int -> Stream m (Array Word8) -> Stream m (Array Word8)
- resizeChunksD :: MonadIO m => BlockConfig -> FrameConfig -> Stream m (Array Word8) -> Stream m (Array Word8)
- decompressChunksRawD :: MonadIO m => BlockConfig -> Stream m (Array Word8) -> Stream m (Array Word8)
- decompressChunksWithD :: (MonadThrow m, MonadIO m) => Parser m Word8 (BlockConfig, FrameConfig) -> Stream m (Array Word8) -> Stream m (Array Word8)
- simpleFrameParserD :: (Monad m, MonadThrow m) => Parser m Word8 (BlockConfig, FrameConfig)
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
simpleFrameParserD :: (Monad m, MonadThrow m) => Parser m Word8 (BlockConfig, FrameConfig) Source #