tokyocabinet-haskell-0.0.5: Haskell binding of Tokyo CabinetContentsIndex
Database.TokyoCabinet.FDB
Contents
Basic API (tokyocabinet.idl compliant)
Description
Interface to Fixed-length DBM. See also, http://tokyocabinet.sourceforge.net/spex-en.html#tcfdbapi for details
Synopsis
data FDB
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
data OpenMode
= OREADER
| OWRITER
| OCREAT
| OTRUNC
| ONOLCK
| OLCKNB
data ID
= IDMIN
| IDPREV
| IDMAX
| IDNEXT
| ID Int64
new :: IO FDB
delete :: FDB -> IO ()
ecode :: FDB -> IO ECODE
errmsg :: ECODE -> String
tune :: FDB -> Int32 -> Int64 -> IO Bool
open :: FDB -> String -> [OpenMode] -> IO Bool
close :: FDB -> IO Bool
put :: (Key k, Storable v) => FDB -> k -> v -> IO Bool
putkeep :: (Key k, Storable v) => FDB -> k -> v -> IO Bool
putcat :: (Key k, Storable v) => FDB -> k -> v -> IO Bool
out :: Key k => FDB -> k -> IO Bool
get :: (Key k, Storable v) => FDB -> k -> IO (Maybe v)
vsiz :: Key k => FDB -> k -> IO (Maybe Int)
iterinit :: FDB -> IO Bool
iternext :: Key k => FDB -> IO (Maybe k)
range :: (Key k1, Key k2) => FDB -> k1 -> k1 -> Int -> IO [k2]
fwmkeys :: (Storable k1, Storable k2, Sequence q) => FDB -> k1 -> Int -> IO (q k2)
addint :: Key k => FDB -> k -> Int -> IO (Maybe Int)
adddouble :: Key k => FDB -> k -> Double -> IO (Maybe Double)
sync :: FDB -> IO Bool
optimize :: FDB -> Int32 -> Int64 -> IO Bool
vanish :: FDB -> IO Bool
copy :: FDB -> String -> IO Bool
path :: FDB -> IO (Maybe String)
rnum :: FDB -> IO Word64
fsiz :: FDB -> IO Word64
Documentation

Example

    import Control.Monad
    import Database.TokyoCabinet.FDB
  
    main = do fdb <- new
              -- open the database
              open fdb "casket.tcf" [OWRITER, OCREAT] >>= err fdb
              -- store records
              puts fdb [(1, "one"), (12, "twelve"), (144, "one forty four")] >>=
                        err fdb . (all id)
              -- retrieve records
              get fdb (1 :: Int) >>= maybe (error "something goes wrong") putStrLn
              -- close the database
              close fdb >>= err fdb
        where
          puts :: FDB -> [(Int, String)] -> IO [Bool]
          puts fdb = mapM (uncurry $ put fdb)
  
          err :: FDB -> Bool -> IO ()
          err fdb = flip unless $ ecode fdb >>= error . show
data FDB
show/hide Instances
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
data OpenMode
Constructors
OREADER
OWRITER
OCREAT
OTRUNC
ONOLCK
OLCKNB
show/hide Instances
data ID
Constructors
IDMIN
IDPREV
IDMAX
IDNEXT
ID Int64
show/hide Instances
Basic API (tokyocabinet.idl compliant)
new :: IO FDB
Create a Fixed-length database object.
delete :: FDB -> IO ()
Free FDB resource forcibly. FDB is kept by ForeignPtr, so Haskell runtime GC cleans up memory for almost situation. Most always, you don't need to call this. After call this, you must not touch FDB object. Its behavior is undefined.
ecode :: FDB -> IO ECODE
Return the last happened error code.
errmsg :: ECODE -> String
Convert error code to message string.
tune
:: FDBFDB object.
-> Int32the width of the value of each record.
-> Int64the limit size of the database file.
-> IO Boolif successful, the return value is True.
Set the tuning parameters.
open :: FDB -> String -> [OpenMode] -> IO Bool
Open FDB database file.
close :: FDB -> IO Bool
Close the database file.
put :: (Key k, Storable v) => FDB -> k -> v -> IO Bool
Stora a record (key-value pair) on FDB. Key type must be instance of Key class. Value type must be instance of Storable.
putkeep :: (Key k, Storable v) => FDB -> k -> v -> IO Bool
Store a new record. If a record with the same key exists in the database, this function has no effect.
putcat :: (Key k, Storable v) => FDB -> k -> v -> IO Bool
Concatenate a value at the end of the existing record.
out :: Key k => FDB -> k -> IO Bool
Delete a record.
get :: (Key k, Storable v) => FDB -> k -> IO (Maybe v)
Return the value of record.
vsiz :: Key k => FDB -> k -> IO (Maybe Int)
Return the byte size of value in a record.
iterinit :: FDB -> IO Bool
Initialize the iterator of a FDB object.
iternext :: Key k => FDB -> IO (Maybe k)
Return the next key of the iterator of a FDB object.
range
:: (Key k1, Key k2)
=> FDBFDB object
-> k1the lower limit of the range.
-> k1the upper limit of the range.
-> Intthe maximum number of keys to be fetched.
-> IO [k2]keys in the specified range.
Return list of keys in the specified range.
fwmkeys :: (Storable k1, Storable k2, Sequence q) => FDB -> k1 -> Int -> IO (q k2)
Return list of forward matched keys.
addint :: Key k => FDB -> k -> Int -> IO (Maybe Int)
Increment the corresponding value. (The value specified by a key is treated as integer.)
adddouble :: Key k => FDB -> k -> Double -> IO (Maybe Double)
Increment the corresponding value. (The value specified by a key is treated as double.)
sync :: FDB -> IO Bool
Synchronize updated contents of a database object with the file and the device.
optimize :: FDB -> Int32 -> Int64 -> IO Bool
Optimize the file of a Hash database object.
vanish :: FDB -> IO Bool
Delete all records.
copy :: FDB -> String -> IO Bool
Copy the database file.
path :: FDB -> IO (Maybe String)
Return the file path of currentry opened database.
rnum :: FDB -> IO Word64
Return the number of records in the database.
fsiz :: FDB -> IO Word64
Return the size of the database file.
Produced by Haddock version 2.4.2