Copyright | (c) 2019 Composewell Technologies |
---|---|
License | BSD3-3-Clause |
Maintainer | streamly@composewell.com |
Stability | experimental |
Portability | GHC |
Safe Haskell | None |
Language | Haskell2010 |
Combinators to efficiently manipulate streams of mutable arrays.
Synopsis
- arraysOf :: (IsStream t, MonadIO m, Storable a) => Int -> t m a -> t m (Array a)
- packArraysChunksOf :: (MonadIO m, Storable a) => Int -> Stream m (Array a) -> Stream m (Array a)
- data SpliceState s arr
- = SpliceInitial s
- | SpliceBuffering s arr
- | SpliceYielding arr (SpliceState s arr)
- | SpliceFinish
- lpackArraysChunksOf :: (MonadIO m, Storable a) => Int -> Fold m (Array a) () -> Fold m (Array a) ()
- groupIOVecsOf :: MonadIO m => Int -> Int -> Stream m (Array a) -> Stream m (Array IOVec)
- compact :: (MonadIO m, Storable a) => Int -> SerialT m (Array a) -> SerialT m (Array a)
- compactLE :: MonadIO m => Int -> SerialT m (Array a) -> SerialT m (Array a)
- compactEQ :: Int -> SerialT m (Array a) -> SerialT m (Array a)
- compactGE :: Int -> SerialT m (Array a) -> SerialT m (Array a)
Generation
arraysOf :: (IsStream t, MonadIO m, Storable a) => Int -> t m a -> t m (Array a) Source #
arraysOf n stream
groups the elements in the input stream into arrays of
n
elements each.
Same as the following but may be more efficient:
arraysOf n = Stream.foldMany (MArray.writeN n)
Pre-release
Compaction
packArraysChunksOf :: (MonadIO m, Storable a) => Int -> Stream m (Array a) -> Stream m (Array a) Source #
This mutates the first array (if it has space) to append values from the second one. This would work for immutable arrays as well because an immutable array never has space so a new array is allocated instead of mutating it.
| Coalesce adjacent arrays in incoming stream to form bigger arrays of a maximum specified size. Note that if a single array is bigger than the specified size we do not split it to fit. When we coalesce multiple arrays if the size would exceed the specified size we do not coalesce therefore the actual array size may be less than the specified chunk size.
Since: 0.7.0
data SpliceState s arr Source #
SpliceInitial s | |
SpliceBuffering s arr | |
SpliceYielding arr (SpliceState s arr) | |
SpliceFinish |
lpackArraysChunksOf :: (MonadIO m, Storable a) => Int -> Fold m (Array a) () -> Fold m (Array a) () Source #
groupIOVecsOf :: MonadIO m => Int -> Int -> Stream m (Array a) -> Stream m (Array IOVec) Source #
groupIOVecsOf maxBytes maxEntries
groups arrays in the incoming stream
to create a stream of IOVec
arrays with a maximum of maxBytes
bytes in
each array and a maximum of maxEntries
entries in each array.
Since: 0.7.0
compact :: (MonadIO m, Storable a) => Int -> SerialT m (Array a) -> SerialT m (Array a) Source #
Coalesce adjacent arrays in incoming stream to form bigger arrays of a maximum specified size in bytes.
Since: 0.7.0