Kyoto Cabinet
|
Index database. More...
#include <kcdbext.h>
Public Member Functions | |
IndexDB () | |
Default constructor. | |
virtual | ~IndexDB () |
Destructor. | |
BasicDB::Error | error () const |
Get the last happened error. | |
void | set_error (const char *file, int32_t line, const char *func, BasicDB::Error::Code code, const char *message) |
Set the error information. | |
void | set_error (BasicDB::Error::Code code, const char *message) |
Set the error information without source code information. | |
bool | open (const std::string &path=":", uint32_t mode=BasicDB::OWRITER|BasicDB::OCREATE) |
Open a database file. | |
bool | close () |
Close the database file. | |
bool | set (const char *kbuf, size_t ksiz, const char *vbuf, size_t vsiz) |
Set the value of a record. | |
bool | set (const std::string &key, const std::string &value) |
Set the value of a record. | |
bool | add (const char *kbuf, size_t ksiz, const char *vbuf, size_t vsiz) |
Add a record. | |
bool | add (const std::string &key, const std::string &value) |
Set the value of a record. | |
bool | replace (const char *kbuf, size_t ksiz, const char *vbuf, size_t vsiz) |
Replace the value of a record. | |
bool | replace (const std::string &key, const std::string &value) |
Replace the value of a record. | |
bool | append (const char *kbuf, size_t ksiz, const char *vbuf, size_t vsiz) |
Append the value of a record. | |
bool | append (const std::string &key, const std::string &value) |
Set the value of a record. | |
bool | remove (const char *kbuf, size_t ksiz) |
Remove a record. | |
bool | remove (const std::string &key) |
Remove a record. | |
char * | get (const char *kbuf, size_t ksiz, size_t *sp) |
Retrieve the value of a record. | |
bool | get (const std::string &key, std::string *value) |
Retrieve the value of a record. | |
bool | synchronize (bool hard=false, BasicDB::FileProcessor *proc=NULL) |
Synchronize updated contents with the file and the device. | |
bool | clear () |
Remove all records. | |
int64_t | count () |
Get the number of records. | |
int64_t | size () |
Get the size of the database file. | |
std::string | path () |
Get the path of the database file. | |
bool | status (std::map< std::string, std::string > *strmap) |
Get the miscellaneous status information. | |
PolyDB * | reveal_inner_db () |
Reveal the inner database object. | |
BasicDB::Cursor * | cursor () |
Create a cursor object. | |
void | log (const char *file, int32_t line, const char *func, BasicDB::Logger::Kind kind, const char *message) |
Write a log message. | |
bool | tune_logger (BasicDB::Logger *logger, uint32_t kinds=BasicDB::Logger::WARN|BasicDB::Logger::ERROR) |
Set the internal logger. | |
bool | tune_meta_trigger (BasicDB::MetaTrigger *trigger) |
Set the internal meta operation trigger. | |
Protected Member Functions | |
void | report (const char *file, int32_t line, const char *func, const char *format,...) |
Report a message for debugging. |
Index database.
kyotocabinet::IndexDB::IndexDB | ( | ) | [explicit] |
Default constructor.
virtual kyotocabinet::IndexDB::~IndexDB | ( | ) | [virtual] |
Destructor.
BasicDB::Error kyotocabinet::IndexDB::error | ( | ) | const |
Get the last happened error.
void kyotocabinet::IndexDB::set_error | ( | const char * | file, |
int32_t | line, | ||
const char * | func, | ||
BasicDB::Error::Code | code, | ||
const char * | message | ||
) |
Set the error information.
file | the file name of the program source code. |
line | the line number of the program source code. |
func | the function name of the program source code. |
code | an error code. |
message | a supplement message. |
void kyotocabinet::IndexDB::set_error | ( | BasicDB::Error::Code | code, |
const char * | message | ||
) |
Set the error information without source code information.
code | an error code. |
message | a supplement message. |
bool kyotocabinet::IndexDB::open | ( | const std::string & | path = ":" , |
uint32_t | mode = BasicDB::OWRITER | BasicDB::OCREATE |
||
) |
Open a database file.
path | the path of a database file. The same as with PolyDB. In addition, the following tuning parameters are supported. "idxclim" specifies the limit size of the internal cache. "idxcbnum" the bucket number of the internal cache. "idxdbnum" specifies the number of internal databases. "idxtmppath' specifies the path of the temporary directory. |
mode | the connection mode. The same as with PolyDB. |
bool kyotocabinet::IndexDB::close | ( | ) |
Close the database file.
bool kyotocabinet::IndexDB::set | ( | const char * | kbuf, |
size_t | ksiz, | ||
const char * | vbuf, | ||
size_t | vsiz | ||
) |
Set the value of a record.
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. |
bool kyotocabinet::IndexDB::set | ( | const std::string & | key, |
const std::string & | value | ||
) |
Set the value of a record.
bool kyotocabinet::IndexDB::add | ( | const char * | kbuf, |
size_t | ksiz, | ||
const char * | vbuf, | ||
size_t | vsiz | ||
) |
Add a record.
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. |
bool kyotocabinet::IndexDB::add | ( | const std::string & | key, |
const std::string & | value | ||
) |
Set the value of a record.
bool kyotocabinet::IndexDB::replace | ( | const char * | kbuf, |
size_t | ksiz, | ||
const char * | vbuf, | ||
size_t | vsiz | ||
) |
Replace the value of a record.
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. |
bool kyotocabinet::IndexDB::replace | ( | const std::string & | key, |
const std::string & | value | ||
) |
Replace the value of a record.
bool kyotocabinet::IndexDB::append | ( | const char * | kbuf, |
size_t | ksiz, | ||
const char * | vbuf, | ||
size_t | vsiz | ||
) |
Append the value of a record.
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. |
bool kyotocabinet::IndexDB::append | ( | const std::string & | key, |
const std::string & | value | ||
) |
Set the value of a record.
bool kyotocabinet::IndexDB::remove | ( | const char * | kbuf, |
size_t | ksiz | ||
) |
Remove a record.
kbuf | the pointer to the key region. |
ksiz | the size of the key region. |
bool kyotocabinet::IndexDB::remove | ( | const std::string & | key | ) |
Remove a record.
char* kyotocabinet::IndexDB::get | ( | const char * | kbuf, |
size_t | ksiz, | ||
size_t * | sp | ||
) |
Retrieve the value of a record.
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. |
bool kyotocabinet::IndexDB::get | ( | const std::string & | key, |
std::string * | value | ||
) |
Retrieve the value of a record.
bool kyotocabinet::IndexDB::synchronize | ( | bool | hard = false , |
BasicDB::FileProcessor * | proc = NULL |
||
) |
Synchronize updated contents with the file and the device.
hard | true for physical synchronization with the device, or false for logical synchronization with the file system. |
proc | a postprocessor object. If it is NULL, no postprocessing is performed. |
bool kyotocabinet::IndexDB::clear | ( | ) |
Remove all records.
int64_t kyotocabinet::IndexDB::count | ( | ) |
Get the number of records.
int64_t kyotocabinet::IndexDB::size | ( | ) |
Get the size of the database file.
std::string kyotocabinet::IndexDB::path | ( | ) |
Get the path of the database file.
bool kyotocabinet::IndexDB::status | ( | std::map< std::string, std::string > * | strmap | ) |
Get the miscellaneous status information.
strmap | a string map to contain the result. |
Reveal the inner database object.
Create a cursor object.
void kyotocabinet::IndexDB::log | ( | const char * | file, |
int32_t | line, | ||
const char * | func, | ||
BasicDB::Logger::Kind | kind, | ||
const char * | message | ||
) |
Write a log message.
file | the file name of the program source code. |
line | the line number of the program source code. |
func | the function name of the program source code. |
kind | the kind of the event. Logger::DEBUG for debugging, Logger::INFO for normal information, Logger::WARN for warning, and Logger::ERROR for fatal error. |
message | the supplement message. |
bool kyotocabinet::IndexDB::tune_logger | ( | BasicDB::Logger * | logger, |
uint32_t | kinds = BasicDB::Logger::WARN | BasicDB::Logger::ERROR |
||
) |
Set the internal logger.
logger | the logger object. |
kinds | kinds of logged messages by bitwise-or: Logger::DEBUG for debugging, Logger::INFO for normal information, Logger::WARN for warning, and Logger::ERROR for fatal error. |
bool kyotocabinet::IndexDB::tune_meta_trigger | ( | BasicDB::MetaTrigger * | trigger | ) |
Set the internal meta operation trigger.
trigger | the trigger object. |
void kyotocabinet::IndexDB::report | ( | const char * | file, |
int32_t | line, | ||
const char * | func, | ||
const char * | format, | ||
... | |||
) | [protected] |
Report a message for debugging.
file | the file name of the program source code. |
line | the line number of the program source code. |
func | the function name of the program source code. |
format | the printf-like format string. |
... | used according to the format string. |