Tkrzw
Classes | Public Member Functions | Static Public Member Functions | List of all members
tkrzw::PolyDBM Class Referencefinal

Polymorphic database manager adapter. More...

#include <tkrzw_dbm_poly.h>

Classes

class  Iterator
 Iterator for each record. More...
 

Public Member Functions

 PolyDBM ()
 Default constructor. More...
 
virtual ~PolyDBM ()
 Destructor. More...
 
 PolyDBM (const PolyDBM &rhs)=delete
 Copy and assignment are disabled. More...
 
PolyDBMoperator= (const PolyDBM &rhs)=delete
 
Status Open (const std::string &path, bool writable, int32_t options=File::OPEN_DEFAULT) override
 Opens a database file. More...
 
Status OpenAdvanced (const std::string &path, bool writable, int32_t options=File::OPEN_DEFAULT, const std::map< std::string, std::string > &params={}) override
 Opens a database file, in an advanced way. More...
 
Status Close () override
 Closes the database file. More...
 
Status Process (std::string_view key, RecordProcessor *proc, bool writable) override
 Processes a record with a processor. More...
 
Status Get (std::string_view key, std::string *value=nullptr) override
 Gets the value of a record of a key. More...
 
Status Set (std::string_view key, std::string_view value, bool overwrite=true, std::string *old_value=nullptr) override
 Sets a record of a key and a value. More...
 
Status Remove (std::string_view key, std::string *old_value=nullptr) override
 Removes a record of a key. More...
 
Status Append (std::string_view key, std::string_view value, std::string_view delim="") override
 Appends data at the end of a record of a key. More...
 
Status ProcessFirst (RecordProcessor *proc, bool writable) override
 Processes the first record with a processor. More...
 
Status ProcessMulti (const std::vector< std::pair< std::string_view, DBM::RecordProcessor * >> &key_proc_pairs, bool writable) override
 Processes multiple records with processors. More...
 
Status ProcessEach (RecordProcessor *proc, bool writable) override
 Processes each and every record in the database with a processor. More...
 
Status Count (int64_t *count) override
 Gets the number of records. More...
 
Status GetFileSize (int64_t *size) override
 Gets the current file size of the database. More...
 
Status GetFilePath (std::string *path) override
 Gets the path of the database file. More...
 
Status GetTimestamp (double *timestamp) override
 Gets the timestamp in seconds of the last modified time. More...
 
Status Clear () override
 Removes all records. More...
 
Status Rebuild () override
 Rebuilds the entire database. More...
 
Status RebuildAdvanced (const std::map< std::string, std::string > &params={}) override
 Rebuilds the entire database, in an advanced way. More...
 
Status ShouldBeRebuilt (bool *tobe) override
 Checks whether the database should be rebuilt. More...
 
Status Synchronize (bool hard, FileProcessor *proc=nullptr) override
 Synchronizes the content of the database to the file system. More...
 
Status SynchronizeAdvanced (bool hard, FileProcessor *proc=nullptr, const std::map< std::string, std::string > &params={}) override
 Synchronizes the content of the database to the file system, in an advanced way. More...
 
std::vector< std::pair< std::string, std::string > > Inspect () override
 Inspects the database. More...
 
bool IsOpen () const override
 Checks whether the database is open. More...
 
bool IsWritable () const override
 Checks whether the database is writable. More...
 
bool IsHealthy () const override
 Checks whether the database condition is healthy. More...
 
bool IsOrdered () const override
 Checks whether ordered operations are supported. More...
 
std::unique_ptr< DBM::IteratorMakeIterator () override
 Makes an iterator for each record. More...
 
std::unique_ptr< DBMMakeDBM () const override
 Makes a new DBM object of the same concrete class. More...
 
UpdateLoggerGetUpdateLogger () const override
 Gets the logger to write all update operations. More...
 
void SetUpdateLogger (UpdateLogger *update_logger) override
 Sets the logger to write all update operations. More...
 
DBMGetInternalDBM () const
 Gets the pointer to the internal database object. More...
 
- Public Member Functions inherited from tkrzw::ParamDBM
virtual ~ParamDBM ()=default
 Destructor. More...
 
- Public Member Functions inherited from tkrzw::DBM
virtual ~DBM ()=default
 Destructor. More...
 
