streamly-lz4 0.1.0 → 0.1.1
raw patch · 6 files changed
+32/−24 lines, 6 filesdep ~streamlynew-uploaderPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: streamly
API changes (from Hackage documentation)
Files
- CHANGELOG.md +6/−0
- benchmark/Main.hs +2/−2
- src/Streamly/Internal/LZ4.hs +16/−15
- src/Streamly/LZ4.hs +1/−1
- streamly-lz4.cabal +5/−4
- test/Main.hs +2/−2
CHANGELOG.md view
@@ -1,3 +1,9 @@+# Changelog++## 0.1.1 (Dec 2021)++* Support streamly-0.8.1+ ## 0.1.0 * Initial release
benchmark/Main.hs view
@@ -1,5 +1,5 @@ -- |--- Module : Streamly.Internal.LZ4.Config+-- Module : Main -- Copyright : (c) 2020 Composewell Technologies -- License : Apache-2.0 -- Maintainer : streamly@composewell.com@@ -13,7 +13,7 @@ import Data.Word (Word8) import Data.Function ((&)) import Streamly.Internal.Data.Array.Foreign (Array)-import Streamly.Internal.Data.Stream.StreamD (fromStreamD, toStreamD)+import Streamly.Internal.Data.Stream.IsStream.Type (fromStreamD, toStreamD) import Streamly.Prelude (SerialT) import System.Directory (getCurrentDirectory, doesFileExist) import System.Environment (lookupEnv)
src/Streamly/Internal/LZ4.hs view
@@ -46,7 +46,6 @@ import Data.Int (Int32) import Data.Word (Word32, Word8, byteSwap32) import Foreign.C (CInt(..), CString)-import Foreign.ForeignPtr (plusForeignPtr, withForeignPtr) import Foreign.Ptr (Ptr, castPtr, plusPtr) import Foreign.Storable (peek, poke) import Fusion.Plugin.Types (Fuse (..))@@ -58,6 +57,7 @@ import qualified Streamly.Internal.Data.Parser.ParserD as Parser import qualified Streamly.Internal.Data.Fold as Fold import qualified Streamly.Internal.Data.Stream.StreamD as Stream+import qualified Streamly.Internal.Data.Stream.IsStream as IsStream import qualified Streamly.Internal.Data.Array.Stream.Foreign as ArrayStream import qualified Streamly.Internal.Data.Array.Stream.Fold.Foreign as ArrayFold @@ -247,7 +247,7 @@ $ error $ "compressChunk: compressed length <= 0." ++ " maxCompLenC: " ++ show maxCompLenC ++ " uncompLenC: " ++ show uncompLenC- (MArray.Array fptr dstBegin dstMax) <-+ (MArray.Array cont dstBegin_ dstBegin dstMax) <- MArray.newArray (maxCompLen + metaSize_) let hdrCompLen = dstBegin `plusPtr` compSizeOffset_ compData = dstBegin `plusPtr` dataOffset_@@ -262,10 +262,10 @@ poke hdrCompLen (toLittleEndian (cIntToI32 compLenC)) let compLen = cIntToInt compLenC dstEnd = dstBegin `plusPtr` (compLen + metaSize_)- compArr = MArray.Array fptr dstEnd dstMax+ compArr = MArray.Array cont dstBegin_ dstEnd dstMax -- It is safe to shrink here as we need to hold the last 64KB of -- the previous uncompressed array and not the compressed one.- Array.unsafeFreeze <$> MArray.shrinkToFit compArr+ Array.unsafeFreeze <$> MArray.rightSize compArr where metaSize_ = metaSize cfg@@ -317,7 +317,8 @@ error $ "decompressChunk: compressed data length is more " ++ "than the max limit: " ++ show maxCompLenC - (MArray.Array fptr dstBegin dstMax) <- MArray.newArray uncompLen+ (MArray.Array cont dstBegin_ dstBegin dstMax)+ <- MArray.newArray uncompLen decompLenC <- c_decompressSafeContinue ctx compData dstBegin compLenC uncompLenC@@ -329,7 +330,7 @@ ++ "\ndecompLenC = " ++ show decompLenC let decompLen = cIntToInt decompLenC dstEnd = dstBegin `plusPtr` decompLen- decompArr = MArray.Array fptr dstEnd dstMax+ decompArr = MArray.Array cont dstBegin_ dstEnd dstMax -- We cannot shrink the array here, because that would reallocate -- the array invalidating the cached dictionary. return $ Array.unsafeFreeze decompArr@@ -455,11 +456,11 @@ | otherwise = return False {-# INLINE process #-}- process st arr@(Array.Array fb e) = do+ process st arr@(Array.Array cont b e) = do let len = Array.byteLength arr if len < 4 then return $ Stream.Skip $ RAccumulate st arr- else withForeignPtr fb $ \b -> do+ else do res <- isEndMark b if res then return $ Stream.Skip $ RFooter st arr@@ -477,9 +478,9 @@ then return $ Stream.Skip $ RAccumulate st arr else do let arr1E = b `plusPtr` required- arr1 = Array.Array fb arr1E- arr2S = fb `plusForeignPtr` required- arr2 = Array.Array arr2S e+ arr1 = Array.Array cont b arr1E+ arr2 = Array.Array cont arr1E e+ MArray.touch cont return $ Stream.Skip $ RYield arr1 $ RProcess st arr2 {-# INLINE_LATE step #-}@@ -498,7 +499,7 @@ r <- step0 gst st case r of Stream.Yield arr st1 -> do- arr1 <- Array.spliceTwo buf arr+ arr1 <- Array.splice buf arr liftIO $ process st1 arr1 Stream.Skip st1 -> return $ Stream.Skip $ RAccumulate st1 buf Stream.Stop -> error "resizeChunksD: Incomplete block"@@ -510,7 +511,7 @@ r <- step0 gst st case r of Stream.Yield arr st1 -> do- arr1 <- Array.spliceTwo buf arr+ arr1 <- Array.splice buf arr return $ Stream.Skip $ RFooter st1 arr1 Stream.Skip st1 -> return $ Stream.Skip $ RFooter st1 buf Stream.Stop -> error "resizeChunksD: Incomplete footer"@@ -571,8 +572,8 @@ -> Stream.Stream m (Array.Array Word8) -> Stream.Stream m (Array.Array Word8) decompressChunksWithD p s = do- ((cfg, config), next) <- Stream.fromEffect $ second Stream.toStreamD- <$> ArrayStream.fold_ (ArrayFold.fromParser p) (Stream.fromStreamD s)+ ((cfg, config), next) <- Stream.fromEffect $ second IsStream.toStreamD+ <$> ArrayStream.foldArr_ (ArrayFold.fromParser p) (IsStream.fromStreamD s) decompressChunksRawD cfg (resizeChunksD cfg config next) -- XXX Merge this with BlockConfig?
src/Streamly/LZ4.hs view
@@ -55,8 +55,8 @@ import Control.Monad.IO.Class (MonadIO) import Data.Word (Word8) import Streamly.Internal.Data.Array.Foreign (Array)-import Streamly.Internal.Data.Stream.StreamD (fromStreamD, toStreamD) import Streamly.Prelude (SerialT)+import Streamly.Internal.Data.Stream.IsStream.Type (fromStreamD, toStreamD) import Streamly.Internal.LZ4.Config import Streamly.Internal.LZ4
streamly-lz4.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.2 name: streamly-lz4-version: 0.1.0+version: 0.1.1 synopsis: Streamly combinators for LZ4 compression description: Compress and decompress streams of data using LZ4 compression. See@@ -20,6 +20,7 @@ , GHC==8.8.4 , GHC==8.10.7 , GHC==9.0.1+ , GHC==9.2.1 extra-source-files: CHANGELOG.md , NOTICE , README.md@@ -58,7 +59,7 @@ build-depends: base >= 4 && < 5 , fusion-plugin-types >= 0.1 && < 0.2 , exceptions >= 0.8 && < 0.11- , streamly >= 0.8 && < 0.9+ , streamly >= 0.8.1 && < 0.8.2 ghc-options: -Wall default-language: Haskell2010 default-extensions:@@ -76,7 +77,7 @@ hs-source-dirs: test main-is: Main.hs build-depends: streamly-lz4- , streamly >= 0.8 && < 0.9+ , streamly >= 0.8.1 && < 0.8.2 , base >= 4 && < 5 , QuickCheck >= 2.13.1 && < 2.15 , hspec >= 2.7 && < 2.9@@ -91,7 +92,7 @@ hs-source-dirs: benchmark main-is: Main.hs build-depends: streamly-lz4- , streamly >= 0.8 && < 0.9+ , streamly >= 0.8.1 && < 0.8.2 , base >= 4 && < 5 , gauge >= 0.2.5 && < 0.2.6 , directory >= 1.3.0 && < 1.3.8
test/Main.hs view
@@ -1,5 +1,5 @@ -- |--- Module : Streamly.Internal.LZ4.Config+-- Module : Main -- Copyright : (c) 2020 Composewell Technologies -- License : Apache-2.0 -- Maintainer : streamly@composewell.com@@ -12,7 +12,7 @@ import Control.Monad.IO.Class (MonadIO(..)) import Data.Word (Word8) import Data.Function ((&))-import Streamly.Internal.Data.Stream.StreamD (fromStreamD, toStreamD)+import Streamly.Internal.Data.Stream.IsStream.Type (fromStreamD, toStreamD) import System.IO (IOMode(..), openFile, hClose) import System.IO.Temp (withSystemTempFile) import Test.Hspec (describe, hspec, it, shouldBe)