| Safe Haskell | None |
|---|
Database.KyotoCabinet.Db
Description
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.
Constructors
| 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.
Constructors
| 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 |
Instances
| Show KcTune |
data KcTuneType Source
Constructors
| KcTypePrototypeHashDb | |
| KcTypePrototypeTreeDb | |
| KcTypeCacheHashDb | |
| KcTypeCacheTreeDb | |
| KcTypeFileHashDb | |
| KcTypeFileTreeDb | |
| KcTypeDirectoryHashDb | |
| KcTypeDirectoryTreeDb |
Instances
| Show KcTuneType |
data KcLogLevel Source
Constructors
| KcLogDebug | |
| KcLogInfo | |
| KcLogWarn | |
| KcLogError |
Instances
| Show KcLogLevel |
Constructors
| KcOptionSmall | |
| KcOptionLinear | |
| KcOptionCompress |
Instances
| Show KcOption |
data KcCompressor Source
Constructors
| KcCompressorZlib | |
| KcCompressorDeflate | |
| KcCompressorGzip | |
| KcCompressorLzo | |
| KcCompressorLzma | |
| KcCompressorArc |
Instances
| Show KcCompressor |
data KcComparator Source
Constructors
| KcComparatorLexical | |
| KcComparatorDecimal |
Instances
| Show KcComparator |
data KcOpenMode Source
Open modes.
Constructors
| 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 |
Instances
| Eq KcOpenMode | |
| Show KcOpenMode |
data KcMergeMode Source
Merge modes.
Constructors
| KCMSET | overwrite the existing value |
| KCMADD | keep the existing value |
| KCMREPLACE | modify the existing record only |
| KCMAPPEND | append the new value |
Instances
| Eq KcMergeMode | |
| Show KcMergeMode |
data KcException Source
An exception indicating an error in a KC operation.
Constructors
| KcException String KcError String |
Instances
| 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.
Constructors
| 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
Arguments
| :: 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.
Arguments
| :: KcDb | |
| -> ByteString | key |
| -> KcVisitFull | |
| -> KcVisitEmpty | |
| -> Bool | writable |
| -> IO () |
Accept a visitor to a record.
Arguments
| :: KcDb | |
| -> [ByteString] | keys |
| -> KcVisitFull | |
| -> KcVisitEmpty | |
| -> Bool | writable |
| -> IO () |
Accept a visitor to multiple records at once.
Arguments
| :: KcDb | |
| -> KcVisitFull | |
| -> Bool | writable |
| -> IO () |
Iterate to accept a visitor for each record.
Arguments
| :: KcDb | |
| -> ByteString | key |
| -> ByteString | value |
| -> IO () |
Set the value of a record.
Arguments
| :: KcDb | |
| -> ByteString | key |
| -> ByteString | value |
| -> IO () |
Replace the value of a record.
Arguments
| :: KcDb | |
| -> ByteString | key |
| -> ByteString | value |
| -> IO () |
Append the value of a record.
Arguments
| :: KcDb | |
| -> ByteString | key |
| -> Int64 | increment amount |
| -> IO Int64 |
Add a number to the numeric value of a record.
Arguments
| :: KcDb | |
| -> ByteString | key |
| -> Double | increment amount |
| -> IO Double |
Add a number to the numeric value of a record.
Arguments
| :: KcDb | |
| -> ByteString | key |
| -> ByteString | old value |
| -> ByteString | new value |
| -> IO () |
Perform compare-and-swap.
Arguments
| :: KcDb | |
| -> ByteString | key |
| -> IO (Maybe ByteString) |
Retrieve the value of a record.
Arguments
| :: KcDb | |
| -> ByteString | key |
| -> Int | max chars to retrieve |
| -> IO (Maybe ByteString) |
Retrieve the value of a record.
Arguments
| :: KcDb | |
| -> [(ByteString, ByteString)] | records to store |
| -> Bool | atomic |
| -> IO Int64 | returns number of records stored |
Store records at once.
Arguments
| :: KcDb | |
| -> [ByteString] | keys of records to remove |
| -> Bool | atomic |
| -> IO Int64 | returns number of records removed |
Remove records at once.
Arguments
| :: KcDb | |
| -> [ByteString] | keys of the records to retrieve |
| -> Bool | atomic |
| -> IO [(ByteString, ByteString)] |
Retrieve records at once.
Arguments
| :: KcDb | |
| -> Bool |
|
| -> KcFileProc | postprocessor callback |
| -> IO () |
Synchronize updated contents with the file and the device.
Arguments
| :: KcDb | |
| -> FilePath | path to the destination file |
| -> IO () |
Create a copy of the database file.
Arguments
| :: KcDb | |
| -> Bool |
|
| -> IO () |
Begin transaction.
Arguments
| :: KcDb | |
| -> Bool |
|
| -> IO () |
Try to begin transaction.
kcdbstatus :: KcDb -> IO StringSource
Get the miscellaneous status information.
Arguments
| :: KcDb | |
| -> ByteString | prefix |
| -> Int | max elements to return |
| -> IO [ByteString] |
Get keys matching a prefix string.
Arguments
| :: KcDb | |
| -> ByteString | regexp |
| -> Int | max elements to return |
| -> IO [ByteString] |
Get keys matching a regular expression string.
Arguments
| :: KcDb | |
| -> [KcDb] | database sources |
| -> KcMergeMode | merge mode:
|
| -> IO () |
Merge records from other databases.
Cursor Operations
kcdbcursor :: KcDb -> IO KcCurSource
Create a cursor object.
Arguments
| :: KcCur | |
| -> KcVisitFull | |
| -> Bool | writable |
| -> Bool | step |
| -> IO () |
Accept a visitor to the current record.
kccurremove :: KcCur -> IO ()Source
Remove the current record.
Arguments
| :: KcCur | |
| -> Bool | step |
| -> IO ByteString |
Get the value of the current record.
Arguments
| :: 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.
Arguments
| :: 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.