Tkrzw
Public Member Functions | List of all members
tkrzw::ParamDBM Class Referenceabstract

Parametric database manager interface. More...

#include <tkrzw_dbm_poly.h>

Public Member Functions

virtual ~ParamDBM ()=default
 Destructor. More...
 
virtual Status OpenAdvanced (const std::string &path, bool writable, int32_t options=File::OPEN_DEFAULT, const std::map< std::string, std::string > &params={})=0
 Opens a database file, in an advanced way. More...
 
virtual Status RebuildAdvanced (const std::map< std::string, std::string > &params={})=0
 Rebuilds the entire database, in an advanced way. More...
 
virtual Status SynchronizeAdvanced (bool hard, FileProcessor *proc=nullptr, const std::map< std::string, std::string > &params={})=0
 Synchronizes the content of the database to the file system, in an advanced way. More...
 
- Public Member Functions inherited from tkrzw::DBM
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 Status GetMulti (const std::vector< std::string_view > &keys, std::map< std::string, std::string > *records)
 Gets the values of multiple records of keys, with a string view vector. More...
 
virtual Status GetMulti (const std::initializer_list< std::string_view > &keys, std::map< std::string, std::string > *records)
 Gets the values of multiple records of keys, with an initializer list. More...
 
virtual Status GetMulti (const std::vector< std::string > &keys, std::map< std::string, std::string > *records)
 Gets the values of multiple records of keys, with a string 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::map< std::string_view, std::string_view > &records, bool overwrite=true)
 Sets multiple records, with a map of string views. More...
 
virtual Status SetMulti (const std::initializer_list< std::pair< std::string_view, std::string_view >> &records, bool overwrite=true)
 Sets multiple records, with an initializer list. 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 RemoveMulti (const std::vector< std::string_view > &keys)
 Removes records of keys, with a string view vector. More...
 
virtual Status RemoveMulti (const std::initializer_list< std::string_view > &keys)
 Removes records of keys, with an initializer list. More...
 
virtual Status RemoveMulti (const std::vector< std::string > &keys)
 Removes records of keys, with a string vector. 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 AppendMulti (const std::map< std::string_view, std::string_view > &records, std::string_view delim="")
 Appends data to multiple records, with a map of string views. More...
 
virtual Status AppendMulti (const std::initializer_list< std::pair< std::string_view, std::string_view >> &records, std::string_view delim="")
 Appends data to multiple records, with an initializer list. More...
 
virtual Status AppendMulti (const std::map< std::string, std::string > &records, std::string_view delim="")
 Appends data to multiple records, with a map of strings. More...
 
virtual Status CompareExchange (std::string_view key, std::string_view expected, std::string_view desired, std::string *actual=nullptr, bool *found=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...
 
virtual 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 ProcessMulti (const std::vector< std::pair< std::string_view, RecordProcessor * >> &key_proc_pairs, bool writable)=0
 Processes multiple records with processors. More...
 
virtual Status ProcessMulti (const std::vector< std::pair< std::string_view, RecordLambdaType >> &key_lambda_pairs, bool writable)
 Processes multiple records with lambda functions. More...
 
virtual Status CompareExchangeMulti (const std::vector< std::pair< std::string_view, std::string_view >> &expected, const std::vector< std::pair< std::string_view, std::string_view >> &desired)
 Compares the values of records and exchanges if the condition meets. More...
 
virtual Status Rekey (std::string_view old_key, std::string_view new_key, bool overwrite=true, bool copying=false, std::string *value=nullptr)
 Changes the key of a record. More...
 
virtual Status ProcessFirst (RecordProcessor *proc, bool writable)=0
 Processes the first record with a processor. More...
 
virtual Status ProcessFirst (RecordLambdaType rec_lambda, bool writable)
 Processes the first record with a lambda function. More...
 
virtual Status PopFirst (std::string *key=nullptr, std::string *value=nullptr)
 Gets the first record and removes it. More...
 
virtual Status PushLast (std::string_view value, double wtime=-1, std::string *key=nullptr)
 Adds a record with a key of the current timestamp. 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 GetTimestamp (double *timestamp)=0
 Gets the timestamp in seconds of the last modified time. More...
 
virtual double GetTimestampSimple ()
 Gets the timestamp of the last modified time, 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 CopyFileData (const std::string &dest_path, bool sync_hard=false)
 Copies the content of the database file to another file. More...
 
virtual Status Export (DBM *dest_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< IteratorMakeIterator ()=0
 Makes an iterator for each record. More...
 
virtual std::unique_ptr< DBMMakeDBM () const =0
 Makes a new DBM object of the same concrete class. More...
 
virtual UpdateLoggerGetUpdateLogger () const =0
 Gets the logger to write all update operations. More...
 
virtual void SetUpdateLogger (UpdateLogger *update_logger)=0
 Sets the logger to write all update operations. More...
 
const std::type_info & GetType () const
 Gets the type information of the actual class. More...
 

Additional Inherited Members

- Public Types inherited from tkrzw::DBM
typedef std::function< std::string_view(std::string_view, std::string_view)> RecordLambdaType
 Lambda function type to process a record. More...
 
- Static Public Attributes inherited from tkrzw::DBM
static const std::string_view ANY_DATA
 The special string_view value to represent any data. More...
 

Detailed Description

Parametric database manager interface.

This is commonly used by the PolyDBM and ShardDBM.

Constructor & Destructor Documentation

◆ ~ParamDBM()

virtual tkrzw::ParamDBM::~ParamDBM ( )
virtualdefault

Destructor.

Member Function Documentation

◆ OpenAdvanced()

virtual Status tkrzw::ParamDBM::OpenAdvanced ( const std::string &  path,
bool  writable,
int32_t  options = File::OPEN_DEFAULT,
const std::map< std::string, std::string > &  params = {} 
)
pure virtual

Opens a database file, in an advanced way.

Parameters
pathA path of the file.
writableIf true, the file is writable. If false, it is read-only.
optionsBit-sum options for opening the file.
paramsOptional parameters.
Returns
The result status.

Implemented in tkrzw::ShardDBM, and tkrzw::PolyDBM.

◆ RebuildAdvanced()

virtual Status tkrzw::ParamDBM::RebuildAdvanced ( const std::map< std::string, std::string > &  params = {})
pure virtual

Rebuilds the entire database, in an advanced way.

Parameters
paramsOptional parameters.
Returns
The result status.

Implemented in tkrzw::ShardDBM, and tkrzw::PolyDBM.

◆ SynchronizeAdvanced()

virtual Status tkrzw::ParamDBM::SynchronizeAdvanced ( bool  hard,
FileProcessor proc = nullptr,
const std::map< std::string, std::string > &  params = {} 
)
pure virtual

Synchronizes the content of the database to the file system, in an advanced way.

Parameters
hardTrue to do physical synchronization with the hardware or false to do only logical synchronization with the file system.
procThe 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.
paramsOptional parameters.
Returns
The result status.

Implemented in tkrzw::ShardDBM, and tkrzw::PolyDBM.