Writer is used to construct an constant B-tree database from an unsorted input sequence. More...
#include <stx-cbtreedb.h>
Public Member Functions | |
Writer (const key_compare &key_less=key_compare()) | |
Constructor. | |
void | Add (const key_type &key, const void *data, size_t size) |
Add a new key -> values mapping to the database. | |
void | Add (const key_type &key, const std::string &data) |
Add a new key -> values mapping to the database. | |
size_t | Size () const |
Return number of items inserted into mapping. | |
void | SetSignature (const char *newsignature) |
Change the database signature from 'cbtreedb' to a custom string. | |
void | Write (std::ostream &os) const |
Write the complete database out to a file. | |
Protected Types | |
typedef std::map< key_type, std::string, key_compare > | datamap_type |
Typedef key -> data mapping. | |
Protected Attributes | |
datamap_type | m_datamap |
STL map to store all key -> values. | |
key_compare | m_key_less |
key comparison functional | |
char | m_signaturestr [8] |
Signature characters to begin file with. |
Writer is used to construct an constant B-tree database from an unsorted input sequence.
The writer class is fed with a possibly unordered sequence of keys together with their data. The complete data is buffered (and sorted) by the class! This means it will use a lot of virtual memory, so make sure your swap is large enough or use WriterSequential.
Definition at line 2625 of file stx-cbtreedb.h.
typedef std::map<key_type, std::string, key_compare> stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::Writer::datamap_type [protected] |
Typedef key -> data mapping.
Definition at line 2629 of file stx-cbtreedb.h.
stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::Writer::Writer | ( | const key_compare & | key_less = key_compare() |
) | [inline] |
Constructor.
Definition at line 2642 of file stx-cbtreedb.h.
void stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::Writer::Add | ( | const key_type & | key, | |
const std::string & | data | |||
) | [inline] |
Add a new key -> values mapping to the database.
Definition at line 2656 of file stx-cbtreedb.h.
void stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::Writer::Add | ( | const key_type & | key, | |
const void * | data, | |||
size_t | size | |||
) | [inline] |
Add a new key -> values mapping to the database.
Definition at line 2650 of file stx-cbtreedb.h.
void stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::Writer::SetSignature | ( | const char * | newsignature | ) | [inline] |
Change the database signature from 'cbtreedb' to a custom string.
The signature is always 8 bytes long. Longer strings are truncated, shorter ones padded with nulls.
Definition at line 2672 of file stx-cbtreedb.h.
size_t stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::Writer::Size | ( | ) | const [inline] |
Return number of items inserted into mapping.
Definition at line 2662 of file stx-cbtreedb.h.
void stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::Writer::Write | ( | std::ostream & | os | ) | const [inline] |
Write the complete database out to a file.
Because the stream must be seekable, a simple ostream will not suffice.
Definition at line 2684 of file stx-cbtreedb.h.
datamap_type stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::Writer::m_datamap [protected] |
STL map to store all key -> values.
Definition at line 2632 of file stx-cbtreedb.h.
key_compare stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::Writer::m_key_less [protected] |
key comparison functional
Definition at line 2635 of file stx-cbtreedb.h.
char stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::Writer::m_signaturestr[8] [protected] |
Signature characters to begin file with.
Definition at line 2638 of file stx-cbtreedb.h.