tokyocabinet-haskell-0.0.5: Haskell binding of Tokyo CabinetContentsIndex
Database.TokyoCabinet
Contents
Error Code
Synopsis
data TCM a
runTCM :: TCM a -> IO a
data OpenMode
= OREADER
| OWRITER
| OCREAT
| OTRUNC
| ONOLCK
| OLCKNB
class TCDB a where
new :: TCM a
delete :: a -> TCM ()
open :: a -> String -> [OpenMode] -> TCM Bool
close :: a -> TCM Bool
put :: (Storable k, Storable v) => a -> k -> v -> TCM Bool
putkeep :: (Storable k, Storable v) => a -> k -> v -> TCM Bool
putcat :: (Storable k, Storable v) => a -> k -> v -> TCM Bool
get :: (Storable k, Storable v) => a -> k -> TCM (Maybe v)
out :: Storable k => a -> k -> TCM Bool
vsiz :: Storable k => a -> k -> TCM (Maybe Int)
iterinit :: a -> TCM Bool
iternext :: Storable v => a -> TCM (Maybe v)
fwmkeys :: (Storable k, Storable v, Sequence q) => a -> k -> Int -> TCM (q v)
addint :: Storable k => a -> k -> Int -> TCM (Maybe Int)
adddouble :: Storable k => a -> k -> Double -> TCM (Maybe Double)
sync :: a -> TCM Bool
vanish :: a -> TCM Bool
copy :: a -> String -> TCM Bool
path :: a -> TCM (Maybe String)
rnum :: a -> TCM Word64
size :: a -> TCM Word64
ecode :: a -> TCM ECODE
defaultExtension :: a -> String
data HDB
data FDB
data TDB
data BDB
data ECODE
= ESUCCESS
| ETHREAD
| EINVALID
| ENOFILE
| ENOPERM
| EMETA
| ERHEAD
| EOPEN
| ECLOSE
| ETRUNC
| ESYNC
| ESTAT
| ESEEK
| EREAD
| EWRITE
| EMMAP
| ELOCK
| EUNLINK
| ERENAME
| EMKDIR
| ERMDIR
| EKEEP
| ENOREC
| EMISC
errmsg :: ECODE -> String
Documentation

Basic Usage (sample code)

    import Database.TokyoCabinet
    import Data.ByteString.Char8
    putsample :: String -> [(ByteString, ByteString)] -> TCM Bool
    putsample file kv =
        do tc <- new :: TCM HDB -- alternatively you can use BDB or FDB
           open tc file [OWRITER, OCREAT]
           mapM (uncurry $ put tc) kv
           close tc
    getsample :: String -> ByteString -> TCM (Maybe ByteString)
    getsample file key =
        do tc <- new :: TCM HDB -- alternatively you can use BDB or FDB
           open tc file [OREADER]
           val <- get tc key
           close tc
           return val
    main = runTCM (do putsample "foo.tch" [(pack "foo", pack "bar")]
                      getsample "foo.tch" (pack "foo")) >>=
           maybe (return ()) (putStrLn . show)
data TCM a
Tokyo Cabinet related computation. Wrap of IO.
show/hide Instances
Monad TCM
MonadIO TCM
runTCM :: TCM a -> IO a
Unwrap TCM.
data OpenMode
Represent open mode for open function.
Constructors
OREADER
OWRITER
OCREAT
OTRUNC
ONOLCK
OLCKNB
show/hide Instances
class TCDB a where
Type class that abstract Tokyo Cabinet database.
Methods
new :: TCM a
Create a database object.
delete :: a -> TCM ()
Free object resource forcibly.
open
:: adatabase object
-> Stringpath to database file
-> [OpenMode]open mode
-> TCM Boolif successful, the return value is True
Open a database file.
close :: a -> TCM Bool
Close the database file. If successful, the return value is True
put
:: (Storable k, Storable v)
=> adatabase object
-> kkey
-> vvalue
-> TCM Boolif successful, the return value is True
Store a record.
putkeep
:: (Storable k, Storable v)
=> adatabase object
-> kkey
-> vvalue
-> TCM Boolif successful, the return value is True
Store a new recoed. If a record with the same key exists in the database, this function has no effect.
putcat
:: (Storable k, Storable v)
=> adatabase object
-> kkey
-> vvalue
-> TCM Boolif successful, the return value is True
Concatenate a value at the end of the existing record.
get
:: (Storable k, Storable v)
=> adatabase object
-> kkey
-> TCM (Maybe v)If successful, the return value is the value of the corresponding record wrapped by Just, else, Nothing is returned.
Retrieve a record.
out
:: Storable k
=> adatabase object
-> kkey
-> TCM Boolif successful, the return value is True
Remove a record.
vsiz
:: Storable k
=> adatabase object
-> kkey
-> TCM (Maybe Int)If successful, the return value is the size of the value of the corresponding record wrapped by Just, else, it is Nothing.
Get the size of the value of a record.
iterinit :: a -> TCM Bool
Initialize the iterator. If successful, the return value is True.
iternext :: Storable v => a -> TCM (Maybe v)
Get the next key of the iterator. If successful, the return value is the next key wrapped by Just, else, it is Nothing.
fwmkeys
:: (Storable k, Storable v, Sequence q)
=> adatabase object
-> ksearch string
-> Intthe maximum number of keys to be fetched
-> TCM (q v)result keys
Get forward matching keys.
addint
:: Storable k
=> adatabase object
-> kkey
-> Intthe addtional value
-> TCM (Maybe Int)If the corresponding record exists, the value is treated as an integer and is added to. If no record corresponds, a new record of the additional value is stored.
Add an integer to a record.
adddouble
:: Storable k
=> adatabase object
-> kkey
-> Doublethe additional value
-> TCM (Maybe Double)If the corresponding record exists, the value is treated as a real number and is added to. If no record corresponds, a new record of the additional value is stored.
Add a real number to a record.
sync :: a -> TCM Bool
Synchronize updated contents with the file and the device. If successful, the return value is True.
vanish :: a -> TCM Bool
Remove all records. If successful, the return value is True.
copy
:: adatabase object
-> Stringpath of the destination file
-> TCM BoolIf successful, the return value is True.
Copy the database file.
path :: a -> TCM (Maybe String)
Get the path of the database file.
rnum :: a -> TCM Word64
Get the number of records.
size :: a -> TCM Word64
Get the size of the database file.
ecode :: a -> TCM ECODE
Get the last happened error code.
defaultExtension :: a -> String
Get the default extension for specified database object.
show/hide Instances
data HDB
show/hide Instances
data FDB
show/hide Instances
data TDB
show/hide Instances
data BDB
show/hide Instances
Error Code
data ECODE
Represents error
Constructors
ESUCCESSsuccess
ETHREADthreading error
EINVALIDinvalid operation
ENOFILEfile not found
ENOPERMno permission
EMETAinvalid meta data
ERHEADinvalid record header
EOPENopen error
ECLOSEclose error
ETRUNCtrunc error
ESYNCsync error
ESTATstat error
ESEEKseek error
EREADread error
EWRITEwrite error
EMMAPmmap error
ELOCKlock error
EUNLINKunlink error
ERENAMErename error
EMKDIRmkdir error
ERMDIRrmdir error
EKEEPexisting record
ENORECno record found
EMISCmiscellaneous error
show/hide Instances
errmsg :: ECODE -> String
Convert error code to message string.
Produced by Haddock version 2.4.2