stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::Writer Class Reference

Writer is used to construct an constant B-tree database from an unsorted input sequence. More...

#include <stx-cbtreedb.h>

Collaboration diagram for stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::Writer:
Collaboration graph
[legend]

List of all members.

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.

Detailed Description

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
class stx::CBTreeDB< _Key, _Compare, _BTreePageSize, _AppVersionId >::Writer

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.


Member Typedef Documentation

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
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.


Constructor & Destructor Documentation

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
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.


Member Function Documentation

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
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.

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
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.

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
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.

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
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.

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
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.


Member Data Documentation

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
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.

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
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.

template<typename _Key = uint32_t, typename _Compare = std::less<_Key>, unsigned int _BTreePageSize = 1024, uint32_t _AppVersionId = 0>
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.


The documentation for this class was generated from the following file:
Generated on Wed Apr 14 13:43:42 2010 for stx-cbtreedb by  doxygen 1.6.3