Copyright | (c) 2014 Kim Altintop |
---|---|
License | BSD3 |
Maintainer | kim.altintop@gmail.com |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
High-level, Data.List-like, streaming interface to Database.LevelDB.Iterator.
This module contains types and functions to construct Stream
s from
Iterator
s, and re-exports the functions operating
on Stream
s from Data.Stream.Monadic.
Note that most of the functions from the latter module are (intentionally) conflicting with the Prelude, it is thus recommended to import this module qualified:
import Database.LevelDB -- or Database.LevelDB.Base import qualified Database.LevelDB.Streaming as S
- data Slice = Slice !Iterator (Maybe KeyRange) !Direction
- data KeyRange
- = KeyRange {
- start :: !ByteString
- end :: ByteString -> Ordering
- | AllKeys
- = KeyRange {
- data Direction
- type Key = ByteString
- type Value = ByteString
- type Entry = (Key, Value)
- keySlice :: (Applicative m, MonadIO m) => Iterator -> KeyRange -> Direction -> Stream m Key
- entrySlice :: (Applicative m, MonadIO m) => Iterator -> KeyRange -> Direction -> Stream m Entry
- module Data.Stream.Monadic
Documentation
KeyRange | |
| |
AllKeys |
type Key = ByteString Source
type Value = ByteString Source
Constructing streams
keySlice :: (Applicative m, MonadIO m) => Iterator -> KeyRange -> Direction -> Stream m Key Source
Create a Stream
which yields only the keys of the given KeyRange
(in
the given Direction
).
Since traversing the Stream
mutates the state of the underlying Iterator
,
it is obviously unsafe to share the latter (between threads, or when
zip
ping). Hence, it is highly recommended to create
a new Iterator
for each Stream
.
entrySlice :: (Applicative m, MonadIO m) => Iterator -> KeyRange -> Direction -> Stream m Entry Source
Create a Stream
which yields key/value pairs of the given KeyRange
(in
the given Direction
).
Since traversing the Stream
mutates the state of the underlying Iterator
,
it is obviously unsafe to share the latter (between threads, or when
zip
ping). Hence, it is highly recommended to create
a new Iterator
for each Stream
.
Re-exports
module Data.Stream.Monadic