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

On-memory secondary index implementation with std::map for strings. More...

#include <tkrzw_index.h>

Classes

class  Iterator
 Iterator for each record. More...
 
struct  RecordComparator
 Comparator for sorting records. More...
 

Public Member Functions

 StdIndexStr ()
 Default constructor. More...
 
 ~StdIndexStr ()
 Destructor. More...
 
 StdIndexStr (const StdIndexStr &rhs)=delete
 Copy and assignment are disabled. More...
 
StdIndexStroperator= (const StdIndexStr &rhs)=delete
 
bool Check (std::string_view key, std::string_view value)
 Checks whether a record exists in the index. More...
 
std::vector< std::string > GetValues (std::string_view key, size_t max=0)
 Gets all values of records of a key. More...
 
void Add (std::string_view key, std::string_view value)
 Adds a record. More...
 
void Remove (std::string_view key, std::string_view value)
 Removes a record. More...
 
size_t Count ()
 Gets the number of records. More...
 
void Clear ()
 Removes all records. More...
 
std::unique_ptr< IteratorMakeIterator ()
 Makes an iterator for each record. More...
 

Detailed Description

On-memory secondary index implementation with std::map for strings.

All operations are thread-safe; Multiple threads can access the same index concurrently.

This is slower than StdIndex<string, string> although space efficiency is better.

Constructor & Destructor Documentation

◆ StdIndexStr() [1/2]

tkrzw::StdIndexStr::StdIndexStr ( )

Default constructor.

◆ ~StdIndexStr()

tkrzw::StdIndexStr::~StdIndexStr ( )

Destructor.

◆ StdIndexStr() [2/2]

tkrzw::StdIndexStr::StdIndexStr ( const StdIndexStr rhs)
explicitdelete

Copy and assignment are disabled.

Member Function Documentation

◆ Check()

bool tkrzw::StdIndexStr::Check ( std::string_view  key,
std::string_view  value 
)

Checks whether a record exists in the index.

Parameters
keyThe key of the record.
valueThe value of the record.

◆ GetValues()

std::vector< std::string > tkrzw::StdIndexStr::GetValues ( std::string_view  key,
size_t  max = 0 
)

Gets all values of records of a key.

Parameters
keyThe key to look for.
maxThe maximum number of values to get. 0 means unlimited.
Returns
All values of the key.

◆ Add()

void tkrzw::StdIndexStr::Add ( std::string_view  key,
std::string_view  value 
)

Adds a record.

Parameters
keyThe key of the record. This can be an arbitrary expression to search the index.
valueThe value of the record. This should be a primary value of another database.

◆ Remove()

void tkrzw::StdIndexStr::Remove ( std::string_view  key,
std::string_view  value 
)

Removes a record.

Parameters
keyThe key of the record.
valueThe value of the record.

◆ Count()

size_t tkrzw::StdIndexStr::Count ( )

Gets the number of records.

Returns
The number of records.

◆ Clear()

void tkrzw::StdIndexStr::Clear ( )

Removes all records.

◆ MakeIterator()

std::unique_ptr< StdIndexStr::Iterator > tkrzw::StdIndexStr::MakeIterator ( )

Makes an iterator for each record.

Returns
The iterator for each record.