Kyoto Cabinet
|
Directory hash database. More...
#include <kcdirdb.h>
Classes | |
class | Cursor |
Cursor to indicate a record. More... | |
struct | Record |
Record data. | |
class | ScopedVisitor |
Scoped visitor. | |
Public Types | |
enum | Option { TSMALL = 1 << 0, TLINEAR = 1 << 1, TCOMPRESS = 1 << 2 } |
Tuning options. More... | |
enum | Flag { FOPEN = 1 << 0, FFATAL = 1 << 1 } |
Status flags. More... | |
Public Member Functions | |
DirDB () | |
Default constructor. | |
virtual | ~DirDB () |
Destructor. | |
bool | accept (const char *kbuf, size_t ksiz, Visitor *visitor, bool writable=true) |
Accept a visitor to a record. | |
bool | accept_bulk (const std::vector< std::string > &keys, Visitor *visitor, bool writable=true) |
Accept a visitor to multiple records at once. | |
bool | iterate (Visitor *visitor, bool writable=true, ProgressChecker *checker=NULL) |
Iterate to accept a visitor for each record. | |
bool | scan_parallel (Visitor *visitor, size_t thnum, ProgressChecker *checker=NULL) |
Scan each record in parallel. | |
Error | error () const |
Get the last happened error. | |
void | set_error (const char *file, int32_t line, const char *func, Error::Code code, const char *message) |
Set the error information. | |
bool | open (const std::string &path, uint32_t mode=OWRITER|OCREATE) |
Open a database file. | |
bool | close () |
Close the database file. | |
bool | synchronize (bool hard=false, FileProcessor *proc=NULL, ProgressChecker *checker=NULL) |
Synchronize updated contents with the file and the device. | |
bool | occupy (bool writable=true, FileProcessor *proc=NULL) |
Occupy database by locking and do something meanwhile. | |
bool | begin_transaction (bool hard=false) |
Begin transaction. | |
bool | begin_transaction_try (bool hard=false) |
Try to begin transaction. | |
bool | end_transaction (bool commit=true) |
End transaction. | |
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. | |
Cursor * | cursor () |
Create a cursor object. | |
void | log (const char *file, int32_t line, const char *func, Logger::Kind kind, const char *message) |
Write a log message. | |
bool | tune_logger (Logger *logger, uint32_t kinds=Logger::WARN|Logger::ERROR) |
Set the internal logger. | |
bool | tune_meta_trigger (MetaTrigger *trigger) |
Set the internal meta operation trigger. | |
bool | tune_options (int8_t opts) |
Set the optional features. | |
bool | tune_compressor (Compressor *comp) |
Set the data compressor. | |
char * | opaque () |
Get the opaque data. | |
bool | synchronize_opaque () |
Synchronize the opaque data. | |
uint8_t | flags () |
Get the status flags. | |
Protected Member Functions | |
void | report (const char *file, int32_t line, const char *func, Logger::Kind kind, const char *format,...) |
Report a message for debugging. | |
void | report_valist (const char *file, int32_t line, const char *func, Logger::Kind kind, const char *format, va_list ap) |
Report a message for debugging with variable number of arguments. | |
void | report_binary (const char *file, int32_t line, const char *func, Logger::Kind kind, const char *name, const char *buf, size_t size) |
Report the content of a binary buffer for debugging. | |
void | trigger_meta (MetaTrigger::Kind kind, const char *message) |
Trigger a meta database operation. | |
bool | tune_type (int8_t type) |
Set the database type. | |
uint8_t | libver () |
Get the library version. | |
uint8_t | librev () |
Get the library revision. | |
uint8_t | fmtver () |
Get the format version. | |
uint8_t | chksum () |
Get the module checksum. | |
uint8_t | type () |
Get the database type. | |
uint8_t | opts () |
Get the options. | |
Compressor * | comp () |
Get the data compressor. | |
bool | recovered () |
Check whether the database was recovered or not. | |
bool | reorganized () |
Check whether the database was reorganized or not. | |
Friends | |
class | PlantDB< DirDB, BasicDB::TYPEFOREST > |
Directory hash database.
kyotocabinet::DirDB::DirDB | ( | ) | [explicit] |
Default constructor.
virtual kyotocabinet::DirDB::~DirDB | ( | ) | [virtual] |
Destructor.
bool kyotocabinet::DirDB::accept | ( | const char * | kbuf, |
size_t | ksiz, | ||
Visitor * | visitor, | ||
bool | writable = true |
||
) | [virtual] |
Accept a visitor to a record.
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. |
Implements kyotocabinet::DB.
bool kyotocabinet::DirDB::accept_bulk | ( | const std::vector< std::string > & | keys, |
Visitor * | visitor, | ||
bool | writable = true |
||
) | [virtual] |
Accept a visitor to multiple records at once.
keys | specifies a string vector of the keys. |
visitor | a visitor object. |
writable | true for writable operation, or false for read-only operation. |
Implements kyotocabinet::BasicDB.
bool kyotocabinet::DirDB::iterate | ( | Visitor * | visitor, |
bool | writable = true , |
||
ProgressChecker * | checker = NULL |
||
) | [virtual] |
Iterate to accept a visitor for each record.
visitor | a visitor object. |
writable | true for writable operation, or false for read-only operation. |
checker | a progress checker object. If it is NULL, no checking is performed. |
Implements kyotocabinet::BasicDB.
bool kyotocabinet::DirDB::scan_parallel | ( | Visitor * | visitor, |
size_t | thnum, | ||
ProgressChecker * | checker = NULL |
||
) | [virtual] |
Scan each record in parallel.
visitor | a visitor object. |
thnum | the number of worker threads. |
checker | a progress checker object. If it is NULL, no checking is performed. |
Implements kyotocabinet::BasicDB.
Error kyotocabinet::DirDB::error | ( | ) | const [virtual] |
void kyotocabinet::DirDB::set_error | ( | const char * | file, |
int32_t | line, | ||
const char * | func, | ||
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. |
bool kyotocabinet::DirDB::open | ( | const std::string & | path, |
uint32_t | mode = OWRITER | OCREATE |
||
) | [virtual] |
Open a database file.
path | the path of a database file. |
mode | the connection mode. DirDB::OWRITER as a writer, DirDB::OREADER as a reader. The following may be added to the writer mode by bitwise-or: DirDB::OCREATE, which means it creates a new database if the file does not exist, DirDB::OTRUNCATE, which means it creates a new database regardless if the file exists, DirDB::OAUTOTRAN, which means each updating operation is performed in implicit transaction, DirDB::OAUTOSYNC, which means each updating operation is followed by implicit synchronization with the file system. The following may be added to both of the reader mode and the writer mode by bitwise-or: DirDB::ONOLOCK, which means it opens the database file without file locking, DirDB::OTRYLOCK, which means locking is performed without blocking, DirDB::ONOREPAIR, which means the database file is not repaired implicitly even if file destruction is detected. |
Implements kyotocabinet::BasicDB.
bool kyotocabinet::DirDB::close | ( | ) | [virtual] |
Close the database file.
Implements kyotocabinet::BasicDB.
bool kyotocabinet::DirDB::synchronize | ( | bool | hard = false , |
FileProcessor * | proc = NULL , |
||
ProgressChecker * | checker = NULL |
||
) | [virtual] |
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. |
checker | a progress checker object. If it is NULL, no checking is performed. |
Implements kyotocabinet::BasicDB.
bool kyotocabinet::DirDB::occupy | ( | bool | writable = true , |
FileProcessor * | proc = NULL |
||
) | [virtual] |
Occupy database by locking and do something meanwhile.
writable | true to use writer lock, or false to use reader lock. |
proc | a processor object. If it is NULL, no processing is performed. |
Implements kyotocabinet::BasicDB.
bool kyotocabinet::DirDB::begin_transaction | ( | bool | hard = false | ) | [virtual] |
Begin transaction.
hard | true for physical synchronization with the device, or false for logical synchronization with the file system. |
Implements kyotocabinet::BasicDB.
bool kyotocabinet::DirDB::begin_transaction_try | ( | bool | hard = false | ) | [virtual] |
Try to begin transaction.
hard | true for physical synchronization with the device, or false for logical synchronization with the file system. |
Implements kyotocabinet::BasicDB.
bool kyotocabinet::DirDB::end_transaction | ( | bool | commit = true | ) | [virtual] |
End transaction.
commit | true to commit the transaction, or false to abort the transaction. |
Implements kyotocabinet::BasicDB.
bool kyotocabinet::DirDB::clear | ( | ) | [virtual] |
int64_t kyotocabinet::DirDB::count | ( | ) | [virtual] |
Get the number of records.
Implements kyotocabinet::DB.
int64_t kyotocabinet::DirDB::size | ( | ) | [virtual] |
Get the size of the database file.
Implements kyotocabinet::BasicDB.
std::string kyotocabinet::DirDB::path | ( | ) | [virtual] |
Get the path of the database file.
Implements kyotocabinet::BasicDB.
bool kyotocabinet::DirDB::status | ( | std::map< std::string, std::string > * | strmap | ) | [virtual] |
Get the miscellaneous status information.
strmap | a string map to contain the result. |
Implements kyotocabinet::BasicDB.
Cursor* kyotocabinet::DirDB::cursor | ( | ) | [virtual] |
Create a cursor object.
Implements kyotocabinet::BasicDB.
void kyotocabinet::DirDB::log | ( | const char * | file, |
int32_t | line, | ||
const char * | func, | ||
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::DirDB::tune_logger | ( | Logger * | logger, |
uint32_t | kinds = Logger::WARN | Logger::ERROR |
||
) | [virtual] |
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. |
Implements kyotocabinet::BasicDB.
bool kyotocabinet::DirDB::tune_meta_trigger | ( | MetaTrigger * | trigger | ) | [virtual] |
Set the internal meta operation trigger.
trigger | the trigger object. |
Implements kyotocabinet::BasicDB.
bool kyotocabinet::DirDB::tune_options | ( | int8_t | opts | ) |
Set the optional features.
opts | the optional features by bitwise-or: DirDB::TCOMPRESS to compress each record. |
bool kyotocabinet::DirDB::tune_compressor | ( | Compressor * | comp | ) |
Set the data compressor.
comp | the data compressor object. |
char* kyotocabinet::DirDB::opaque | ( | ) |
Get the opaque data.
Synchronize the opaque data.
uint8_t kyotocabinet::DirDB::flags | ( | ) |
Get the status flags.
void kyotocabinet::DirDB::report | ( | const char * | file, |
int32_t | line, | ||
const char * | func, | ||
Logger::Kind | kind, | ||
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. |
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. |
format | the printf-like format string. |
... | used according to the format string. |
void kyotocabinet::DirDB::report_valist | ( | const char * | file, |
int32_t | line, | ||
const char * | func, | ||
Logger::Kind | kind, | ||
const char * | format, | ||
va_list | ap | ||
) | [protected] |
Report a message for debugging with variable number of arguments.
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. |
format | the printf-like format string. |
ap | used according to the format string. |
void kyotocabinet::DirDB::report_binary | ( | const char * | file, |
int32_t | line, | ||
const char * | func, | ||
Logger::Kind | kind, | ||
const char * | name, | ||
const char * | buf, | ||
size_t | size | ||
) | [protected] |
Report the content of a binary buffer for debugging.
file | the file name of the epicenter. |
line | the line number of the epicenter. |
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. |
name | the name of the information. |
buf | the binary buffer. |
size | the size of the binary buffer |
void kyotocabinet::DirDB::trigger_meta | ( | MetaTrigger::Kind | kind, |
const char * | message | ||
) | [protected] |
Trigger a meta database operation.
kind | the kind of the event. MetaTrigger::OPEN for opening, MetaTrigger::CLOSE for closing, MetaTrigger::CLEAR for clearing, MetaTrigger::ITERATE for iteration, MetaTrigger::SYNCHRONIZE for synchronization, MetaTrigger::BEGINTRAN for beginning transaction, MetaTrigger::COMMITTRAN for committing transaction, MetaTrigger::ABORTTRAN for aborting transaction, and MetaTrigger::MISC for miscellaneous operations. |
message | the supplement message. |
bool kyotocabinet::DirDB::tune_type | ( | int8_t | type | ) | [protected] |
Set the database type.
type | the database type. |
uint8_t kyotocabinet::DirDB::libver | ( | ) | [protected] |
Get the library version.
uint8_t kyotocabinet::DirDB::librev | ( | ) | [protected] |
Get the library revision.
uint8_t kyotocabinet::DirDB::fmtver | ( | ) | [protected] |
Get the format version.
uint8_t kyotocabinet::DirDB::chksum | ( | ) | [protected] |
Get the module checksum.
uint8_t kyotocabinet::DirDB::type | ( | ) | [protected] |
Get the database type.
uint8_t kyotocabinet::DirDB::opts | ( | ) | [protected] |
Get the options.
Compressor* kyotocabinet::DirDB::comp | ( | ) | [protected] |
Get the data compressor.
bool kyotocabinet::DirDB::recovered | ( | ) | [protected] |
Check whether the database was recovered or not.
bool kyotocabinet::DirDB::reorganized | ( | ) | [protected] |
Check whether the database was reorganized or not.