Tkrzw
|
Interface of database manager. More...
#include <tkrzw_dbm.h>
Classes | |
class | FileProcessor |
Interface of processor for a record. More... | |
class | FileProcessorCopyFile |
File processor to implement DBM::CopyFile. More... | |
class | Iterator |
Interface of iterator for each record. More... | |
class | RecordProcessor |
Interface of processor for a record. More... | |
class | RecordProcessorAppend |
Record processor to implement DBM::Append. More... | |
class | RecordProcessorCompareExchange |
Record processor to implement DBM::CompareExchange. More... | |
class | RecordProcessorExport |
Record processor to implement DBM::Export. More... | |
class | RecordProcessorGet |
Record processor to implement DBM::Get. More... | |
class | RecordProcessorIncrement |
Record processor to implement DBM::Increment. More... | |
class | RecordProcessorIteratorGet |
Record processor to implement DBM::Iterator::Get. More... | |
class | RecordProcessorIteratorRemove |
Record processor to implement DBM::Iterator::Remove. More... | |
class | RecordProcessorIteratorSet |
Record processor to implement DBM::Iterator::Set. More... | |
class | RecordProcessorLambda |
Record processor to implement DBM::Process with a lambda function. More... | |
class | RecordProcessorRemove |
Record processor to implement DBM::Remove. More... | |
class | RecordProcessorSet |
Record processor to implement DBM::Set. More... | |
Public Types | |
typedef std::function< std::string_view(std::string_view, std::string_view)> | RecordLambdaType |
Lambda function type to process a record. More... | |
Public Member Functions | |
virtual | ~DBM ()=default |
Destructor. More... | |
virtual Status | Open (const std::string &path, bool writable, int32_t options=File::OPEN_DEFAULT)=0 |
Opens a database file. More... | |
virtual Status | Close ()=0 |
Closes the database file. More... | |
virtual Status | Process (std::string_view key, RecordProcessor *proc, bool writable)=0 |
Processes a record with a processor. More... | |
virtual Status | Process (std::string_view key, RecordLambdaType rec_lambda, bool writable) |
Processes a record with a lambda function. More... | |
virtual Status | Get (std::string_view key, std::string *value=nullptr) |
Gets the value of a record of a key. More... | |
virtual std::string | GetSimple (std::string_view key, std::string_view default_value="") |
Gets the value of a record of a key, in a simple way. More... | |
virtual std::map< std::string, std::string > | GetMulti (const std::initializer_list< std::string > &keys) |
Gets the values of multiple records of keys. More... | |
virtual std::map< std::string, std::string > | GetMulti (const std::vector< std::string > &keys) |
Gets the values of multiple records of keys, with a vector. More... | |
virtual Status | Set (std::string_view key, std::string_view value, bool overwrite=true, std::string *old_value=nullptr) |
Sets a record of a key and a value. More... | |
virtual Status | SetMulti (const std::initializer_list< std::pair< std::string, std::string >> &records, bool overwrite=true) |
Sets multiple records. More... | |
virtual Status | SetMulti (const std::map< std::string, std::string > &records, bool overwrite=true) |
Sets multiple records, with a map of strings. More... | |
virtual Status | Remove (std::string_view key, std::string *old_value=nullptr) |
Removes a record of a key. More... | |
virtual Status | Append (std::string_view key, std::string_view value, std::string_view delim="") |
Appends data at the end of a record of a key. More... | |
virtual Status | CompareExchange (std::string_view key, std::string_view expected, std::string_view desired, std::string *actual=nullptr) |
Compares the value of a record and exchanges if the condition meets. More... | |
virtual Status | Increment (std::string_view key, int64_t increment=1, int64_t *current=nullptr, int64_t initial=0) |
Increments the numeric value of a record. More... | |
int64_t | IncrementSimple (std::string_view key, int64_t increment=1, int64_t initial=0) |
Increments the numeric value of a record, in a simple way. More... | |
virtual Status | ProcessEach (RecordProcessor *proc, bool writable)=0 |
Processes each and every record in the database with a processor. More... | |
virtual Status | ProcessEach (RecordLambdaType rec_lambda, bool writable) |
Processes each and every record in the database with a lambda function. More... | |
virtual Status | Count (int64_t *count)=0 |
Gets the number of records. More... | |
virtual int64_t | CountSimple () |
Gets the number of records, in a simple way. More... | |
virtual Status | GetFileSize (int64_t *size)=0 |
Gets the current file size of the database. More... | |
virtual int64_t | GetFileSizeSimple () |
Gets the current file size of the database, in a simple way. More... | |
virtual Status | GetFilePath (std::string *path)=0 |
Gets the path of the database file. More... | |
virtual std::string | GetFilePathSimple () |
Gets the path of the database file, in a simple way. More... | |
virtual Status | Clear ()=0 |
Removes all records. More... | |
virtual Status | Rebuild ()=0 |
Rebuilds the entire database. More... | |
virtual Status | ShouldBeRebuilt (bool *tobe)=0 |
Checks whether the database should be rebuilt. More... | |
virtual bool | ShouldBeRebuiltSimple () |
Checks whether the database should be rebuilt, in a simple way. More... | |
virtual Status | Synchronize (bool hard, FileProcessor *proc=nullptr)=0 |
Synchronizes the content of the database to the file system. More... | |
virtual Status | CopyFile (const std::string &dest_path) |
Copies the content of the database file to another file. More... | |
virtual Status | Export (DBM *dbm) |
Exports all records to another database. More... | |
virtual std::vector< std::pair< std::string, std::string > > | Inspect ()=0 |
Inspects the database. More... | |
virtual bool | IsOpen () const =0 |
Checks whether the database is open. More... | |
virtual bool | IsWritable () const =0 |
Checks whether the database is writable. More... | |
virtual bool | IsHealthy () const =0 |
Checks whether the database condition is healthy. More... | |
virtual bool | IsOrdered () const =0 |
Checks whether ordered operations are supported. More... | |
virtual std::unique_ptr< Iterator > | MakeIterator ()=0 |
Makes an iterator for each record. More... | |
virtual std::unique_ptr< DBM > | MakeDBM () const =0 |
Make a new DBM object of the same concrete class. More... | |
Interface of database manager.
typedef std::function<std::string_view(std::string_view, std::string_view)> tkrzw::DBM::RecordLambdaType |
Lambda function type to process a record.
The first parameter is the key of the record. The second parameter is the value of the existing record, or NOOP if it the record doesn't exist. The return value is a string reference to NOOP, REMOVE, or the new record value.
|
virtualdefault |
Destructor.
|
pure virtual |
Opens a database file.
path | A path of the file. |
writable | If true, the file is writable. If false, it is read-only. |
options | Bit-sum options for opening the file. |
Implemented in tkrzw::TreeDBM, tkrzw::TinyDBM, tkrzw::StdTreeDBM, tkrzw::StdHashDBM, tkrzw::SkipDBM, tkrzw::ShardDBM, tkrzw::PolyDBM, tkrzw::HashDBM, tkrzw::CacheDBM, and tkrzw::BabyDBM.
|
pure virtual |
Closes the database file.
Implemented in tkrzw::TreeDBM, tkrzw::TinyDBM, tkrzw::StdTreeDBM, tkrzw::StdHashDBM, tkrzw::SkipDBM, tkrzw::ShardDBM, tkrzw::PolyDBM, tkrzw::HashDBM, tkrzw::CacheDBM, and tkrzw::BabyDBM.
|
pure virtual |
Processes a record with a processor.
key | The key of the record. |
proc | The pointer to the processor object. |
writable | True if the processor can edit the record. |
Implemented in tkrzw::TreeDBM, tkrzw::TinyDBM, tkrzw::StdTreeDBM, tkrzw::StdHashDBM, tkrzw::SkipDBM, tkrzw::ShardDBM, tkrzw::PolyDBM, tkrzw::HashDBM, tkrzw::CacheDBM, and tkrzw::BabyDBM.
|
virtual |
Processes a record with a lambda function.
key | The key of the record. |
rec_lambda | The lambda function to process a record. The first parameter is the key of the record. The second parameter is the value of the existing record, or NOOP if it the record doesn't exist. The return value is a string reference to NOOP, REMOVE, or the new record value. |
writable | True if the processor can edit the record. |
|
virtual |
Gets the value of a record of a key.
key | The key of the record. |
value | The pointer to a string object to contain the result value. If it is nullptr, the value data is ignored. |
Reimplemented in tkrzw::ShardDBM, and tkrzw::PolyDBM.
|
virtual |
Gets the value of a record of a key, in a simple way.
key | The key of the record. |
default_value | The value to be returned on failure. |
|
virtual |
Gets the values of multiple records of keys.
keys | The keys of records to retrieve. |
|
virtual |
Gets the values of multiple records of keys, with a vector.
keys | The keys of records to retrieve. |
|
virtual |
Sets a record of a key and a value.
key | The key of the record. |
value | The value of the record. |
overwrite | Whether to overwrite the existing value if there's a record with the same key. If true, the existing value is overwritten by the new value. If false, the operation is given up and an error status is returned. |
old_value | The pointer to a string object to contain the old value. Assignment is done even on the duplication error. If it is nullptr, it is ignored. |
Reimplemented in tkrzw::SkipDBM, tkrzw::ShardDBM, and tkrzw::PolyDBM.
|
virtual |
Sets multiple records.
records | The records to store. |
overwrite | Whether to overwrite the existing value if there's a record with the same key. If true, the existing value is overwritten by the new value. If false, the operation is given up and an error status is returned. |
|
virtual |
Sets multiple records, with a map of strings.
records | The records to store. |
overwrite | Whether to overwrite the existing value if there's a record with the same key. If true, the existing value is overwritten by the new value. If false, the operation is given up and an error status is returned. |
|
virtual |
Removes a record of a key.
key | The key of the record. |
old_value | The pointer to a string object to contain the old value. If it is nullptr, it is ignored. even on the duplication error. |
Reimplemented in tkrzw::SkipDBM, tkrzw::ShardDBM, and tkrzw::PolyDBM.
|
virtual |
Appends data at the end of a record of a key.
key | The key of the record. |
value | The value to append. |
delim | The delimiter to put after the existing record. |
Reimplemented in tkrzw::TinyDBM, tkrzw::ShardDBM, tkrzw::PolyDBM, and tkrzw::BabyDBM.
|
virtual |
Compares the value of a record and exchanges if the condition meets.
key | The key of the record. |
expected | The expected value. |
desired | The desired value. If the data is nullptr, the record is to be removed. |
actual | The pointer to a string object to contain the result value. If it is nullptr, it is ignored. |
|
virtual |
Increments the numeric value of a record.
key | The key of the record. |
increment | The incremental value. If it is INT64MIN, the current value is not changed and a new record is not created. |
current | The pointer to an integer to contain the current value. If it is nullptr, it is ignored. |
initial | The initial value. |
int64_t tkrzw::DBM::IncrementSimple | ( | std::string_view | key, |
int64_t | increment = 1 , |
||
int64_t | initial = 0 |
||
) |
Increments the numeric value of a record, in a simple way.
key | The key of the record. |
increment | The incremental value. |
initial | The initial value. |
|
pure virtual |
Processes each and every record in the database with a processor.
proc | The pointer to the processor object. |
writable | True if the processor can edit the record. |
Implemented in tkrzw::TreeDBM, tkrzw::TinyDBM, tkrzw::StdTreeDBM, tkrzw::StdHashDBM, tkrzw::SkipDBM, tkrzw::ShardDBM, tkrzw::PolyDBM, tkrzw::HashDBM, tkrzw::CacheDBM, and tkrzw::BabyDBM.
|
virtual |
Processes each and every record in the database with a lambda function.
rec_lambda | The lambda function to process a record. The first parameter is the key of the record. The second parameter is the value of the existing record, or NOOP if it the record doesn't exist. The return value is a string reference to NOOP, REMOVE, or the new record value. |
writable | True if the processor can edit the record. |
|
pure virtual |
Gets the number of records.
count | The pointer to an integer object to contain the result count. |
Implemented in tkrzw::TreeDBM, tkrzw::TinyDBM, tkrzw::StdTreeDBM, tkrzw::StdHashDBM, tkrzw::SkipDBM, tkrzw::ShardDBM, tkrzw::PolyDBM, tkrzw::HashDBM, tkrzw::CacheDBM, and tkrzw::BabyDBM.
|
virtual |
Gets the number of records, in a simple way.
|
pure virtual |
Gets the current file size of the database.
size | The pointer to an integer object to contain the result size. |
Implemented in tkrzw::TreeDBM, tkrzw::TinyDBM, tkrzw::StdTreeDBM, tkrzw::StdHashDBM, tkrzw::SkipDBM, tkrzw::ShardDBM, tkrzw::PolyDBM, tkrzw::HashDBM, tkrzw::CacheDBM, and tkrzw::BabyDBM.
|
virtual |
Gets the current file size of the database, in a simple way.
|
pure virtual |
Gets the path of the database file.
path | The pointer to a string object to contain the result path. |
Implemented in tkrzw::TreeDBM, tkrzw::TinyDBM, tkrzw::StdTreeDBM, tkrzw::StdHashDBM, tkrzw::SkipDBM, tkrzw::ShardDBM, tkrzw::PolyDBM, tkrzw::HashDBM, tkrzw::CacheDBM, and tkrzw::BabyDBM.
|
virtual |
Gets the path of the database file, in a simple way.
|
pure virtual |
Removes all records.
Implemented in tkrzw::TreeDBM, tkrzw::TinyDBM, tkrzw::StdTreeDBM, tkrzw::StdHashDBM, tkrzw::SkipDBM, tkrzw::ShardDBM, tkrzw::PolyDBM, tkrzw::HashDBM, tkrzw::CacheDBM, and tkrzw::BabyDBM.
|
pure virtual |
Rebuilds the entire database.
Implemented in tkrzw::TreeDBM, tkrzw::TinyDBM, tkrzw::StdTreeDBM, tkrzw::StdHashDBM, tkrzw::SkipDBM, tkrzw::ShardDBM, tkrzw::PolyDBM, tkrzw::HashDBM, tkrzw::CacheDBM, and tkrzw::BabyDBM.
|
pure virtual |
Checks whether the database should be rebuilt.
tobe | The pointer to a boolean object to contain the result decision. |
Implemented in tkrzw::TreeDBM, tkrzw::TinyDBM, tkrzw::StdTreeDBM, tkrzw::StdHashDBM, tkrzw::SkipDBM, tkrzw::ShardDBM, tkrzw::PolyDBM, tkrzw::HashDBM, tkrzw::CacheDBM, and tkrzw::BabyDBM.
|
virtual |
Checks whether the database should be rebuilt, in a simple way.
|
pure virtual |
Synchronizes the content of the database to the file system.
hard | True to do physical synchronization with the hardware or false to do only logical synchronization with the file system. |
proc | The pointer to the file processor object, whose Process method is called while the content of the file is synchronized. If it is nullptr, it is ignored. |
Implemented in tkrzw::TreeDBM, tkrzw::TinyDBM, tkrzw::StdTreeDBM, tkrzw::StdHashDBM, tkrzw::SkipDBM, tkrzw::ShardDBM, tkrzw::PolyDBM, tkrzw::HashDBM, tkrzw::CacheDBM, and tkrzw::BabyDBM.
|
virtual |
Copies the content of the database file to another file.
dest_path | A path to the destination file. |
Reimplemented in tkrzw::ShardDBM.
Exports all records to another database.
dbm | The pointer to the destination database. |
|
pure virtual |
Inspects the database.
Implemented in tkrzw::TreeDBM, tkrzw::TinyDBM, tkrzw::StdTreeDBM, tkrzw::StdHashDBM, tkrzw::SkipDBM, tkrzw::ShardDBM, tkrzw::PolyDBM, tkrzw::HashDBM, tkrzw::CacheDBM, and tkrzw::BabyDBM.
|
pure virtual |
Checks whether the database is open.
Implemented in tkrzw::TreeDBM, tkrzw::TinyDBM, tkrzw::StdTreeDBM, tkrzw::StdHashDBM, tkrzw::SkipDBM, tkrzw::ShardDBM, tkrzw::PolyDBM, tkrzw::HashDBM, tkrzw::CacheDBM, and tkrzw::BabyDBM.
|
pure virtual |
Checks whether the database is writable.
Implemented in tkrzw::TreeDBM, tkrzw::TinyDBM, tkrzw::StdTreeDBM, tkrzw::StdHashDBM, tkrzw::SkipDBM, tkrzw::ShardDBM, tkrzw::PolyDBM, tkrzw::HashDBM, tkrzw::CacheDBM, and tkrzw::BabyDBM.
|
pure virtual |
Checks whether the database condition is healthy.
Implemented in tkrzw::TreeDBM, tkrzw::TinyDBM, tkrzw::StdTreeDBM, tkrzw::StdHashDBM, tkrzw::SkipDBM, tkrzw::ShardDBM, tkrzw::PolyDBM, tkrzw::HashDBM, tkrzw::CacheDBM, and tkrzw::BabyDBM.
|
pure virtual |
Checks whether ordered operations are supported.
Implemented in tkrzw::TreeDBM, tkrzw::TinyDBM, tkrzw::StdTreeDBM, tkrzw::StdHashDBM, tkrzw::SkipDBM, tkrzw::ShardDBM, tkrzw::PolyDBM, tkrzw::HashDBM, tkrzw::CacheDBM, and tkrzw::BabyDBM.
|
pure virtual |
Makes an iterator for each record.
Implemented in tkrzw::TreeDBM, tkrzw::TinyDBM, tkrzw::StdTreeDBM, tkrzw::StdHashDBM, tkrzw::SkipDBM, tkrzw::ShardDBM, tkrzw::PolyDBM, tkrzw::HashDBM, tkrzw::CacheDBM, and tkrzw::BabyDBM.
|
pure virtual |
Make a new DBM object of the same concrete class.
Implemented in tkrzw::TreeDBM, tkrzw::TinyDBM, tkrzw::StdTreeDBM, tkrzw::StdHashDBM, tkrzw::SkipDBM, tkrzw::ShardDBM, tkrzw::PolyDBM, tkrzw::HashDBM, tkrzw::CacheDBM, and tkrzw::BabyDBM.