module Database.TokyoCabinet.HDB
(
HDB
, ECODE(..)
, OpenMode(..)
, TuningOption(..)
, new
, delete
, ecode
, errmsg
, tune
, setcache
, setxmsiz
, open
, close
, put
, putkeep
, putcat
, putasync
, out
, get
, vsiz
, iterinit
, iternext
, fwmkeys
, addint
, adddouble
, sync
, optimize
, vanish
, copy
, tranbegin
, trancommit
, tranabort
, path
, rnum
, fsiz
)
where
import Foreign.ForeignPtr
import Data.Int
import Data.Word
import Database.TokyoCabinet.HDB.C
import Database.TokyoCabinet.Error
import Database.TokyoCabinet.Internal
import Database.TokyoCabinet.Sequence
import Database.TokyoCabinet.Storable
data HDB = HDB { unTCHDB :: !(ForeignPtr HDB') }
new :: IO HDB
new = HDB `fmap` (c_tchdbnew >>= newForeignPtr tchdbFinalizer)
delete :: HDB -> IO ()
delete hdb = finalizeForeignPtr (unTCHDB hdb)
ecode :: HDB -> IO ECODE
ecode hdb = cintToError `fmap` withForeignPtr (unTCHDB hdb) c_tchdbecode
tune :: HDB
-> Int64
-> Int8
-> Int8
-> [TuningOption]
-> IO Bool
tune hdb bnum apow fpow options =
withForeignPtr (unTCHDB hdb) $ \p ->
c_tchdbtune p bnum apow fpow (combineTuningOption options)
setcache :: HDB
-> Int32
-> IO Bool
setcache hdb rcnum = withForeignPtr (unTCHDB hdb) (flip c_tchdbsetcache rcnum)
setxmsiz :: HDB -> Int64 -> IO Bool
setxmsiz hdb xmsiz = withForeignPtr (unTCHDB hdb) (flip c_tchdbsetxmsiz xmsiz)
open :: HDB -> String -> [OpenMode] -> IO Bool
open = openHelper c_tchdbopen unTCHDB combineOpenMode
close :: HDB -> IO Bool
close hdb = withForeignPtr (unTCHDB hdb) c_tchdbclose
put :: (Storable k, Storable v) => HDB -> k -> v -> IO Bool
put = putHelper c_tchdbput unTCHDB
putkeep :: (Storable k, Storable v) => HDB -> k -> v -> IO Bool
putkeep = putHelper c_tchdbputkeep unTCHDB
putcat :: (Storable k, Storable v) => HDB -> k -> v -> IO Bool
putcat = putHelper c_tchdbputcat unTCHDB
putasync :: (Storable k, Storable v) => HDB -> k -> v -> IO Bool
putasync = putHelper c_tchdbputasync unTCHDB
out :: (Storable k) => HDB -> k -> IO Bool
out = outHelper c_tchdbout unTCHDB
get :: (Storable k, Storable v) => HDB -> k -> IO (Maybe v)
get = getHelper c_tchdbget unTCHDB
vsiz :: (Storable k) => HDB -> k -> IO (Maybe Int)
vsiz = vsizHelper c_tchdbvsiz unTCHDB
iterinit :: HDB -> IO Bool
iterinit hdb = withForeignPtr (unTCHDB hdb) c_tchdbiterinit
iternext :: (Storable k) => HDB -> IO (Maybe k)
iternext = iternextHelper c_tchdbiternext unTCHDB
fwmkeys :: (Storable k1, Storable k2, Sequence q) =>
HDB -> k1 -> Int -> IO (q k2)
fwmkeys = fwmHelper c_tchdbfwmkeys unTCHDB
addint :: (Storable k) => HDB -> k -> Int -> IO (Maybe Int)
addint = addHelper c_tchdbaddint unTCHDB fromIntegral fromIntegral (== cINT_MIN)
adddouble :: (Storable k) => HDB -> k -> Double -> IO (Maybe Double)
adddouble = addHelper c_tchdbadddouble unTCHDB realToFrac realToFrac isNaN
sync :: HDB -> IO Bool
sync hdb = withForeignPtr (unTCHDB hdb) c_tchdbsync
optimize :: HDB
-> Int64
-> Int8
-> Int8
-> [TuningOption]
-> IO Bool
optimize hdb bnum apow fpow options =
withForeignPtr (unTCHDB hdb) $ \p ->
c_tchdboptimize p bnum apow fpow (combineTuningOption options)
vanish :: HDB -> IO Bool
vanish hdb = withForeignPtr (unTCHDB hdb) c_tchdbvanish
copy :: HDB -> String -> IO Bool
copy = copyHelper c_tchdbcopy unTCHDB
tranbegin :: HDB -> IO Bool
tranbegin hdb = withForeignPtr (unTCHDB hdb) c_tchdbtranbegin
trancommit :: HDB -> IO Bool
trancommit hdb = withForeignPtr (unTCHDB hdb) c_tchdbtrancommit
tranabort :: HDB -> IO Bool
tranabort hdb = withForeignPtr (unTCHDB hdb) c_tchdbtranabort
path :: HDB -> IO (Maybe String)
path = pathHelper c_tchdbpath unTCHDB
rnum :: HDB -> IO Word64
rnum hdb = withForeignPtr (unTCHDB hdb) c_tchdbrnum
fsiz :: HDB -> IO Word64
fsiz hdb = withForeignPtr (unTCHDB hdb) c_tchdbfsiz