Copyright | (c) 2021 Francisco Vallarino |
---|---|
License | BSD-3-Clause (see the LICENSE file) |
Maintainer | fjvallarino@gmail.com |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Low level bindings to libmdbx functions.
Synopsis
- data MdbxEnvFlags
- newtype MdbxEnv = MdbxEnv (Ptr MdbxEnv)
- type MdbxEnvMode = CUInt
- mdbx_env_create :: IO (Int, MdbxEnv)
- mdbx_env_set_geometry :: MdbxEnv -> Int -> Int -> Int -> Int -> Int -> Int -> IO Int
- mdbx_env_open :: MdbxEnv -> String -> [MdbxEnvFlags] -> MdbxEnvMode -> IO Int
- mdbx_env_close :: MdbxEnv -> IO Int
- data MdbxTxnFlags
- newtype MdbxTxn = MdbxTxn (Ptr MdbxTxn)
- mdbx_txn_begin :: MdbxEnv -> Maybe MdbxTxn -> [MdbxTxnFlags] -> IO (Int, MdbxTxn)
- mdbx_txn_commit :: MdbxTxn -> IO Int
- mdbx_txn_abort :: MdbxTxn -> IO Int
- mdbx_txn_env :: MdbxTxn -> IO MdbxEnv
- data MdbxDbFlags
- type MdbxDbi = CUInt
- mdbx_dbi_open :: MdbxTxn -> Maybe String -> [MdbxDbFlags] -> IO (Int, MdbxDbi)
- mdbx_dbi_close :: MdbxEnv -> MdbxDbi -> IO Int
- data MdbxVal = MdbxVal {}
- emptyMdbxVal :: MdbxVal
- data MdbxPutFlags
- mdbx_put :: MdbxTxn -> MdbxDbi -> MdbxVal -> MdbxVal -> [MdbxPutFlags] -> IO Int
- mdbx_get :: MdbxTxn -> MdbxDbi -> MdbxVal -> IO (Int, MdbxVal)
- mdbx_del :: MdbxTxn -> MdbxDbi -> MdbxVal -> Maybe MdbxVal -> IO Int
- data MdbxCursorOp
- newtype MdbxCursor = MdbxCursor (Ptr MdbxCursor)
- mdbx_cursor_open :: MdbxTxn -> MdbxDbi -> IO (Int, MdbxCursor)
- mdbx_cursor_close :: MdbxCursor -> IO ()
- mdbx_cursor_del :: MdbxCursor -> [MdbxPutFlags] -> IO Int
- mdbx_cursor_get :: MdbxCursor -> MdbxVal -> MdbxCursorOp -> IO (Int, MdbxVal, MdbxVal)
- mdbx_cursor_put :: MdbxCursor -> MdbxVal -> MdbxVal -> [MdbxPutFlags] -> IO Int
- mdbx_cursor_count :: MdbxCursor -> IO (Int, CSize)
- mdbx_strerror :: Int -> IO String
- mdbx_cmp :: MdbxTxn -> MdbxDbi -> MdbxVal -> MdbxVal -> IO Int
- data MdbxError
- = MdbxKeyexist
- | MdbxFirstLmdbErrcode
- | MdbxNotfound
- | MdbxPageNotfound
- | MdbxCorrupted
- | MdbxPanic
- | MdbxVersionMismatch
- | MdbxInvalid
- | MdbxMapFull
- | MdbxDbsFull
- | MdbxReadersFull
- | MdbxTxnFull
- | MdbxCursorFull
- | MdbxPageFull
- | MdbxUnableExtendMapsize
- | MdbxIncompatible
- | MdbxBadRslot
- | MdbxBadTxn
- | MdbxBadValsize
- | MdbxBadDbi
- | MdbxProblem
- | MdbxLastLmdbErrcode
- | MdbxBusy
- | MdbxFirstAddedErrcode
- | MdbxEmultival
- | MdbxEbadsign
- | MdbxWannaRecovery
- | MdbxEkeymismatch
- | MdbxTooLarge
- | MdbxThreadMismatch
- | MdbxTxnOverlapping
- | MdbxLastAddedErrcode
- | MdbxResultTrue
- | MdbxSuccess
- | MdbxResultFalse
- | MdbxEperm
- | MdbxEnofile
- | MdbxEintr
- | MdbxEio
- | MdbxEnomem
- | MdbxEaccess
- | MdbxEremote
- | MdbxEinval
- | MdbxErofs
- | MdbxEnosys
- | MdbxEnodata
- mdbx_key_from_float :: Float -> Word32
- mdbx_key_from_double :: Double -> Word64
- mdbx_key_from_int32 :: Int32 -> Word32
- mdbx_key_from_int64 :: Int64 -> Word64
- mdbx_float_from_key :: Word32 -> Float
- mdbx_double_from_key :: Word64 -> Double
- mdbx_int32_from_key :: Word32 -> Int32
- mdbx_int64_from_key :: Word64 -> Int64
Environment
data MdbxEnvFlags Source #
Flags for opening an environment.
Instances
Environment object, needed for all the operations.
type MdbxEnvMode = CUInt Source #
UNIX permissions to set on created files. Zero value means to open existing, but do not create.
mdbx_env_create :: IO (Int, MdbxEnv) Source #
Creates an environment. Represents a database in the file system.
mdbx_env_set_geometry :: MdbxEnv -> Int -> Int -> Int -> Int -> Int -> Int -> IO Int Source #
Sets geometry of an environment. All the parameters can receive -1 to keep the current value. Receives (expressed in bytes): size_lower, size_now, size_upper, growth_step, shrink_threshold, pagesize.
mdbx_env_open :: MdbxEnv -> String -> [MdbxEnvFlags] -> MdbxEnvMode -> IO Int Source #
Opens an environment. Receives name, flags and mode.
Transaction
data MdbxTxnFlags Source #
Flags for a transaction.
Instances
Transaction instance. Needed for all operations with data, even reading.
mdbx_txn_begin :: MdbxEnv -> Maybe MdbxTxn -> [MdbxTxnFlags] -> IO (Int, MdbxTxn) Source #
Begins a new transaction.
Arguments:
- Environment.
- Parent transaction, or Nothing.
- Flags.
Database
data MdbxDbFlags Source #
Flags for a database.
MdbxDbDefaults | |
MdbxReversekey | |
MdbxDupsort | |
MdbxIntegerkey | |
MdbxDupfixed | |
MdbxIntegerdup | |
MdbxReversedup | |
MdbxCreate | |
MdbxDbAccede |
Instances
mdbx_dbi_open :: MdbxTxn -> Maybe String -> [MdbxDbFlags] -> IO (Int, MdbxDbi) Source #
Opens a database.
Arguments:
- Transaction.
- Name.
- Flags.
Data
Binary blob representing a key or value in the database.
Instances
Eq MdbxVal Source # | |
Show MdbxVal Source # | |
Storable MdbxVal Source # | |
emptyMdbxVal :: MdbxVal Source #
Sample empty value
CRUD
data MdbxPutFlags Source #
Flags for all data related operations.
MdbxUpsert | |
MdbxNooverwrite | |
MdbxNodupdata | |
MdbxCurrent | |
MdbxAlldups | |
MdbxReserve | |
MdbxAppend | |
MdbxAppenddup | |
MdbxMultiple |
Instances
mdbx_put :: MdbxTxn -> MdbxDbi -> MdbxVal -> MdbxVal -> [MdbxPutFlags] -> IO Int Source #
Stores a key/value pair.
Arguments:
- Transaction.
- Database.
- Key.
- Value.
mdbx_get :: MdbxTxn -> MdbxDbi -> MdbxVal -> IO (Int, MdbxVal) Source #
Gets a value with the given key.
Arguments:
- Transaction.
- Database.
- Key.
mdbx_del :: MdbxTxn -> MdbxDbi -> MdbxVal -> Maybe MdbxVal -> IO Int Source #
Gets a value with the given key.
Arguments:
- Transaction.
- Database.
- Key.
Cursor
data MdbxCursorOp Source #
Flags for cursor operations.
Instances
newtype MdbxCursor Source #
Cursor instance. Used for efficient navigation in a database.
Instances
Storable MdbxCursor Source # | |
Defined in Mdbx.FFI sizeOf :: MdbxCursor -> Int # alignment :: MdbxCursor -> Int # peekElemOff :: Ptr MdbxCursor -> Int -> IO MdbxCursor # pokeElemOff :: Ptr MdbxCursor -> Int -> MdbxCursor -> IO () # peekByteOff :: Ptr b -> Int -> IO MdbxCursor # pokeByteOff :: Ptr b -> Int -> MdbxCursor -> IO () # peek :: Ptr MdbxCursor -> IO MdbxCursor # poke :: Ptr MdbxCursor -> MdbxCursor -> IO () # |
mdbx_cursor_open :: MdbxTxn -> MdbxDbi -> IO (Int, MdbxCursor) Source #
Opens a new cursor.
Arguments:
- Transaction.
- Database.
mdbx_cursor_close :: MdbxCursor -> IO () Source #
Closes a cursor.
mdbx_cursor_del :: MdbxCursor -> [MdbxPutFlags] -> IO Int Source #
Removes the current key/value pair.
mdbx_cursor_get :: MdbxCursor -> MdbxVal -> MdbxCursorOp -> IO (Int, MdbxVal, MdbxVal) Source #
Returns the current key/value pair.
mdbx_cursor_put :: MdbxCursor -> MdbxVal -> MdbxVal -> [MdbxPutFlags] -> IO Int Source #
Sets the value for the current key.
Arguments:
- Cursor.
- Key.
- Value.
- FLags.
mdbx_cursor_count :: MdbxCursor -> IO (Int, CSize) Source #
Returns the count of duplicates in the current key.
mdbx_cmp :: MdbxTxn -> MdbxDbi -> MdbxVal -> MdbxVal -> IO Int Source #
Compares two values as a binary blob.
Error
Error codes for the different operations.
Instances
Enum MdbxError Source # | |
Defined in Mdbx.FFI succ :: MdbxError -> MdbxError # pred :: MdbxError -> MdbxError # fromEnum :: MdbxError -> Int # enumFrom :: MdbxError -> [MdbxError] # enumFromThen :: MdbxError -> MdbxError -> [MdbxError] # enumFromTo :: MdbxError -> MdbxError -> [MdbxError] # enumFromThenTo :: MdbxError -> MdbxError -> MdbxError -> [MdbxError] # | |
Eq MdbxError Source # | |
Ord MdbxError Source # | |
Defined in Mdbx.FFI | |
Show MdbxError Source # | |
Conversion for types used in keys
mdbx_key_from_float :: Float -> Word32 Source #
Converts a Double value to an unsigned Word that can be used by libmdbx's compare function.
Converts a Float value to an unsigned Word that can be used by libmdbx's compare function.
mdbx_key_from_double :: Double -> Word64 Source #
Converts a 32bits signed Int value to an unsigned Word that can be used by libmdbx's compare function.
mdbx_key_from_int32 :: Int32 -> Word32 Source #
Converts a 64bits signed Int value to an unsigned Word that can be used by libmdbx's compare function.
mdbx_key_from_int64 :: Int64 -> Word64 Source #
mdbx_float_from_key :: Word32 -> Float Source #
Converts an unsigned Word to a Float value.
mdbx_double_from_key :: Word64 -> Double Source #
Converts an unsigned Word to a Double value.
mdbx_int32_from_key :: Word32 -> Int32 Source #
Converts an unsigned Word value to a 32bits signed Int.
mdbx_int64_from_key :: Word64 -> Int64 Source #
Converts an unsigned Word value to a 64bits signed Int.