kyotocabinet::DB Class Reference

Interface of database abstraction. More...

#include <kcdb.h>

List of all members.

Classes

class  Cursor
 Interface of cursor to indicate a record. More...
class  Visitor
 Interface to access a record. More...

Public Member Functions

virtual ~DB ()
 Destructor.
virtual bool accept (const char *kbuf, size_t ksiz, Visitor *visitor, bool writable=true)=0
 Accept a visitor to a record.
virtual bool set (const char *kbuf, size_t ksiz, const char *vbuf, size_t vsiz)=0
 Set the value of a record.
virtual bool set (const std::string &key, const std::string &value)=0
 Set the value of a record.
virtual bool add (const char *kbuf, size_t ksiz, const char *vbuf, size_t vsiz)=0
 Add a record.
virtual bool add (const std::string &key, const std::string &value)=0
 Set the value of a record.
virtual bool replace (const char *kbuf, size_t ksiz, const char *vbuf, size_t vsiz)=0
 Replace the value of a record.
virtual bool replace (const std::string &key, const std::string &value)=0
 Replace the value of a record.
virtual bool append (const char *kbuf, size_t ksiz, const char *vbuf, size_t vsiz)=0
 Append the value of a record.
virtual bool append (const std::string &key, const std::string &value)=0
 Set the value of a record.
virtual int64_t increment (const char *kbuf, size_t ksiz, int64_t num)=0
 Add a number to the numeric integer value of a record.
virtual int64_t increment (const std::string &key, int64_t num)=0
 Add a number to the numeric integer value of a record.
virtual double increment_double (const char *kbuf, size_t ksiz, double num)=0
 Add a number to the numeric double value of a record.
virtual double increment_double (const std::string &key, double num)=0
 Add a number to the numeric double value of a record.
virtual bool cas (const char *kbuf, size_t ksiz, const char *ovbuf, size_t ovsiz, const char *nvbuf, size_t nvsiz)=0
 Perform compare-and-swap.
virtual bool cas (const std::string &key, const std::string &ovalue, const std::string &nvalue)=0
 Perform compare-and-swap.
virtual bool remove (const char *kbuf, size_t ksiz)=0
 Remove a record.
virtual bool remove (const std::string &key)=0
 Remove a record.
virtual char * get (const char *kbuf, size_t ksiz, size_t *sp)=0
 Retrieve the value of a record.
virtual std::string * get (const std::string &key)=0
 Retrieve the value of a record.
virtual int32_t get (const char *kbuf, size_t ksiz, char *vbuf, size_t max)=0
 Retrieve the value of a record.
virtual bool clear ()=0
 Remove all records.
virtual int64_t count ()=0
 Get the number of records.
virtual Cursorcursor ()=0
 Create a cursor object.

Detailed Description

Interface of database abstraction.

Note:
This class is an abstract class to prescribe the interface of record access.

Constructor & Destructor Documentation

virtual kyotocabinet::DB::~DB (  )  [virtual]

Destructor.


Member Function Documentation

virtual bool kyotocabinet::DB::accept ( const char *  kbuf,
size_t  ksiz,
Visitor visitor,
bool  writable = true 
) [pure virtual]

Accept a visitor to a record.

Parameters:
kbuf the pointer to the key region.
ksiz the size of the key region.
visitor a visitor object.
writable true for writable operation, or false for read-only operation.
Returns:
true on success, or false on failure.
Note:
The operation for each record is performed atomically and other threads accessing the same record are blocked. To avoid deadlock, any database operation must not be performed in this function.

Implemented in kyotocabinet::CacheDB, kyotocabinet::DirDB, kyotocabinet::HashDB, kyotocabinet::PlantDB< BASEDB, DBTYPE >, kyotocabinet::PolyDB, kyotocabinet::ProtoDB< STRMAP, DBTYPE >, and kyotocabinet::StashDB.

virtual bool kyotocabinet::DB::set ( const char *  kbuf,
size_t  ksiz,
const char *  vbuf,
size_t  vsiz 
) [pure virtual]

Set the value of a record.