virtual Status Process (std::string_view key, RecordLambdaType rec_lambda, bool writable)
 Processes a record with a lambda function. 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 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 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 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 (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 (RecordLambdaType rec_lambda, bool writable)
 Processes each and every record in the database with a lambda function. More...
 
virtual int64_t CountSimple ()
 Gets the number of records, in a simple way. More...
 
virtual int64_t GetFileSizeSimple ()
 Gets the current file size of the database, in a simple way. More...
 
virtual std::string GetFilePathSimple ()
 Gets the path of the database file, in a simple way. More...
 
virtual double GetTimestampSimple ()
 Gets the timestamp of the last modified time, in a simple way. More...
 
virtual bool ShouldBeRebuiltSimple ()
 Checks whether the database should be rebuilt, in a simple way. 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...
 
const std::type_info & GetType () const
 Gets the type information of the actual class. More...
 

Static Public Member Functions

static Status RestoreDatabase (const std::string &old_file_path, const std::string &new_file_path, const std::string &class_name="", int64_t end_offset=-1, std::string_view cipher_key="")
 Restores a broken database as a new healthy database. 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

Polymorphic database manager adapter.

All operations except for Open and Close are thread-safe; Multiple threads can access the same database concurrently. Every opened database must be closed explicitly to avoid data corruption.

This class is a wrapper of HashDBM, TreeDBM, SkipDBM, TinyDBM, BabyDBM, StdHashDBM, and StdTreeDBM. The Open method specifies the actuall class used internally.

Constructor & Destructor Documentation

◆ PolyDBM() [1/2]

tkrzw::PolyDBM::PolyDBM ( )

Default constructor.

◆ ~PolyDBM()

virtual tkrzw::PolyDBM::~PolyDBM ( )
virtual

Destructor.

◆ PolyDBM() [2/2]

tkrzw::PolyDBM::PolyDBM ( const PolyDBM rhs)
explicitdelete

Copy and assignment are disabled.

Member Function Documentation

◆ Open()

Status tkrzw::PolyDBM::Open ( const std::string &  path,
bool  writable,
int32_t  options = File::OPEN_DEFAULT 
)
overridevirtual

Opens a database file.

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

Implements tkrzw::DBM.

◆ OpenAdvanced()

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

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.

The extension of the path indicates the type of the database.

  • .tkh : File hash database (HashDBM)
  • .tkt : File tree database (TreeDBM)
  • .tks : File skip database (SkipDBM)
  • .tkmt : On-memory hash database (TinyDBM)
  • .tkmb : On-memory tree database (BabyDBM)
  • .tkmc : On-memory LRU cache database (CacheDBM)
  • .tksh : On-memory STL hash database (StdHashDBM)
  • .tkst : On-memory STL tree database (StdTreeDBM)

    The optional parameter "dbm" supercedes the decision of the database type by the extension. The value is the type name: "HashDBM", "TreeDBM", "SkipDBM", "TinyDBM", "BabyDBM", "CacheDBM", "StdHashDBM", "StdTreeDBM".

    The optional parameter "file" specifies the internal file implementation class. The default file class is "MemoryMapAtomicFile". The other supported classes are "StdFile", "MemoryMapAtomicFile", "PositionalParallelFile", and "PositionalAtomicFile".

    For HashDBM, these optional parameters are supported.

  • update_mode (string): How to update the database file: "UPDATE_IN_PLACE" for the in-palce or "UPDATE_APPENDING" for the appending mode.
  • record_crc_mode (string): How to add the CRC data to the record: "RECORD_CRC_NONE" to add no CRC to each record, "RECORD_CRC_8" to add CRC-8 to each record, "RECORD_CRC_16" to add CRC-16 to each record, or "RECORD_CRC_32" to add CRC-32 to each record.
  • record_comp_mode (string): How to compress the record data: "RECORD_COMP_NONE" to do no compression, "RECORD_COMP_ZLIB" to compress with ZLib, "RECORD_COMP_ZSTD" to compress with ZStd, "RECORD_COMP_LZ4" to compress with LZ4, "RECORD_COMP_LZMA" to compress with LZMA, "RECORD_COMP_RC4" to cipher with RC4, "RECORD_COMP_AES" to cipher with AES.
  • offset_width (int): The width to represent the offset of records.
  • align_pow (int): The power to align records.
  • num_buckets (int): The number of buckets for hashing.
  • restore_mode (string): How to restore the database file: "RESTORE_SYNC" to restore to the last synchronized state, "RESTORE_READ_ONLY" to make the database read-only, or "RESTORE_NOOP" to do nothing. By default, as many records as possible are restored. Appending ":RESTORE_NO_SHORTCUTS" is to not apply shortcuts. Appending ":RESTORE_WITH_HARDSYNC" is do physical synchronization.
  • fbp_capacity (int): The capacity of the free block pool.
  • min_read_size (int): The minimum reading size to read a record.
  • cache_buckets (bool): True to cache the hash buckets on memory.
  • cipher_key (string): The encryption key for cipher compressors.

    For TreeDBM, all optional parameters for HashDBM are available. In addition, these optional parameters are supported.

  • max_page_size (int): The maximum size of a page.
  • max_branches (int): The maximum number of branches each inner node can have.
  • max_cached_pages (int): The maximum number of cached pages.
  • page_update_mode (string): What to do when each page is updated: "PAGE_UPDATE_NONE" is to do no operation or "PAGE_UPDATE_WRITE" is to write immediately.
  • key_comparator (string): The comparator of record keys: "LexicalKeyComparator" for the lexical order, "LexicalCaseKeyComparator" for the lexical order ignoring case, "DecimalKeyComparator" for the order of decimal integer numeric expressions, "HexadecimalKeyComparator" for the order of hexadecimal integer numeric expressions, "RealNumberKeyComparator" for the order of decimal real number expressions, "SignedBigEndianKeyComparator" for the order of binary signed integer expressions, and "FloatBigEndianKeyComparator" for the order of binary float-number expressions.

    For SkipDBM, these optional parameters are supported.

  • offset_width (int): The width to represent the offset of records.
  • step_unit (int): The step unit of the skip list.
  • max_level (int): The maximum level of the skip list.
  • restore_mode (string): How to restore the database file: "RESTORE_SYNC" to restore to the last synchronized state, "RESTORE_READ_ONLY" to make the database read-only, or "RESTORE_NOOP" to do nothing. By default, as many records as possible are restored. Appending ":RESTORE_NO_SHORTCUTS" is to not apply shortcuts. Appending ":RESTORE_WITH_HARDSYNC" is do physical synchronization.
  • sort_mem_size (int): The memory size used for sorting to build the database in the at-random mode.
  • insert_in_order (bool): If true, records are assumed to be inserted in ascending order of the key.
  • max_cached_records (int): The maximum number of cached records.

    For TinyDBM, these optional parameters are supported.

  • num_buckets (int): The number of buckets for hashing.

    For BabyDBM, these optional parameters are supported.

  • key_comparator (string): The comparator of record keys. The same ones as TreeDBM.

    For CacheDBM, these optional parameters are supported.

  • cap_rec_num (int): The maximum number of records.
  • cap_mem_size (int): The total memory size to use.

    All databases support taking update logs into files. It is enabled by setting the prefix of update log files.

  • ulog_prefix (str): The prefix of the update log files.
  • ulog_max_file_size (num): The maximum file size of each update log file. By default, it is 1GiB.
  • ulog_server_id (num): The server ID attached to each log. By default, it is 0.
  • ulog_dbm_index (num): The DBM index attached to each log. By default, it is 0.

    For the file "PositionalParallelFile" and "PositionalAtomicFile", these optional parameters are supported.

  • block_size (int): The block size to which all blocks should be aligned.
  • access_options (str): Values separated by colon. "direct" for direct I/O. "sync" for synchrnizing I/O, "padding" for file size alignment by padding, "pagecache" for the mini page cache in the process.

Implements tkrzw::ParamDBM.

◆ Close()

Status tkrzw::PolyDBM::Close ( )
overridevirtual

Closes the database file.

Returns
The result status.

Implements tkrzw::DBM.

◆ Process()

Status tkrzw::PolyDBM::Process ( std::string_view  key,
RecordProcessor proc,
bool  writable 
)
overridevirtual

Processes a record with a processor.

Parameters
keyThe key of the record.
procThe pointer to the processor object.
writableTrue if the processor can edit the record.
Returns
The result status.

If the specified record exists, the ProcessFull of the processor is called. Otherwise, the ProcessEmpty of the processor is called.

Implements tkrzw::DBM.

◆ Get()

Status tkrzw::PolyDBM::Get ( std::string_view  key,
std::string *  value = nullptr 
)
overridevirtual

Gets the value of a record of a key.

Parameters
keyThe key of the record.
valueThe pointer to a string object to contain the result value. If it is nullptr, the value data is ignored.
Returns
The result status. If there's no matching record, NOT_FOUND_ERROR is returned.

Reimplemented from tkrzw::DBM.

◆ Set()

Status tkrzw::PolyDBM::Set ( std::string_view  key,
std::string_view  value,
bool  overwrite = true,
std::string *  old_value = nullptr 
)
overridevirtual

Sets a record of a key and a value.

Parameters
keyThe key of the record.
valueThe value of the record.
overwriteWhether 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_valueThe 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.
Returns
The result status. If overwriting is abandoned, DUPLICATION_ERROR is returned.

Reimplemented from tkrzw::DBM.

◆ Remove()

Status tkrzw::PolyDBM::Remove ( std::string_view  key,
std::string *  old_value = nullptr 
)
overridevirtual

Removes a record of a key.

Parameters
keyThe key of the record.
old_valueThe pointer to a string object to contain the old value. If it is nullptr, it is ignored.
Returns
The result status. If there's no matching record, NOT_FOUND_ERROR is returned.

Reimplemented from tkrzw::DBM.

◆ Append()

Status tkrzw::PolyDBM::Append ( std::string_view  key,
std::string_view  value,
std::string_view  delim = "" 
)
overridevirtual

Appends data at the end of a record of a key.

Parameters
keyThe key of the record.
valueThe value to append.
delimThe delimiter to put after the existing record.
Returns
The result status.

If there's no existing record, the value is set without the delimiter.

Reimplemented from tkrzw::DBM.

◆ ProcessFirst()

Status tkrzw::PolyDBM::ProcessFirst ( RecordProcessor proc,
bool  writable 
)
overridevirtual

Processes the first record with a processor.

Parameters
procThe pointer to the processor object.
writableTrue if the processor can edit the record.
Returns
The result status.

If the first record exists, the ProcessFull of the processor is called. Otherwise, this method fails and no method of the processor is called. Whereas ordered databases have efficient implementations of this method, unordered databases have inefficient implementations.

Implements tkrzw::DBM.

◆ ProcessMulti()

Status tkrzw::PolyDBM::ProcessMulti ( const std::vector< std::pair< std::string_view, DBM::RecordProcessor * >> &  key_proc_pairs,
bool  writable 
)
override

Processes multiple records with processors.

Parameters
key_proc_pairsPairs of the keys and their processor objects.
writableTrue if the processors can edit the records.
Returns
The result status.

If the specified record exists, the ProcessFull of the processor is called. Otherwise, the ProcessEmpty of the processor is called.

◆ ProcessEach()

Status tkrzw::PolyDBM::ProcessEach ( RecordProcessor proc,
bool  writable 
)
overridevirtual

Processes each and every record in the database with a processor.

Parameters
procThe pointer to the processor object.
writableTrue if the processor can edit the record.
Returns
The result status.

The ProcessFull of the processor is called repeatedly for each record. The ProcessEmpty of the processor is called once before the iteration and once after the iteration.

Implements tkrzw::DBM.

◆ Count()

Status tkrzw::PolyDBM::Count ( int64_t *  count)
overridevirtual

Gets the number of records.

Parameters
countThe pointer to an integer object to contain the result count.
Returns
The result status.

Implements tkrzw::DBM.

◆ GetFileSize()

Status tkrzw::PolyDBM::GetFileSize ( int64_t *  size)
overridevirtual

Gets the current file size of the database.

Parameters
sizeThe pointer to an integer object to contain the result size.
Returns
The result status.

Implements tkrzw::DBM.

◆ GetFilePath()

Status tkrzw::PolyDBM::GetFilePath ( std::string *  path)
overridevirtual

Gets the path of the database file.

Parameters
pathThe pointer to a string object to contain the result path.
Returns
The result status.

Implements tkrzw::DBM.

◆ GetTimestamp()

Status tkrzw::PolyDBM::GetTimestamp ( double *  timestamp)
overridevirtual

Gets the timestamp in seconds of the last modified time.

Parameters
timestampThe pointer to a double object to contain the timestamp.
Returns
The result status.

Implements tkrzw::DBM.

◆ Clear()

Status tkrzw::PolyDBM::Clear ( )
overridevirtual

Removes all records.

Returns
The result status.

Implements tkrzw::DBM.

◆ Rebuild()

Status tkrzw::PolyDBM::Rebuild ( )
overridevirtual

Rebuilds the entire database.

Returns
The result status.

Implements tkrzw::DBM.

◆ RebuildAdvanced()

Status tkrzw::PolyDBM::RebuildAdvanced ( const std::map< std::string, std::string > &  params = {})
overridevirtual

Rebuilds the entire database, in an advanced way.

Parameters
paramsOptional parameters.
Returns
The result status.

Tuning options can be given by the optional parameters, as with the Open method. A unset parameter means that the current setting is succeeded or calculated implicitly. In addition, HashDBM, TreeDBM, and SkipDBM supports the following parameters.

  • skip_broken_records (bool): If true, the operation continues even if there are broken records which can be skipped.
  • sync_hard (bool): If true, physical synchronization with the hardware is done before finishing the rebuilt file.

Implements tkrzw::ParamDBM.

◆ ShouldBeRebuilt()

Status tkrzw::PolyDBM::ShouldBeRebuilt ( bool *  tobe)
overridevirtual

Checks whether the database should be rebuilt.

Parameters
tobeThe pointer to a boolean object to contain the result decision.
Returns
The result status.

Implements tkrzw::DBM.

◆ Synchronize()

Status tkrzw::PolyDBM::Synchronize ( bool  hard,
FileProcessor proc = nullptr 
)
overridevirtual

Synchronizes the content of the database to the file system.

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.
Returns
The result status.

Implements tkrzw::DBM.

◆ SynchronizeAdvanced()

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

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.

Only SkipDBM uses the optional parameters. The "merge" parameter specifies paths of databases to merge, separated by colon. The "reducer" parameter specifies the reducer to apply to records of the same key. "ReduceToFirst", "ReduceToSecond", "ReduceToLast", etc are supported.

Implements tkrzw::ParamDBM.

◆ Inspect()

std::vector<std::pair<std::string, std::string> > tkrzw::PolyDBM::Inspect ( )
overridevirtual

Inspects the database.

Returns
A vector of pairs of a property name and its value.

Implements tkrzw::DBM.

◆ IsOpen()

bool tkrzw::PolyDBM::IsOpen ( ) const
overridevirtual

Checks whether the database is open.

Returns
True if the database is open, or false if not.

Implements tkrzw::DBM.

◆ IsWritable()

bool tkrzw::PolyDBM::IsWritable ( ) const
overridevirtual

Checks whether the database is writable.

Returns
True if the database is writable, or false if not.

Implements tkrzw::DBM.

◆ IsHealthy()

bool tkrzw::PolyDBM::IsHealthy ( ) const
overridevirtual

Checks whether the database condition is healthy.

Returns
True if the database condition is healthy, or false if not.

Implements tkrzw::DBM.

◆ IsOrdered()

bool tkrzw::PolyDBM::IsOrdered ( ) const
overridevirtual

Checks whether ordered operations are supported.

Returns
True if ordered operations are supported, or false if not.

Implements tkrzw::DBM.

◆ MakeIterator()

std::unique_ptr<DBM::Iterator> tkrzw::PolyDBM::MakeIterator ( )
overridevirtual

Makes an iterator for each record.

Returns
The iterator for each record.

Implements tkrzw::DBM.

◆ MakeDBM()

std::unique_ptr<DBM> tkrzw::PolyDBM::MakeDBM ( ) const
overridevirtual

Makes a new DBM object of the same concrete class.

Returns
The new DBM object.

Implements tkrzw::DBM.

◆ GetUpdateLogger()

UpdateLogger* tkrzw::PolyDBM::GetUpdateLogger ( ) const
overridevirtual

Gets the logger to write all update operations.

Returns
The update logger if it has been set or nullptr if it hasn't.

Implements tkrzw::DBM.

◆ SetUpdateLogger()

void tkrzw::PolyDBM::SetUpdateLogger ( UpdateLogger update_logger)
overridevirtual

Sets the logger to write all update operations.

Parameters
update_loggerThe pointer to the update logger object. Ownership is not taken. If it is nullptr, no logger is used.

Implements tkrzw::DBM.

◆ GetInternalDBM()

DBM* tkrzw::PolyDBM::GetInternalDBM ( ) const

Gets the pointer to the internal database object.

Returns
The pointer to the internal database object, or nullptr on failure.

◆ RestoreDatabase()

static Status tkrzw::PolyDBM::RestoreDatabase ( const std::string &  old_file_path,
const std::string &  new_file_path,
const std::string &  class_name = "",
int64_t  end_offset = -1,
std::string_view  cipher_key = "" 
)
static

Restores a broken database as a new healthy database.

Parameters
old_file_pathThe path of the broken database.
new_file_pathThe path of the new database to be created.
class_nameThe name of the database class. If it is empty, the class is guessed from the file extension.
end_offsetThe exclusive end offset of records to read. Negative means unlimited. 0 means the size when the database is synched or closed properly.
cipher_keyThe encryption key for cipher compressors.
Returns
The result status.