WriterSequential is used to construct a constant B-tree database from an _ordered_ input sequence. More...
#include <stx-cbtreedb.h>
Public Member Functions | |
WriterSequential (const key_compare &key_less=key_compare()) | |
Constructor. | |
void | Add (const key_type &key, uint32_t size) |
Add a new key -> value size mapping to the database. | |
size_t | Size () const |
Return number of pairs inserted into mapping. | |
void | SetSignature (const char *newsignature) |
Change the database signature from 'cbtreedb' to a custom string. | |
void | WriteHeader (std::ostream &os) |
Write header and b-tree to file stream. Starts Phase 2. | |
void | WriteValue (const key_type &key, const void *data, uint32_t size) |
Sequentially write value blobs to file. | |
void | WriteValue (const key_type &key, const std::string &data) |
Sequentially write value blobs to file. | |
void | WriteFinalize () |
Finalize database file. | |
Protected Attributes | |
key_compare | m_key_less |
key comparison functional | |
BTreeBuilder | m_btree |
phase 1: b-tree object built from sequential predeclared sequence | |
uint64_t | m_dataoffset |
phase 1: value data offset counter for predeclared sequence | |
char | m_signaturestr [8] |
signature characters to begin file with | |
SignaturePage | m_signature |
signature page of current written file | |
std::ostream * | m_ostream |
phase 2: output stream | |
uint32_t | m_currpos |
phase 2: current position in array | |
uint64_t | m_curroffset |
phase 2: current offset in output stream | |
SHA256 | m_datasha |
phase 2: running digest of the value area |
WriterSequential is used to construct a constant B-tree database from an _ordered_ input sequence.
The writer class is fed in two phases. In phase one the ordered sequence of keys together with their value data size (without contents) is delivered to the class via the Add() function. Phase two is started by calling WriteHeader() followed by a sequence to WriteValue() calls for each of the predeclared key-value pairs. The value data is written directly to the file and not buffered. The write loop is terminated by WriteFinalize(), which finalizes the database file.
Definition at line 2775 of file stx-cbtreedb.h.
stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::WriterSequential::WriterSequential | ( | const key_compare & | key_less = key_compare() |
) | [inline] |
Constructor.
Definition at line 2807 of file stx-cbtreedb.h.
void stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::WriterSequential::Add | ( | const key_type & | key, | |
uint32_t | size | |||
) | [inline] |
Add a new key -> value size mapping to the database.
The keys must be added in ascending order.
Definition at line 2819 of file stx-cbtreedb.h.
void stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::WriterSequential::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 2841 of file stx-cbtreedb.h.
size_t stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::WriterSequential::Size | ( | ) | const [inline] |
Return number of pairs inserted into mapping.
Definition at line 2831 of file stx-cbtreedb.h.
void stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::WriterSequential::WriteFinalize | ( | ) | [inline] |
Finalize database file.
Definition at line 2935 of file stx-cbtreedb.h.
void stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::WriterSequential::WriteHeader | ( | std::ostream & | os | ) | [inline] |
Write header and b-tree to file stream. Starts Phase 2.
Definition at line 2852 of file stx-cbtreedb.h.
void stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::WriterSequential::WriteValue | ( | const key_type & | key, | |
const std::string & | data | |||
) | [inline] |
Sequentially write value blobs to file.
The key-value sequence must match the pre-declared sequence.
Definition at line 2929 of file stx-cbtreedb.h.
void stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::WriterSequential::WriteValue | ( | const key_type & | key, | |
const void * | data, | |||
uint32_t | size | |||
) | [inline] |
Sequentially write value blobs to file.
The key-value sequence must match the pre-declared sequence.
Definition at line 2896 of file stx-cbtreedb.h.
BTreeBuilder stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::WriterSequential::m_btree [protected] |
phase 1: b-tree object built from sequential predeclared sequence
Definition at line 2782 of file stx-cbtreedb.h.
uint64_t stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::WriterSequential::m_curroffset [protected] |
phase 2: current offset in output stream
Definition at line 2800 of file stx-cbtreedb.h.
uint32_t stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::WriterSequential::m_currpos [protected] |
phase 2: current position in array
Definition at line 2797 of file stx-cbtreedb.h.
uint64_t stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::WriterSequential::m_dataoffset [protected] |
phase 1: value data offset counter for predeclared sequence
Definition at line 2785 of file stx-cbtreedb.h.
SHA256 stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::WriterSequential::m_datasha [protected] |
phase 2: running digest of the value area
Definition at line 2803 of file stx-cbtreedb.h.
key_compare stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::WriterSequential::m_key_less [protected] |
key comparison functional
Definition at line 2779 of file stx-cbtreedb.h.
std::ostream* stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::WriterSequential::m_ostream [protected] |
phase 2: output stream
Definition at line 2794 of file stx-cbtreedb.h.
SignaturePage stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::WriterSequential::m_signature [protected] |
signature page of current written file
Definition at line 2791 of file stx-cbtreedb.h.
char stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::WriterSequential::m_signaturestr[8] [protected] |
signature characters to begin file with
Definition at line 2788 of file stx-cbtreedb.h.