Safe Haskell | None |
---|
Kyoto Cabinet DB bindings. All IO monad functions can throw KcException.
This documentation is not a complete description of the Kyoto Cabinet DB interface. You will need to refer to Kyoto Cabinet DB's C API documentation for the details: http://fallabs.com/kyotocabinet/
- data KcDb
- data KcCur
- data KcError
- = KCESUCCESS
- | KCENOIMPL
- | KCEINVALID
- | KCENOREPOS
- | KCENOPERM
- | KCEBROKEN
- | KCEDUPREC
- | KCENOREC
- | KCELOGIC
- | KCESYSTEM
- | KCEMISC
- | KCUNKNOWNERROR Int
- data KcTune
- = KcTuneType KcTuneType
- | KcTuneLogger KcLogger
- | KcTuneLogKinds KcLogLevel
- | KcTuneLogPx String
- | KcTuneOptions [KcOption]
- | KcTuneBuckets Int
- | KcTuneCompressor KcCompressor
- | KcTuneZkey String
- | KcTuneCapCount Int
- | KcTuneCapSize Int
- | KcTunePage Int
- | KcTuneComparator KcComparator
- | KcTunePageCache Int
- | KcTuneAlignment Int
- | KcTuneFbp Int
- | KcTuneMap Int
- | KcTuneDefrag Int
- data KcTuneType
- data KcLogger
- data KcLogLevel
- = KcLogDebug
- | KcLogInfo
- | KcLogWarn
- | KcLogError
- data KcOption
- data KcCompressor
- data KcComparator
- data KcOpenMode
- = KCOREADER
- | KCOWRITER
- | KCOCREATE
- | KCOTRUNCATE
- | KCOAUTOTRAN
- | KCOAUTOSYNC
- | KCONOLOCK
- | KCOTRYLOCK
- | KCONOREPAIR
- data KcMergeMode
- = KCMSET
- | KCMADD
- | KCMREPLACE
- | KCMAPPEND
- data KcException = KcException String KcError String
- data KcVisitAction
- = KCVISNOP
- | KCVISSET ByteString
- | KCVISREMOVE
- type KcVisitFull = ByteString -> ByteString -> IO KcVisitAction
- type KcVisitEmpty = ByteString -> IO KcVisitAction
- type KcFileProc = FilePath -> Int64 -> Int64 -> IO Bool
- kcversion :: IO String
- kcmalloc :: Int -> IO (Ptr a)
- kcfree :: Ptr a -> IO ()
- kctime :: IO Double
- kcatoi :: String -> IO Int64
- kcatoix :: String -> IO Int64
- kcatof :: String -> IO Double
- kchashmurmur :: ByteString -> IO Int64
- kchashfnv :: ByteString -> IO Int64
- kcnan :: IO Double
- kcinf :: IO Double
- kcchknan :: Double -> IO Bool
- kcchkinf :: Double -> IO Bool
- kcecodename :: Int -> IO String
- kcdbnew :: IO KcDb
- kcdbdel :: KcDb -> IO ()
- kcdbopen :: KcDb -> String -> [KcTune] -> [KcOpenMode] -> IO ()
- kcdbclose :: KcDb -> IO ()
- kcdbecode :: KcDb -> IO KcError
- kcdbemsg :: KcDb -> IO String
- kcdbaccept :: KcDb -> ByteString -> KcVisitFull -> KcVisitEmpty -> Bool -> IO ()
- kcdbacceptbulk :: KcDb -> [ByteString] -> KcVisitFull -> KcVisitEmpty -> Bool -> IO ()
- kcdbiterate :: KcDb -> KcVisitFull -> Bool -> IO ()
- kcdbset :: KcDb -> ByteString -> ByteString -> IO ()
- kcdbadd :: KcDb -> ByteString -> ByteString -> IO ()
- kcdbreplace :: KcDb -> ByteString -> ByteString -> IO ()
- kcdbappend :: KcDb -> ByteString -> ByteString -> IO ()
- kcdbincrint :: KcDb -> ByteString -> Int64 -> IO Int64
- kcdbincrdouble :: KcDb -> ByteString -> Double -> IO Double
- kcdbcas :: KcDb -> ByteString -> ByteString -> ByteString -> IO ()
- kcdbremove :: KcDb -> ByteString -> IO ()
- kcdbget :: KcDb -> ByteString -> IO (Maybe ByteString)
- kcdbgetbuf :: KcDb -> ByteString -> Int -> IO (Maybe ByteString)
- kcdbsetbulk :: KcDb -> [(ByteString, ByteString)] -> Bool -> IO Int64
- kcdbremovebulk :: KcDb -> [ByteString] -> Bool -> IO Int64
- kcdbgetbulk :: KcDb -> [ByteString] -> Bool -> IO [(ByteString, ByteString)]
- kcdbclear :: KcDb -> IO ()
- kcdbsync :: KcDb -> Bool -> KcFileProc -> IO ()
- kcdbcopy :: KcDb -> FilePath -> IO ()
- kcdbbegintran :: KcDb -> Bool -> IO ()
- kcdbbegintrantry :: KcDb -> Bool -> IO ()
- kcdbendtran :: KcDb -> Bool -> IO ()
- kcdbdumpsnap :: KcDb -> FilePath -> IO ()
- kcdbloadsnap :: KcDb -> FilePath -> IO ()
- kcdbcount :: KcDb -> IO Int64
- kcdbsize :: KcDb -> IO Int64
- kcdbpath :: KcDb -> IO String
- kcdbstatus :: KcDb -> IO String
- kcdbmatchprefix :: KcDb -> ByteString -> Int -> IO [ByteString]
- kcdbmatchregex :: KcDb -> ByteString -> Int -> IO [ByteString]
- kcdbmerge :: KcDb -> [KcDb] -> KcMergeMode -> IO ()
- kcdbcursor :: KcDb -> IO KcCur
- kccurdel :: KcCur -> IO ()
- kccuraccept :: KcCur -> KcVisitFull -> Bool -> Bool -> IO ()
- kccurremove :: KcCur -> IO ()
- kccurgetkey :: KcCur -> Bool -> IO ByteString
- kccurgetvalue :: KcCur -> Bool -> IO ByteString
- kccurget :: KcCur -> Bool -> IO (ByteString, ByteString)
- kccurjump :: KcCur -> IO ()
- kccurjumpkey :: KcCur -> ByteString -> IO ()
- kccurjumpback :: KcCur -> IO ()
- kccurjumpbackkey :: KcCur -> ByteString -> IO ()
- kccurstep :: KcCur -> IO ()
- kccurstepback :: KcCur -> IO ()
- kccurdb :: KcCur -> IO KcDb
- kccurecode :: KcCur -> IO KcError
- kccuremsg :: KcCur -> IO String
- kcwithdbopen :: FilePath -> [KcTune] -> [KcOpenMode] -> (KcDb -> IO a) -> IO a
- kcwithdbcursor :: KcDb -> (KcCur -> IO a) -> IO a
- kcwithdbtran :: KcDb -> Bool -> IO a -> IO a
Types
Error codes.
KCESUCCESS | success |
KCENOIMPL | not implemented |
KCEINVALID | invalid operation |
KCENOREPOS | no repository |
KCENOPERM | no permission |
KCEBROKEN | broken file |
KCEDUPREC | record duplication |
KCENOREC | no record |
KCELOGIC | logical inconsistency |
KCESYSTEM | system error |
KCEMISC | miscellaneous error |
KCUNKNOWNERROR Int |
Tuning parameters for database creation.
KcTuneType KcTuneType | |
KcTuneLogger KcLogger | |
KcTuneLogKinds KcLogLevel | |
KcTuneLogPx String | |
KcTuneOptions [KcOption] | supported by: cache hash, cache tree, file hash, file tree, directory hash, directory tree |
KcTuneBuckets Int | supported by: cache hash, cache tree, file hash, file tree |
KcTuneCompressor KcCompressor | supported by: cache hash, cache tree, file hash, file tree, directory hash, directory tree |
KcTuneZkey String | supported by: cache hash, cache tree, file hash, file tree, directory hash, directory tree |
KcTuneCapCount Int | supported by: cache hash |
KcTuneCapSize Int | supported by: cache hash |
KcTunePage Int | supported by: cache tree, file tree, directory tree |
KcTuneComparator KcComparator | supported by: cache tree, file tree, directory tree |
KcTunePageCache Int | supported by: cache tree, file tree, directory tree |
KcTuneAlignment Int | supported by: file hash, file tree |
KcTuneFbp Int | supported by: file hash, file tree |
KcTuneMap Int | supported by: file hash, file tree |
KcTuneDefrag Int | supported by: file hash, file tree |
Show KcTune |
data KcTuneType Source
KcTypePrototypeHashDb | |
KcTypePrototypeTreeDb | |
KcTypeCacheHashDb | |
KcTypeCacheTreeDb | |
KcTypeFileHashDb | |
KcTypeFileTreeDb | |
KcTypeDirectoryHashDb | |
KcTypeDirectoryTreeDb |
Show KcTuneType |
data KcCompressor Source
KcCompressorZlib | |
KcCompressorDeflate | |
KcCompressorGzip | |
KcCompressorLzo | |
KcCompressorLzma | |
KcCompressorArc |
Show KcCompressor |
data KcOpenMode Source
Open modes.
KCOREADER | open as a reader |
KCOWRITER | open as a writer |
KCOCREATE | writer creating |
KCOTRUNCATE | writer truncating |
KCOAUTOTRAN | auto transaction |
KCOAUTOSYNC | auto synchronization |
KCONOLOCK | open without locking |
KCOTRYLOCK | lock without blocking |
KCONOREPAIR | open without auto repair |
Eq KcOpenMode | |
Show KcOpenMode |
data KcMergeMode Source
Merge modes.
KCMSET | overwrite the existing value |
KCMADD | keep the existing value |
KCMREPLACE | modify the existing record only |
KCMAPPEND | append the new value |
Eq KcMergeMode | |
Show KcMergeMode |
data KcException Source
An exception indicating an error in a KC operation.
KcException String KcError String |
Eq KcException | |
Show KcException | |
Typeable KcException | |
Exception KcException |
data KcVisitAction Source
Return one of these from KcVisitFull
, KcVisitEmpty
or
KcFileProc
to update the database after a visitor access.
KCVISNOP | |
KCVISSET ByteString | |
KCVISREMOVE |
type KcVisitFull = ByteString -> ByteString -> IO KcVisitActionSource
Type of a visitor function when key-value is present.
type KcVisitEmpty = ByteString -> IO KcVisitActionSource
Type of a visitor function when key-value is absent.
type KcFileProc = FilePath -> Int64 -> Int64 -> IO BoolSource
Type of a database synchronization callback.
Utilities
Most of these routines are probably not needed by haskell users, but are included for completeness.
kchashmurmur :: ByteString -> IO Int64Source
Get the hash value by MurMur hashing.
kcecodename :: Int -> IO StringSource
Get the readable string of an error code.
DB Operations
:: KcDb |
|
-> String |
|
-> [KcTune] |
|
-> [KcOpenMode] |
The following flags may be added to both of the reader mode and the writer mode:
|
-> IO () | Returns Every opened database must be closed by the |
Open a database file.
:: KcDb | |
-> ByteString | key |
-> KcVisitFull | |
-> KcVisitEmpty | |
-> Bool | writable |
-> IO () |
Accept a visitor to a record.
:: KcDb | |
-> [ByteString] | keys |
-> KcVisitFull | |
-> KcVisitEmpty | |
-> Bool | writable |
-> IO () |
Accept a visitor to multiple records at once.
:: KcDb | |
-> KcVisitFull | |
-> Bool | writable |
-> IO () |
Iterate to accept a visitor for each record.
:: KcDb | |
-> ByteString | key |
-> ByteString | value |
-> IO () |
Replace the value of a record.
:: KcDb | |
-> ByteString | key |
-> Int64 | increment amount |
-> IO Int64 |
Add a number to the numeric value of a record.
:: KcDb | |
-> ByteString | key |
-> Double | increment amount |
-> IO Double |
Add a number to the numeric value of a record.
:: KcDb | |
-> ByteString | key |
-> ByteString | old value |
-> ByteString | new value |
-> IO () |
Perform compare-and-swap.
:: KcDb | |
-> ByteString | key |
-> Int | max chars to retrieve |
-> IO (Maybe ByteString) |
Retrieve the value of a record.
:: KcDb | |
-> [(ByteString, ByteString)] | records to store |
-> Bool | atomic |
-> IO Int64 | returns number of records stored |
Store records at once.
:: KcDb | |
-> [ByteString] | keys of records to remove |
-> Bool | atomic |
-> IO Int64 | returns number of records removed |
Remove records at once.
:: KcDb | |
-> [ByteString] | keys of the records to retrieve |
-> Bool | atomic |
-> IO [(ByteString, ByteString)] |
Retrieve records at once.
:: KcDb | |
-> Bool |
|
-> KcFileProc | postprocessor callback |
-> IO () |
Synchronize updated contents with the file and the device.
:: KcDb | |
-> FilePath | path to the destination file |
-> IO () |
Create a copy of the database file.
:: KcDb | |
-> Bool |
|
-> IO () |
Begin transaction.
:: KcDb | |
-> Bool |
|
-> IO () |
Try to begin transaction.
kcdbstatus :: KcDb -> IO StringSource
Get the miscellaneous status information.
:: KcDb | |
-> ByteString | prefix |
-> Int | max elements to return |
-> IO [ByteString] |
Get keys matching a prefix string.
:: KcDb | |
-> ByteString | regexp |
-> Int | max elements to return |
-> IO [ByteString] |
Get keys matching a regular expression string.
:: KcDb | |
-> [KcDb] | database sources |
-> KcMergeMode | merge mode:
|
-> IO () |
Merge records from other databases.
Cursor Operations
kcdbcursor :: KcDb -> IO KcCurSource
Create a cursor object.
:: KcCur | |
-> KcVisitFull | |
-> Bool | writable |
-> Bool | step |
-> IO () |
Accept a visitor to the current record.
kccurremove :: KcCur -> IO ()Source
Remove the current record.
:: KcCur | |
-> Bool | step |
-> IO (ByteString, ByteString) |
Get a pair of the key and the value of the current record.
kccurjumpkey :: KcCur -> ByteString -> IO ()Source
Jump the cursor to a record for forward scan.
kccurjumpback :: KcCur -> IO ()Source
Jump the cursor to the last record for backward scan.
kccurjumpbackkey :: KcCur -> ByteString -> IO ()Source
Jump the cursor to a record for backward scan.
kccurstepback :: KcCur -> IO ()Source
Step the cursor to the previous record.
kccurecode :: KcCur -> IO KcErrorSource
Get the code of the last happened error.
Scoped Operations
kcwithdbopen :: FilePath -> [KcTune] -> [KcOpenMode] -> (KcDb -> IO a) -> IO aSource
kcwithdbcursor :: KcDb -> (KcCur -> IO a) -> IO aSource
Brackets a cursor command between kcdbcursor
and kccurdel
calls.
:: KcDb | |
-> Bool |
|
-> IO a | db command |
-> IO a |
Brackets a db command between kcdbbegintran
and kcdbendtran
calls,
committing on successful completion of the command, and aborting on
exception.