Parameters:
kbuf the pointer to the key region.
ksiz the size of the key region.
vbuf the pointer to the value region.
vsiz the size of the value region.
Returns:
true on success, or false on failure.
Note:
If no record corresponds to the key, a new record is created. If the corresponding record exists, the value is overwritten.

Implemented in kyotocabinet::BasicDB.

virtual bool kyotocabinet::DB::set ( const std::string &  key,
const std::string &  value 
) [pure virtual]

Set the value of a record.

Note:
Equal to the original DB::set method except that the parameters are std::string.

Implemented in kyotocabinet::BasicDB.

virtual bool kyotocabinet::DB::add ( const char *  kbuf,
size_t  ksiz,
const char *  vbuf,
size_t  vsiz 
) [pure virtual]

Add a record.

Parameters:
kbuf the pointer to the key region.
ksiz the size of the key region.
vbuf the pointer to the value region.
vsiz the size of the value region.
Returns:
true on success, or false on failure.
Note:
If no record corresponds to the key, a new record is created. If the corresponding record exists, the record is not modified and false is returned.

Implemented in kyotocabinet::BasicDB.

virtual bool kyotocabinet::DB::add ( const std::string &  key,
const std::string &  value 
) [pure virtual]

Set the value of a record.

Note:
Equal to the original DB::add method except that the parameters are std::string.

Implemented in kyotocabinet::BasicDB.

virtual bool kyotocabinet::DB::replace ( const char *  kbuf,
size_t  ksiz,
const char *  vbuf,
size_t  vsiz 
) [pure virtual]

Replace the value of a record.

Parameters:
kbuf the pointer to the key region.
ksiz the size of the key region.
vbuf the pointer to the value region.
vsiz the size of the value region.
Returns:
true on success, or false on failure.
Note:
If no record corresponds to the key, no new record is created and false is returned. If the corresponding record exists, the value is modified.

Implemented in kyotocabinet::BasicDB.

virtual bool kyotocabinet::DB::replace ( const std::string &  key,
const std::string &  value 
) [pure virtual]

Replace the value of a record.

Note:
Equal to the original DB::replace method except that the parameters are std::string.

Implemented in kyotocabinet::BasicDB.

virtual bool kyotocabinet::DB::append ( const char *  kbuf,
size_t  ksiz,
const char *  vbuf,
size_t  vsiz 
) [pure virtual]

Append the value of a record.

Parameters:
kbuf the pointer to the key region.
ksiz the size of the key region.
vbuf the pointer to the value region.
vsiz the size of the value region.
Returns:
true on success, or false on failure.
Note:
If no record corresponds to the key, a new record is created. If the corresponding record exists, the given value is appended at the end of the existing value.

Implemented in kyotocabinet::BasicDB.

virtual bool kyotocabinet::DB::append ( const std::string &  key,
const std::string &  value 
) [pure virtual]

Set the value of a record.

Note:
Equal to the original DB::append method except that the parameters are std::string.

Implemented in kyotocabinet::BasicDB.

virtual int64_t kyotocabinet::DB::increment ( const char *  kbuf,
size_t  ksiz,
int64_t  num 
) [pure virtual]

Add a number to the numeric integer value of a record.

Parameters:
kbuf the pointer to the key region.
ksiz the size of the key region.
num the additional number.
Returns:
the result value, or INT64_MIN on failure.

Implemented in kyotocabinet::BasicDB.

virtual int64_t kyotocabinet::DB::increment ( const std::string &  key,
int64_t  num 
) [pure virtual]

Add a number to the numeric integer value of a record.

Note:
Equal to the original DB::increment method except that the parameter is std::string.

Implemented in kyotocabinet::BasicDB.

virtual double kyotocabinet::DB::increment_double ( const char *  kbuf,
size_t  ksiz,
double  num 
) [pure virtual]

Add a number to the numeric double value of a record.

Parameters:
kbuf the pointer to the key region.
ksiz the size of the key region.
num the additional number.
Returns:
the result value, or Not-a-number on failure.

Implemented in kyotocabinet::BasicDB.

virtual double kyotocabinet::DB::increment_double ( const std::string &  key,
double  num 
) [pure virtual]

