Copyright | (c) 2012-2013 The leveldb-haskell Authors (c) 2014 The rocksdb-haskell Authors |
---|---|
License | BSD3 |
Maintainer | [email protected] |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Database.RocksDB.Base
Description
RocksDB Haskell binding.
The API closely follows the C-API of RocksDB. For more information, see: http://agrafix.net
Synopsis
- data DB
- data BatchOp
- newtype Comparator = Comparator (ByteString -> ByteString -> Ordering)
- data Compression
- data Options = Options {
- comparator :: !(Maybe Comparator)
- compression :: !Compression
- createIfMissing :: !Bool
- errorIfExists :: !Bool
- maxOpenFiles :: !Int
- paranoidChecks :: !Bool
- writeBufferSize :: !Int
- data ReadOptions = ReadOptions {
- verifyCheckSums :: !Bool
- fillCache :: !Bool
- useSnapshot :: !(Maybe Snapshot)
- data Snapshot
- type WriteBatch = [BatchOp]
- data WriteOptions = WriteOptions {}
- type Range = (ByteString, ByteString)
- defaultOptions :: Options
- defaultReadOptions :: ReadOptions
- defaultWriteOptions :: WriteOptions
- open :: MonadIO m => FilePath -> Options -> m DB
- openBracket :: MonadResource m => FilePath -> Options -> m (ReleaseKey, DB)
- close :: MonadIO m => DB -> m ()
- put :: MonadIO m => DB -> WriteOptions -> ByteString -> ByteString -> m ()
- putBinaryVal :: (MonadIO m, Binary v) => DB -> WriteOptions -> ByteString -> v -> m ()
- putBinary :: (MonadIO m, Binary k, Binary v) => DB -> WriteOptions -> k -> v -> m ()
- delete :: MonadIO m => DB -> WriteOptions -> ByteString -> m ()
- write :: MonadIO m => DB -> WriteOptions -> WriteBatch -> m ()
- get :: MonadIO m => DB -> ReadOptions -> ByteString -> m (Maybe ByteString)
- getBinary :: (MonadIO m, Binary k, Binary v) => DB -> ReadOptions -> k -> m (Maybe v)
- getBinaryVal :: (Binary v, MonadIO m) => DB -> ReadOptions -> ByteString -> m (Maybe v)
- withSnapshot :: MonadIO m => DB -> (Snapshot -> IO a) -> m a
- withSnapshotBracket :: MonadResource m => DB -> (Snapshot -> m a) -> m a
- createSnapshot :: MonadIO m => DB -> m Snapshot
- releaseSnapshot :: MonadIO m => DB -> Snapshot -> m ()
- data FilterPolicy = FilterPolicy {
- fpName :: String
- createFilter :: [ByteString] -> ByteString
- keyMayMatch :: ByteString -> ByteString -> Bool
- data BloomFilter
- createBloomFilter :: MonadIO m => Int -> m BloomFilter
- releaseBloomFilter :: MonadIO m => BloomFilter -> m ()
- bloomFilter :: MonadResource m => Int -> m BloomFilter
- data Property
- getProperty :: MonadIO m => DB -> Property -> m (Maybe ByteString)
- destroy :: MonadIO m => FilePath -> Options -> m ()
- repair :: MonadIO m => FilePath -> Options -> m ()
- approximateSize :: MonadIO m => DB -> Range -> m Int64
- module Database.RocksDB.Iterator
Exported Types
Database handle
newtype Comparator Source #
User-defined comparator
Constructors
Comparator (ByteString -> ByteString -> Ordering) |
data Compression Source #
Compression setting
Constructors
NoCompression | |
SnappyCompression | |
ZlibCompression |
Instances
Show Compression Source # | |
Defined in Database.RocksDB.Types Methods showsPrec :: Int -> Compression -> ShowS # show :: Compression -> String # showList :: [Compression] -> ShowS # | |
Eq Compression Source # | |
Defined in Database.RocksDB.Types |
Options when opening a database
Constructors
Options | |
Fields
|
data ReadOptions Source #
Options for read operations
Constructors
ReadOptions | |
Fields
|
Instances
Default ReadOptions Source # | |
Defined in Database.RocksDB.Types Methods def :: ReadOptions # | |
Eq ReadOptions Source # | |
Defined in Database.RocksDB.Types |
Snapshot handle
type WriteBatch = [BatchOp] Source #
data WriteOptions Source #
Options for write operations
Constructors
WriteOptions | |
Fields
|
Instances
Show WriteOptions Source # | |
Defined in Database.RocksDB.Types Methods showsPrec :: Int -> WriteOptions -> ShowS # show :: WriteOptions -> String # showList :: [WriteOptions] -> ShowS # | |
Default WriteOptions Source # | |
Defined in Database.RocksDB.Types Methods def :: WriteOptions # | |
Eq WriteOptions Source # | |
Defined in Database.RocksDB.Types |
type Range = (ByteString, ByteString) Source #
Defaults
Basic Database Manipulations
open :: MonadIO m => FilePath -> Options -> m DB Source #
Open a database.
The returned handle should be released with close
.
openBracket :: MonadResource m => FilePath -> Options -> m (ReleaseKey, DB) Source #
Open a database
The returned handle will automatically be released when the enclosing
runResourceT
terminates.
close :: MonadIO m => DB -> m () Source #
Close a database.
The handle will be invalid after calling this action and should no longer be used.
put :: MonadIO m => DB -> WriteOptions -> ByteString -> ByteString -> m () Source #
Write a key/value pair.
putBinaryVal :: (MonadIO m, Binary v) => DB -> WriteOptions -> ByteString -> v -> m () Source #
delete :: MonadIO m => DB -> WriteOptions -> ByteString -> m () Source #
Delete a key/value pair.
write :: MonadIO m => DB -> WriteOptions -> WriteBatch -> m () Source #
Perform a batch mutation.
get :: MonadIO m => DB -> ReadOptions -> ByteString -> m (Maybe ByteString) Source #
Read a value by key.
getBinaryVal :: (Binary v, MonadIO m) => DB -> ReadOptions -> ByteString -> m (Maybe v) Source #
withSnapshot :: MonadIO m => DB -> (Snapshot -> IO a) -> m a Source #
Run an action with a Snapshot
of the database.
withSnapshotBracket :: MonadResource m => DB -> (Snapshot -> m a) -> m a Source #
Run an action with a snapshot of the database.
The snapshot will be released when the action terminates or throws an
exception. Note that this function is provided for convenience and does not
prevent the Snapshot
handle to escape. It will, however, be invalid after
this function returns and should not be used anymore.
createSnapshot :: MonadIO m => DB -> m Snapshot Source #
Create a snapshot of the database.
The returned Snapshot
should be released with releaseSnapshot
.
releaseSnapshot :: MonadIO m => DB -> Snapshot -> m () Source #
Release a snapshot.
The handle will be invalid after calling this action and should no longer be used.
Filter Policy / Bloom Filter
data FilterPolicy Source #
User-defined filter policy
Constructors
FilterPolicy | |
Fields
|
data BloomFilter Source #
Represents the built-in Bloom Filter
createBloomFilter :: MonadIO m => Int -> m BloomFilter Source #
releaseBloomFilter :: MonadIO m => BloomFilter -> m () Source #
bloomFilter :: MonadResource m => Int -> m BloomFilter Source #
Create a BloomFilter
Administrative Functions
Properties exposed by RocksDB
Constructors
NumFilesAtLevel Int | |
Stats | |
SSTables |
getProperty :: MonadIO m => DB -> Property -> m (Maybe ByteString) Source #
Get a DB property.
approximateSize :: MonadIO m => DB -> Range -> m Int64 Source #
Inspect the approximate sizes of the different levels.
Iteration
module Database.RocksDB.Iterator