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 Types

enum  Type {
  TYPEVOID = 0x00, TYPEPHASH = 0x01, TYPEPTREE = 0x02, TYPEPMISC = 0x08,
  TYPECACHE = 0x09, TYPEHASH = 0x11, TYPETREE = 0x12, TYPEMISC = 0x20
}
 

Database types.

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 iterate (Visitor *visitor, bool writable=true)=0
 Iterate to accept a visitor for each 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 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 value of a record.
virtual int64_t increment (const std::string &key, int64_t num)=0
 Add a number to the numeric value of a record.
virtual double increment (const char *kbuf, size_t ksiz, double num)=0
 Add a number to the numeric value of a record.
virtual double increment (const std::string &key, double num)=0
 Add a number to the numeric 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.

Static Public Member Functions

static const char * typestring (uint32_t type)
 Get the string of a database type.

Detailed Description

Interface of database abstraction.


Member Enumeration Documentation

Database types.

Enumerator:
TYPEVOID 

void database

TYPEPHASH 

prototype hash database

TYPEPTREE 

prototype tree database

TYPEPMISC 

miscellaneous prototype database

TYPECACHE 

cache database

TYPEHASH 

file hash database

TYPETREE 

file tree database

TYPEMISC 

miscellaneous database


Constructor & Destructor Documentation

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

Destructor.


Member Function Documentation

static const char* kyotocabinet::DB::typestring ( uint32_t  type  )  [static]

Get the string of a database type.

Parameters:
type the database type.
Returns:
the string of the type name.
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.

Implemented in kyotocabinet::CacheDB, kyotocabinet::HashDB, kyotocabinet::PolyDB, kyotocabinet::ProtoDB< STRMAP >, and kyotocabinet::TreeDB.

virtual bool kyotocabinet::DB::iterate ( Visitor visitor,
bool  writable = true 
) [pure virtual]

Iterate to accept a visitor for each record.

Parameters:
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 whole iteration is performed atomically and other threads are blocked.

Implemented in kyotocabinet::CacheDB, kyotocabinet::HashDB, kyotocabinet::PolyDB, kyotocabinet::ProtoDB< STRMAP >, and kyotocabinet::TreeDB.

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::FileDB.

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::FileDB.

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::FileDB.

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::FileDB.

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::FileDB.

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::FileDB.

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

Add a number to the numeric 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::FileDB.

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

Add a number to the numeric value of a record.

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

Implemented in kyotocabinet::FileDB.

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

Add a number to the numeric value of a record.

Note:
Equal to the original DB::increment method except that the parameter and the return value are double. Not-a-number is returned on failure.

Implemented in kyotocabinet::FileDB.

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

Add a number to the numeric value of a record.

Note:
Equal to the original DB::increment method except that the parameter is std::string and the return value is double. Not-a-number is returned on failure.

Implemented in kyotocabinet::FileDB.

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::FileDB.

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::FileDB.

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::FileDB.

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::FileDB.

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::FileDB.

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::FileDB.

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::FileDB.

virtual bool kyotocabinet::DB::clear (  )  [pure virtual]

Remove all records.

Returns:
true on success, or false on failure.

Implemented in kyotocabinet::CacheDB, kyotocabinet::HashDB, kyotocabinet::PolyDB, kyotocabinet::ProtoDB< STRMAP >, and kyotocabinet::TreeDB.

virtual int64_t kyotocabinet::DB::count (  )  [pure virtual]

Get the number of records.

Returns:
the number of records, or -1 on failure.

Implemented in kyotocabinet::CacheDB, kyotocabinet::HashDB, kyotocabinet::PolyDB, kyotocabinet::ProtoDB< STRMAP >, and kyotocabinet::TreeDB.

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::FileDB, kyotocabinet::HashDB, kyotocabinet::PolyDB, kyotocabinet::ProtoDB< STRMAP >, and kyotocabinet::TreeDB.

Generated on Thu May 27 17:50:47 2010 for Kyoto Cabinet by  doxygen 1.6.3