Add a number to the numeric double value of a record.

Note:
Equal to the original DB::increment_double method except that the parameter is std::string.

Implemented in kyotocabinet::BasicDB.

virtual bool kyotocabinet::DB::cas ( const char *  kbuf,
size_t  ksiz,
const char *  ovbuf,
size_t  ovsiz,
const char *  nvbuf,
size_t  nvsiz 
) [pure virtual]

Perform compare-and-swap.

Parameters:
kbuf the pointer to the key region.
ksiz the size of the key region.
ovbuf the pointer to the old value region. NULL means that no record corresponds.
ovsiz the size of the old value region.
nvbuf the pointer to the new value region. NULL means that the record is removed.
nvsiz the size of new old value region.
Returns:
true on success, or false on failure.

Implemented in kyotocabinet::BasicDB.

virtual bool kyotocabinet::DB::cas ( const std::string &  key,
const std::string &  ovalue,
const std::string &  nvalue 
) [pure virtual]

Perform compare-and-swap.

Note:
Equal to the original DB::cas method except that the parameters are std::string.

Implemented in kyotocabinet::BasicDB.

virtual bool kyotocabinet::DB::remove ( const char *  kbuf,
size_t  ksiz 
) [pure virtual]

Remove a record.

Parameters:
kbuf the pointer to the key region.
ksiz the size of the key region.
Returns:
true on success, or false on failure.
Note:
If no record corresponds to the key, false is returned.

Implemented in kyotocabinet::BasicDB.

virtual bool kyotocabinet::DB::remove ( const std::string &  key  )  [pure virtual]

Remove a record.

Note:
Equal to the original DB::remove method except that the parameter is std::string.

Implemented in kyotocabinet::BasicDB.

virtual char* kyotocabinet::DB::get ( const char *  kbuf,
size_t  ksiz,
size_t *  sp 
) [pure virtual]

Retrieve the value of a record.

Parameters:
kbuf the pointer to the key region.
ksiz the size of the key region.
sp the pointer to the variable into which the size of the region of the return value is assigned.
Returns:
the pointer to the value region of the corresponding record, or NULL on failure.
Note:
If no record corresponds to the key, NULL is returned. Because an additional zero code is appended at the end of the region of the return value, the return value can be treated as a C-style string. Because the region of the return value is allocated with the the new[] operator, it should be released with the delete[] operator when it is no longer in use.

Implemented in kyotocabinet::BasicDB.

virtual std::string* kyotocabinet::DB::get ( const std::string &  key  )  [pure virtual]

Retrieve the value of a record.

Note:
Equal to the original DB::get method except that the parameter and the return value are std::string. The return value should be deleted explicitly by the caller.

Implemented in kyotocabinet::BasicDB.

virtual int32_t kyotocabinet::DB::get ( const char *  kbuf,
size_t  ksiz,
char *  vbuf,
size_t  max 
) [pure virtual]

Retrieve the value of a record.

Parameters:
kbuf the pointer to the key region.
ksiz the size of the key region.
vbuf the pointer to the buffer into which the value of the corresponding record is written.
max the size of the buffer.
Returns:
the size of the value, or -1 on failure.

Implemented in kyotocabinet::BasicDB.

virtual bool kyotocabinet::DB::clear (  )  [pure virtual]
virtual int64_t kyotocabinet::DB::count (  )  [pure virtual]
virtual Cursor* kyotocabinet::DB::cursor (  )  [pure virtual]

Create a cursor object.

Returns:
the return value is the created cursor object.
Note:
Because the object of the return value is allocated by the constructor, it should be released with the delete operator when it is no longer in use.

Implemented in kyotocabinet::CacheDB, kyotocabinet::BasicDB, kyotocabinet::DirDB, kyotocabinet::HashDB, kyotocabinet::PlantDB< BASEDB, DBTYPE >, kyotocabinet::PolyDB, kyotocabinet::ProtoDB< STRMAP, DBTYPE >, and kyotocabinet::StashDB.

Generated on Sun Dec 19 12:53:11 2010 for Kyoto Cabinet by  doxygen 1.6.3