Tkrzw
tkrzw::RecordSorter Class Referencefinal

Sorter for a large amound of records based on merge sort on files. More...

#include <tkrzw_dbm_skip_impl.h>

Public Member Functions

 RecordSorter (const std::string &base_path, int64_t max_mem_size, bool use_mmap)
 Constructor.
 
 ~RecordSorter ()
 Destructor.
 
Status Add (std::string_view key, std::string_view value)
 Adds a record.
 
void AddSkipRecord (SkipRecord *rec, int64_t record_base)
 Adds a file of SkipRecord.
 
void TakeFileOwnership (std::unique_ptr< File > &&file)
 Takes ownership of a file object.
 
bool IsUpdated () const
 Checks whether the sorter is updated.
 
Status Finish ()
 Finishes adding records and allows getting them.
 
Status Get (std::string *key, std::string *value)
 Gets the minimum record.
 

Detailed Description

Sorter for a large amound of records based on merge sort on files.

Constructor & Destructor Documentation

◆ RecordSorter()

tkrzw::RecordSorter::RecordSorter ( const std::string & base_path,
int64_t max_mem_size,
bool use_mmap )

Constructor.

Parameters
base_pathThe base path of the temporary files.
max_mem_sizeThe maximum memory size to use.
use_mmapIf true, memory mapping files are used.

◆ ~RecordSorter()

tkrzw::RecordSorter::~RecordSorter ( )

Destructor.

Member Function Documentation

◆ Add()

Status tkrzw::RecordSorter::Add ( std::string_view key,
std::string_view value )

Adds a record.

Parameters
keyThe key string.
valueThe key string.
Returns
The result status.

◆ AddSkipRecord()

void tkrzw::RecordSorter::AddSkipRecord ( SkipRecord * rec,
int64_t record_base )

Adds a file of SkipRecord.

Parameters
recThe pointer to a skip record, whose ownership is taken.
record_baseThe record base offset.

◆ TakeFileOwnership()

void tkrzw::RecordSorter::TakeFileOwnership ( std::unique_ptr< File > && file)

Takes ownership of a file object.

Parameters
fileThe unique pointer of the file object.

◆ IsUpdated()

bool tkrzw::RecordSorter::IsUpdated ( ) const

Checks whether the sorter is updated.

Returns
True if the sorter is updated or false if not.

◆ Finish()

Status tkrzw::RecordSorter::Finish ( )

Finishes adding records and allows getting them.

Returns
The result status.

◆ Get()

Status tkrzw::RecordSorter::Get ( std::string * key,
std::string * value )

Gets the minimum record.

Parameters
keyThe pointer to a string object to contain the record key.
valueThe pointer to a string object to contain the record value.
Returns
The result status.