leveldb-haskell-0.4.1: Haskell bindings to LevelDB

Copyright(c) 2012-2013 The leveldb-haskell Authors
LicenseBSD3
Maintainerkim.altintop@gmail.com
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Database.LevelDB.Iterator

Description

Iterating over key ranges.

Synopsis

Documentation

data Iterator Source

Iterator handle

Note that an Iterator requires external synchronization if it is shared between multiple threads which mutate it's state. See examples/iterforkio.hs for a simple example of how to do that.

Instances

createIter :: MonadIO m => DB -> ReadOptions -> m Iterator Source

Create an Iterator.

The iterator should be released with releaseIter.

Note that an Iterator creates a snapshot of the database implicitly, so updates written after the iterator was created are not visible. You may, however, specify an older Snapshot in the ReadOptions.

iterEntry :: MonadIO m => Iterator -> m (Maybe (BS.ByteString, BS.ByteString)) Source

Return the current entry as a pair, if the iterator is currently positioned at an entry, ie. iterValid.

iterFirst :: MonadIO m => Iterator -> m () Source

Position at the first key in the source. The iterator is valid after this call iff the source is not empty.

iterGetError :: MonadIO m => Iterator -> m (Maybe BS.ByteString) Source

Check for errors

Note that this captures somewhat severe errors such as a corrupted database.

iterKey :: MonadIO m => Iterator -> m (Maybe BS.ByteString) Source

Return the key for the current entry if the iterator is currently positioned at an entry, ie. iterValid.

iterLast :: MonadIO m => Iterator -> m () Source

Position at the last key in the source. The iterator is valid after this call iff the source is not empty.

iterNext :: MonadIO m => Iterator -> m () Source

Moves to the next entry in the source. After this call, iterValid is true iff the iterator was not positioned at the last entry in the source.

If the iterator is not valid, this function does nothing. Note that this is a shortcoming of the C API: an iterPrev might still be possible, but we can't determine if we're at the last or first entry.

iterPrev :: MonadIO m => Iterator -> m () Source

Moves to the previous entry in the source. After this call, iterValid is true iff the iterator was not positioned at the first entry in the source.

If the iterator is not valid, this function does nothing. Note that this is a shortcoming of the C API: an iterNext might still be possible, but we can't determine if we're at the last or first entry.

iterSeek :: MonadIO m => Iterator -> BS.ByteString -> m () Source

Position at the first key in the source that is at or past target. The iterator is valid after this call iff the source contains an entry that comes at or past target.

iterValid :: MonadIO m => Iterator -> m Bool Source

An iterator is either positioned at a key/value pair, or not valid. This function returns true iff the iterator is valid.

iterValue :: MonadIO m => Iterator -> m (Maybe BS.ByteString) Source

Return the value for the current entry if the iterator is currently positioned at an entry, ie. iterValid.

releaseIter :: MonadIO m => Iterator -> m () Source

Release an Iterator.

The handle will be invalid after calling this action and should no longer be used. Calling this function with an already released Iterator will cause a double-free error!

withIter :: (MonadMask m, MonadIO m) => DB -> ReadOptions -> (Iterator -> m a) -> m a Source

Run an action with an Iterator