Kyoto Tycoon
|
Timed database. More...
#include <kttimeddb.h>
Classes | |
class | Cursor |
Cursor to indicate a record. More... | |
struct | MergeLine |
Front line of a merging list. | |
class | TimedMetaTrigger |
Trigger of meta database operations. | |
class | TimedVisitor |
Visitor to handle records with time stamps. | |
class | UpdateTrigger |
Interface to trigger update operations. More... | |
class | Visitor |
Interface to access a record. More... | |
Public Types | |
enum | MergeMode { MSET, MADD, MREPLACE, MAPPEND } |
Merge modes. More... | |
Public Member Functions | |
TimedDB () | |
Default constructor. | |
virtual | ~TimedDB () |
Destructor. | |
bool | set_internal_db (kc::BasicDB *db) |
Set the internal database object. | |
kc::BasicDB::Error | error () const |
Get the last happened error. | |
void | set_error (kc::BasicDB::Error::Code code, const char *message) |
Set the error information. | |
bool | open (const std::string &path=":", uint32_t mode=kc::BasicDB::OWRITER|kc::BasicDB::OCREATE) |
Open a database file. | |
bool | close () |
Close the database file. | |
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, kc::BasicDB::ProgressChecker *checker=NULL) |
Iterate to accept a visitor for each record. | |
bool | scan_parallel (Visitor *visitor, size_t thnum, kc::BasicDB::ProgressChecker *checker=NULL) |
Scan each record in parallel. | |
bool | synchronize (bool hard=false, kc::BasicDB::FileProcessor *proc=NULL, kc::BasicDB::ProgressChecker *checker=NULL) |
Synchronize updated contents with the file and the device. | |
bool | occupy (bool writable=true, kc::BasicDB::FileProcessor *proc=NULL) |
Occupy database by locking and do something meanwhile. | |
bool | copy (const std::string &dest, kc::BasicDB::ProgressChecker *checker=NULL) |
Create a copy of the database file. | |
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. | |
bool | set (const char *kbuf, size_t ksiz, const char *vbuf, size_t vsiz, int64_t xt=kc::INT64MAX) |
Set the value of a record. | |
bool | set (const std::string &key, const std::string &value, int64_t xt=kc::INT64MAX) |
Set the value of a record. | |
bool | add (const char *kbuf, size_t ksiz, const char *vbuf, size_t vsiz, int64_t xt=kc::INT64MAX) |
Add a record. | |
bool | add (const std::string &key, const std::string &value, int64_t xt=kc::INT64MAX) |
Set the value of a record. | |
bool | replace (const char *kbuf, size_t ksiz, const char *vbuf, size_t vsiz, int64_t xt=kc::INT64MAX) |
Replace the value of a record. | |
bool | replace (const std::string &key, const std::string &value, int64_t xt=kc::INT64MAX) |
Replace the value of a record. | |
bool | append (const char *kbuf, size_t ksiz, const char *vbuf, size_t vsiz, int64_t xt=kc::INT64MAX) |
Append the value of a record. | |
bool | append (const std::string &key, const std::string &value, int64_t xt=kc::INT64MAX) |
Set the value of a record. | |
int64_t | increment (const char *kbuf, size_t ksiz, int64_t num, int64_t orig=0, int64_t xt=kc::INT64MAX) |
Add a number to the numeric integer value of a record. | |
int64_t | increment (const std::string &key, int64_t num, int64_t orig=0, int64_t xt=kc::INT64MAX) |
Add a number to the numeric integer value of a record. | |
double | increment_double (const char *kbuf, size_t ksiz, double num, double orig=0, int64_t xt=kc::INT64MAX) |
Add a number to the numeric double value of a record. | |
double | increment_double (const std::string &key, double num, double orig=0, int64_t xt=kc::INT64MAX) |
Add a number to the numeric double value of a record. | |
bool | cas (const char *kbuf, size_t ksiz, const char *ovbuf, size_t ovsiz, const char *nvbuf, size_t nvsiz, int64_t xt=kc::INT64MAX) |
Perform compare-and-swap. | |
bool | cas (const std::string &key, const std::string &ovalue, const std::string &nvalue, int64_t xt=kc::INT64MAX) |
Perform compare-and-swap. | |
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, int64_t *xtp=NULL) |
Retrieve the value of a record. | |
bool | get (const std::string &key, std::string *value, int64_t *xtp=NULL) |
Retrieve the value of a record. | |
int32_t | get (const char *kbuf, size_t ksiz, char *vbuf, size_t max, int64_t *xtp=NULL) |
Retrieve the value of a record. | |
int32_t | check (const char *kbuf, size_t ksiz, int64_t *xtp=NULL) |
Check the existence of a record. | |
int32_t | check (const std::string &key, int64_t *xtp=NULL) |
Check the existence of a record. | |
char * | seize (const char *kbuf, size_t ksiz, size_t *sp, int64_t *xtp=NULL) |
Retrieve the value of a record and remove it atomically. | |
bool | seize (const std::string &key, std::string *value, int64_t *xtp=NULL) |
Retrieve the value of a record and remove it atomically. | |
int64_t | set_bulk (const std::map< std::string, std::string > &recs, int64_t xt=kc::INT64MAX, bool atomic=true) |
Store records at once. | |
int64_t | remove_bulk (const std::vector< std::string > &keys, bool atomic=true) |
Remove records at once. | |
int64_t | get_bulk (const std::vector< std::string > &keys, std::map< std::string, std::string > *recs, bool atomic=true) |
Retrieve records at once. | |
bool | dump_snapshot (std::ostream *dest, kc::BasicDB::ProgressChecker *checker=NULL) |
Dump records into a data stream. | |
bool | dump_snapshot (const std::string &dest, kc::BasicDB::ProgressChecker *checker=NULL) |
Dump records into a file. | |
bool | load_snapshot (std::istream *src, kc::BasicDB::ProgressChecker *checker=NULL) |
Load records from a data stream. | |
bool | load_snapshot (const std::string &src, kc::BasicDB::ProgressChecker *checker=NULL) |
Load records from a file. | |
bool | dump_snapshot_atomic (const std::string &dest, kc::Compressor *zcomp=NULL, kc::BasicDB::ProgressChecker *checker=NULL) |
Dump records atomically into a file. | |
bool | load_snapshot_atomic (const std::string &src, kc::Compressor *zcomp=NULL, kc::BasicDB::ProgressChecker *checker=NULL) |
Load records atomically from a file. | |
kc::BasicDB * | reveal_inner_db () |
Reveal the inner database object. | |
bool | vacuum (int64_t step=0) |
Scan the database and eliminate regions of expired records. | |
bool | recover (const char *mbuf, size_t msiz) |
Recover the database with an update log message. | |
int64_t | match_prefix (const std::string &prefix, std::vector< std::string > *strvec, int64_t max=-1, kc::BasicDB::ProgressChecker *checker=NULL) |
Get keys matching a prefix string. | |
int64_t | match_regex (const std::string ®ex, std::vector< std::string > *strvec, int64_t max=-1, kc::BasicDB::ProgressChecker *checker=NULL) |
Get keys matching a regular expression string. | |
int64_t | match_similar (const std::string &origin, size_t range, bool utf, std::vector< std::string > *strvec, int64_t max=-1, kc::BasicDB::ProgressChecker *checker=NULL) |
Get keys similar to a string in terms of the levenshtein distance. | |
bool | merge (TimedDB **srcary, size_t srcnum, MergeMode mode=MSET, kc::BasicDB::ProgressChecker *checker=NULL) |
Merge records from other databases. | |
Cursor * | cursor () |
Create a cursor object. | |
bool | tune_logger (kc::BasicDB::Logger *logger, uint32_t kinds=kc::BasicDB::Logger::WARN|kc::BasicDB::Logger::ERROR) |
Set the internal logger. | |
bool | tune_update_trigger (UpdateTrigger *trigger) |
Set the internal update trigger. | |
Static Public Member Functions | |
static bool | tokenize_update_log (const char *mbuf, size_t msiz, std::vector< std::string > *tokens) |
Tokenize an update log message. | |
static bool | status_snapshot_atomic (const std::string &src, uint64_t *tsp=NULL, int64_t *cntp=NULL, int64_t *sizp=NULL) |
Get status of an atomic snapshot file. | |
Static Public Attributes | |
static const int32_t | XTWIDTH = 5 |
The width of expiration time. | |
static const int64_t | XTMAX = (1LL << (XTWIDTH * 8)) - 1 |
The maximum number of expiration time. |
Timed database.
kyototycoon::TimedDB::TimedDB | ( | ) | [explicit] |
Default constructor.
virtual kyototycoon::TimedDB::~TimedDB | ( | ) | [virtual] |
Destructor.
bool kyototycoon::TimedDB::set_internal_db | ( | kc::BasicDB * | db | ) |
Set the internal database object.
db | the internal database object. Its possession is transferred inside and the object is deleted automatically. |
kc::BasicDB::Error kyototycoon::TimedDB::error | ( | ) | const |
Get the last happened error.
void kyototycoon::TimedDB::set_error | ( | kc::BasicDB::Error::Code | code, |
const char * | message | ||
) |
Set the error information.
code | an error code. |
message | a supplement message. |
bool kyototycoon::TimedDB::open | ( | const std::string & | path = ":" , |
uint32_t | mode = kc::BasicDB::OWRITER | kc::BasicDB::OCREATE |
||
) |
Open a database file.
path | the path of a database file. The same as with kc::PolyDB. In addition, the following tuning parameters are supported. "ktopts" sets options and the value can contain "p" for the persistent option. "ktcapcnt" sets the capacity by record number. "ktcapsiz" sets the capacity by database size. |
mode | the connection mode. The same as with kc::PolyDB. |
bool kyototycoon::TimedDB::close | ( | ) |
Close the database file.
bool kyototycoon::TimedDB::accept | ( | const char * | kbuf, |
size_t | ksiz, | ||
Visitor * | visitor, | ||
bool | writable = true |
||
) |
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. |
bool kyototycoon::TimedDB::accept_bulk | ( | const std::vector< std::string > & | keys, |
Visitor * | visitor, | ||
bool | writable = true |
||
) |
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. |
bool kyototycoon::TimedDB::iterate | ( | Visitor * | visitor, |
bool | writable = true , |
||
kc::BasicDB::ProgressChecker * | checker = NULL |
||
) |
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. |
bool kyototycoon::TimedDB::scan_parallel | ( | Visitor * | visitor, |
size_t | thnum, | ||
kc::BasicDB::ProgressChecker * | checker = NULL |
||
) |
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. |
bool kyototycoon::TimedDB::synchronize | ( | bool | hard = false , |
kc::BasicDB::FileProcessor * | proc = NULL , |
||
kc::BasicDB::ProgressChecker * | checker = 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. |
checker | a progress checker object. If it is NULL, no checking is performed. |
bool kyototycoon::TimedDB::occupy | ( | bool | writable = true , |
kc::BasicDB::FileProcessor * | proc = NULL |
||
) |
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. |
bool kyototycoon::TimedDB::copy | ( | const std::string & | dest, |
kc::BasicDB::ProgressChecker * | checker = NULL |
||
) |
Create a copy of the database file.
dest | the path of the destination file. |
checker | a progress checker object. If it is NULL, no checking is performed. |
bool kyototycoon::TimedDB::begin_transaction | ( | bool | hard = false | ) |
Begin transaction.
hard | true for physical synchronization with the device, or false for logical synchronization with the file system. |
bool kyototycoon::TimedDB::begin_transaction_try | ( | bool | hard = false | ) |
Try to begin transaction.
hard | true for physical synchronization with the device, or false for logical synchronization with the file system. |
bool kyototycoon::TimedDB::end_transaction | ( | bool | commit = true | ) |
End transaction.
commit | true to commit the transaction, or false to abort the transaction. |
bool kyototycoon::TimedDB::clear | ( | ) |
Remove all records.
int64_t kyototycoon::TimedDB::count | ( | ) |
Get the number of records.
int64_t kyototycoon::TimedDB::size | ( | ) |
Get the size of the database file.
std::string kyototycoon::TimedDB::path | ( | ) |
Get the path of the database file.
bool kyototycoon::TimedDB::status | ( | std::map< std::string, std::string > * | strmap | ) |
Get the miscellaneous status information.
strmap | a string map to contain the result. |
bool kyototycoon::TimedDB::set | ( | const char * | kbuf, |
size_t | ksiz, | ||
const char * | vbuf, | ||
size_t | vsiz, | ||
int64_t | xt = kc::INT64MAX |
||
) |
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. |
xt | the expiration time from now in seconds. If it is negative, the absolute value is treated as the epoch time. |
bool kyototycoon::TimedDB::set | ( | const std::string & | key, |
const std::string & | value, | ||
int64_t | xt = kc::INT64MAX |
||
) |
Set the value of a record.
bool kyototycoon::TimedDB::add | ( | const char * | kbuf, |
size_t | ksiz, | ||
const char * | vbuf, | ||
size_t | vsiz, | ||
int64_t | xt = kc::INT64MAX |
||
) |
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. |
xt | the expiration time from now in seconds. If it is negative, the absolute value is treated as the epoch time. |
bool kyototycoon::TimedDB::add | ( | const std::string & | key, |
const std::string & | value, | ||
int64_t | xt = kc::INT64MAX |
||
) |
Set the value of a record.
bool kyototycoon::TimedDB::replace | ( | const char * | kbuf, |
size_t | ksiz, | ||
const char * | vbuf, | ||
size_t | vsiz, | ||
int64_t | xt = kc::INT64MAX |
||
) |
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. |
xt | the expiration time from now in seconds. If it is negative, the absolute value is treated as the epoch time. |
bool kyototycoon::TimedDB::replace | ( | const std::string & | key, |
const std::string & | value, | ||
int64_t | xt = kc::INT64MAX |
||
) |
Replace the value of a record.
bool kyototycoon::TimedDB::append | ( | const char * | kbuf, |
size_t | ksiz, | ||
const char * | vbuf, | ||
size_t | vsiz, | ||
int64_t | xt = kc::INT64MAX |
||
) |
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. |
xt | the expiration time from now in seconds. If it is negative, the absolute value is treated as the epoch time. |
bool kyototycoon::TimedDB::append | ( | const std::string & | key, |
const std::string & | value, | ||
int64_t | xt = kc::INT64MAX |
||
) |
Set the value of a record.
int64_t kyototycoon::TimedDB::increment | ( | const char * | kbuf, |
size_t | ksiz, | ||
int64_t | num, | ||
int64_t | orig = 0 , |
||
int64_t | xt = kc::INT64MAX |
||
) |
Add a number to the numeric integer value of a record.
kbuf | the pointer to the key region. |
ksiz | the size of the key region. |
num | the additional number. |
orig | the origin number if no record corresponds to the key. If it is INT64MIN and no record corresponds, this function fails. If it is INT64MAX, the value is set as the additional number regardless of the current value. |
xt | the expiration time from now in seconds. If it is negative, the absolute value is treated as the epoch time. |
int64_t kyototycoon::TimedDB::increment | ( | const std::string & | key, |
int64_t | num, | ||
int64_t | orig = 0 , |
||
int64_t | xt = kc::INT64MAX |
||
) |
Add a number to the numeric integer value of a record.
double kyototycoon::TimedDB::increment_double | ( | const char * | kbuf, |
size_t | ksiz, | ||
double | num, | ||
double | orig = 0 , |
||
int64_t | xt = kc::INT64MAX |
||
) |
Add a number to the numeric double value of a record.
kbuf | the pointer to the key region. |
ksiz | the size of the key region. |
num | the additional number. |
orig | the origin number if no record corresponds to the key. If it is negative infinity and no record corresponds, this function fails. If it is positive infinity, the value is set as the additional number regardless of the current value. |
xt | the expiration time from now in seconds. If it is negative, the absolute value is treated as the epoch time. |
double kyototycoon::TimedDB::increment_double | ( | const std::string & | key, |
double | num, | ||
double | orig = 0 , |
||
int64_t | xt = kc::INT64MAX |
||
) |
Add a number to the numeric double value of a record.
bool kyototycoon::TimedDB::cas | ( | const char * | kbuf, |
size_t | ksiz, | ||
const char * | ovbuf, | ||
size_t | ovsiz, | ||
const char * | nvbuf, | ||
size_t | nvsiz, | ||
int64_t | xt = kc::INT64MAX |
||
) |
Perform compare-and-swap.
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. |
xt | the expiration time from now in seconds. If it is negative, the absolute value is treated as the epoch time. |
bool kyototycoon::TimedDB::cas | ( | const std::string & | key, |
const std::string & | ovalue, | ||
const std::string & | nvalue, | ||
int64_t | xt = kc::INT64MAX |
||
) |
Perform compare-and-swap.
bool kyototycoon::TimedDB::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 kyototycoon::TimedDB::remove | ( | const std::string & | key | ) |
Remove a record.
char* kyototycoon::TimedDB::get | ( | const char * | kbuf, |
size_t | ksiz, | ||
size_t * | sp, | ||
int64_t * | xtp = NULL |
||
) |
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. |
xtp | the pointer to the variable into which the absolute expiration time is assigned. If it is NULL, it is ignored. |
bool kyototycoon::TimedDB::get | ( | const std::string & | key, |
std::string * | value, | ||
int64_t * | xtp = NULL |
||
) |
Retrieve the value of a record.
int32_t kyototycoon::TimedDB::get | ( | const char * | kbuf, |
size_t | ksiz, | ||
char * | vbuf, | ||
size_t | max, | ||
int64_t * | xtp = NULL |
||
) |
Retrieve the value of a record.
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. |
xtp | the pointer to the variable into which the expiration time from now in seconds is assigned. If it is NULL, it is ignored. |
int32_t kyototycoon::TimedDB::check | ( | const char * | kbuf, |
size_t | ksiz, | ||
int64_t * | xtp = NULL |
||
) |
Check the existence of a record.
kbuf | the pointer to the key region. |
ksiz | the size of the key region. |
xtp | the pointer to the variable into which the absolute expiration time is assigned. If it is NULL, it is ignored. |
int32_t kyototycoon::TimedDB::check | ( | const std::string & | key, |
int64_t * | xtp = NULL |
||
) |
Check the existence of a record.
char* kyototycoon::TimedDB::seize | ( | const char * | kbuf, |
size_t | ksiz, | ||
size_t * | sp, | ||
int64_t * | xtp = NULL |
||
) |
Retrieve the value of a record and remove it atomically.
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. |
xtp | the pointer to the variable into which the absolute expiration time is assigned. If it is NULL, it is ignored. |
bool kyototycoon::TimedDB::seize | ( | const std::string & | key, |
std::string * | value, | ||
int64_t * | xtp = NULL |
||
) |
Retrieve the value of a record and remove it atomically.
int64_t kyototycoon::TimedDB::set_bulk | ( | const std::map< std::string, std::string > & | recs, |
int64_t | xt = kc::INT64MAX , |
||
bool | atomic = true |
||
) |
Store records at once.
recs | the records to store. |
xt | the expiration time from now in seconds. If it is negative, the absolute value is treated as the epoch time. |
atomic | true to perform all operations atomically, or false for non-atomic operations. |
int64_t kyototycoon::TimedDB::remove_bulk | ( | const std::vector< std::string > & | keys, |
bool | atomic = true |
||
) |
Remove records at once.
keys | the keys of the records to remove. |
atomic | true to perform all operations atomically, or false for non-atomic operations. |
int64_t kyototycoon::TimedDB::get_bulk | ( | const std::vector< std::string > & | keys, |
std::map< std::string, std::string > * | recs, | ||
bool | atomic = true |
||
) |
Retrieve records at once.
keys | the keys of the records to retrieve. |
recs | a string map to contain the retrieved records. |
atomic | true to perform all operations atomically, or false for non-atomic operations. |
bool kyototycoon::TimedDB::dump_snapshot | ( | std::ostream * | dest, |
kc::BasicDB::ProgressChecker * | checker = NULL |
||
) |
Dump records into a data stream.
dest | the destination stream. |
checker | a progress checker object. If it is NULL, no checking is performed. |
bool kyototycoon::TimedDB::dump_snapshot | ( | const std::string & | dest, |
kc::BasicDB::ProgressChecker * | checker = NULL |
||
) |
Dump records into a file.
dest | the path of the destination file. |
checker | a progress checker object. If it is NULL, no checking is performed. |
bool kyototycoon::TimedDB::load_snapshot | ( | std::istream * | src, |
kc::BasicDB::ProgressChecker * | checker = NULL |
||
) |
Load records from a data stream.
src | the source stream. |
checker | a progress checker object. If it is NULL, no checking is performed. |
bool kyototycoon::TimedDB::load_snapshot | ( | const std::string & | src, |
kc::BasicDB::ProgressChecker * | checker = NULL |
||
) |
Load records from a file.
src | the path of the source file. |
checker | a progress checker object. If it is NULL, no checking is performed. |
bool kyototycoon::TimedDB::dump_snapshot_atomic | ( | const std::string & | dest, |
kc::Compressor * | zcomp = NULL , |
||
kc::BasicDB::ProgressChecker * | checker = NULL |
||
) |
Dump records atomically into a file.
dest | the path of the destination file. |
zcomp | the data compressor object. If it is NULL, no compression is performed. |
checker | a progress checker object. If it is NULL, no checking is performed. |
bool kyototycoon::TimedDB::load_snapshot_atomic | ( | const std::string & | src, |
kc::Compressor * | zcomp = NULL , |
||
kc::BasicDB::ProgressChecker * | checker = NULL |
||
) |
Load records atomically from a file.
src | the path of the source file. |
zcomp | the data compressor object. If it is NULL, no decompression is performed. |
checker | a progress checker object. If it is NULL, no checking is performed. |
kc::BasicDB* kyototycoon::TimedDB::reveal_inner_db | ( | ) |
Reveal the inner database object.
bool kyototycoon::TimedDB::vacuum | ( | int64_t | step = 0 | ) |
Scan the database and eliminate regions of expired records.
step | the number of steps. If it is not more than 0, the whole region is scanned. |
bool kyototycoon::TimedDB::recover | ( | const char * | mbuf, |
size_t | msiz | ||
) |
Recover the database with an update log message.
mbuf | the pointer to the message region. |
msiz | the size of the message region. |
int64_t kyototycoon::TimedDB::match_prefix | ( | const std::string & | prefix, |
std::vector< std::string > * | strvec, | ||
int64_t | max = -1 , |
||
kc::BasicDB::ProgressChecker * | checker = NULL |
||
) |
Get keys matching a prefix string.
prefix | the prefix string. |
strvec | a string vector to contain the result. |
max | the maximum number to retrieve. If it is negative, no limit is specified. |
checker | a progress checker object. If it is NULL, no checking is performed. |
int64_t kyototycoon::TimedDB::match_regex | ( | const std::string & | regex, |
std::vector< std::string > * | strvec, | ||
int64_t | max = -1 , |
||
kc::BasicDB::ProgressChecker * | checker = NULL |
||
) |
Get keys matching a regular expression string.
regex | the regular expression string. |
strvec | a string vector to contain the result. |
max | the maximum number to retrieve. If it is negative, no limit is specified. |
checker | a progress checker object. If it is NULL, no checking is performed. |
int64_t kyototycoon::TimedDB::match_similar | ( | const std::string & | origin, |
size_t | range, | ||
bool | utf, | ||
std::vector< std::string > * | strvec, | ||
int64_t | max = -1 , |
||
kc::BasicDB::ProgressChecker * | checker = NULL |
||
) |
Get keys similar to a string in terms of the levenshtein distance.
origin | the origin string. |
range | the maximum distance of keys to adopt. |
utf | flag to treat keys as UTF-8 strings. |
strvec | a string vector to contain the result. |
max | the maximum number to retrieve. If it is negative, no limit is specified. |
checker | a progress checker object. If it is NULL, no checking is performed. |
bool kyototycoon::TimedDB::merge | ( | TimedDB ** | srcary, |
size_t | srcnum, | ||
MergeMode | mode = MSET , |
||
kc::BasicDB::ProgressChecker * | checker = NULL |
||
) |
Merge records from other databases.
srcary | an array of the source detabase objects. |
srcnum | the number of the elements of the source array. |
mode | the merge mode. TimedDB::MSET to overwrite the existing value, TimedDB::MADD to keep the existing value, TimedDB::MREPLACE to modify the existing record only, TimedDB::MAPPEND to append the new value. |
checker | a progress checker object. If it is NULL, no checking is performed. |
Create a cursor object.
bool kyototycoon::TimedDB::tune_logger | ( | kc::BasicDB::Logger * | logger, |
uint32_t | kinds = kc::BasicDB::Logger::WARN | kc::BasicDB::Logger::ERROR |
||
) |
Set the internal logger.
logger | the logger object. The same as with kc::BasicDB. |
kinds | kinds of logged messages by bitwise-or: The same as with kc::BasicDB. |
bool kyototycoon::TimedDB::tune_update_trigger | ( | UpdateTrigger * | trigger | ) |
Set the internal update trigger.
trigger | the trigger object. |
static bool kyototycoon::TimedDB::tokenize_update_log | ( | const char * | mbuf, |
size_t | msiz, | ||
std::vector< std::string > * | tokens | ||
) | [static] |
Tokenize an update log message.
mbuf | the pointer to the message region. |
msiz | the size of the message region. |
tokens | a string vector to contain the result. |
static bool kyototycoon::TimedDB::status_snapshot_atomic | ( | const std::string & | src, |
uint64_t * | tsp = NULL , |
||
int64_t * | cntp = NULL , |
||
int64_t * | sizp = NULL |
||
) | [static] |
Get status of an atomic snapshot file.
src | the path of the source file. |
tsp | the pointer to the variable into which the time stamp of the snapshot data is assigned. If it is NULL, it is ignored. |
cntp | the pointer to the variable into which the number of records in the original database is assigned. If it is NULL, it is ignored. |
sizp | the pointer to the variable into which the size of the original database is assigned. If it is NULL, it is ignored. |
const int32_t kyototycoon::TimedDB::XTWIDTH = 5 [static] |
The width of expiration time.
const int64_t kyototycoon::TimedDB::XTMAX = (1LL << (XTWIDTH * 8)) - 1 [static] |
The maximum number of expiration time.