potoki-core 2.2.15 → 2.2.16
raw patch · 3 files changed
+18/−4 lines, 3 filesdep ~foldl
Dependency ranges changed: foldl
Files
- library/Potoki/Core/Produce.hs +14/−0
- potoki-core.cabal +2/−2
- test/Transform.hs +2/−2
library/Potoki/Core/Produce.hs view
@@ -4,6 +4,7 @@ list, transform, vector,+ vectorWithIndices, hashMapRows, fileBytes, fileBytesAtOffset,@@ -116,6 +117,19 @@ indexVal <- readIORef indexRef writeIORef indexRef $! succ indexVal return $ (GenericVector.!?) vectorVal indexVal+ in return fetch++{-# INLINE vectorWithIndices #-}+vectorWithIndices :: GenericVector.Vector vector a => vector a -> Produce (Int, a)+vectorWithIndices vectorVal =+ Produce $ liftIO $ do+ indexRef <- newIORef 0+ let+ fetch =+ A.Fetch $ do+ indexVal <- readIORef indexRef+ writeIORef indexRef $! succ indexVal+ return $ fmap (indexVal,) $ (GenericVector.!?) vectorVal indexVal in return fetch {-# INLINE hashMapRows #-}
potoki-core.cabal view
@@ -1,5 +1,5 @@ name: potoki-core-version: 2.2.15+version: 2.2.16 synopsis: Low-level components of "potoki" description: Provides everything required for building custom instances of@@ -75,7 +75,7 @@ build-depends: acquire >=0.2 && <0.3, attoparsec,- foldl >=1.3.7 && <1.4,+ foldl >=1.3.7 && <2, ilist >=0.3.1.0 && <0.4, split >=0.2.3.3 && <0.3, potoki-core,
test/Transform.hs view
@@ -21,14 +21,14 @@ transform = testGroup "Transform" $ [- testProperty "Applying chunksOf to list has the same effect as the \"chunk\" transform" $ let+ testProperty "Applying chunksOf to list has the same effect as the \"batch\" transform" $ let gen = do list <- listOf (choose (0, 1000 :: Int)) chunkSize <- frequency [(1000, choose (1, 3)), (100, choose (4, 100)), (1, pure 0)] return (list, chunkSize) in forAll gen $ \ (list, chunkSize) -> let listChunks = if chunkSize < 1 then [] else SplitList.chunksOf chunkSize list- potokiChunks = unsafePerformIO $ C.produceAndTransformAndConsume (E.list list) (rmap toList (A.chunk chunkSize)) D.list+ potokiChunks = unsafePerformIO $ C.produceAndTransformAndConsume (E.list list) (rmap toList (A.batch @Vector chunkSize)) D.list in listChunks === potokiChunks , transformProduce