Osmium
0.1
|
#include <stringtable.hpp>
Classes | |
struct | string_info |
Public Member Functions | |
StringTable () | |
string_id_t | record_string (const std::string &string) |
void | store_stringtable (OSMPBF::StringTable *st) |
string_id_t | map_string_id (const string_id_t interim_id) const |
void | clear () |
Static Public Member Functions | |
template<typename A , typename B > | |
static std::pair< B, A > | flip_pair (const std::pair< A, B > &p) |
Private Types | |
typedef uint16_t | string_id_t |
type for string IDs (interim and final) | |
typedef std::map< std::string, string_info > | string2string_info_t |
typedef std::vector< string_id_t > | interim_id2id_t |
Private Attributes | |
string2string_info_t | m_strings |
interim_id2id_t | m_id2id_map |
int | m_size |
Friends | |
bool | operator< (const string_info &lhs, const string_info &rhs) |
StringTable management for PBF writer
All strings are stored as indexes to rows in a StringTable. The StringTable contains one row for each used string, so strings that are used multiple times need to be stored only once. The StringTable is sorted by usage-count, so the most often used string is stored at index 1.
typedef std::vector<string_id_t> Osmium::StringTable::interim_id2id_t [private] |
This vector is used to map the interim IDs to real StringTable IDs after writing all strings to the StringTable.
typedef std::map<std::string, string_info> Osmium::StringTable::string2string_info_t [private] |
Interim StringTable, storing all strings that should be written to the StringTable once the block is written to disk.
typedef uint16_t Osmium::StringTable::string_id_t [private] |
type for string IDs (interim and final)
Osmium::StringTable::StringTable | ( | ) | [inline] |
void Osmium::StringTable::clear | ( | ) | [inline] |
Clear the stringtable, preparing for the next block.
static std::pair<B,A> Osmium::StringTable::flip_pair | ( | const std::pair< A, B > & | p | ) | [inline, static] |
string_id_t Osmium::StringTable::map_string_id | ( | const string_id_t | interim_id | ) | const [inline] |
Map from an interim ID to a real string ID.
string_id_t Osmium::StringTable::record_string | ( | const std::string & | string | ) | [inline] |
record a string in the interim StringTable if it's missing, otherwise just increase its counter, return the interim-id assigned to the string.
void Osmium::StringTable::store_stringtable | ( | OSMPBF::StringTable * | st | ) | [inline] |
Sort the interim StringTable and store it to the real protobuf StringTable. while storing to the real table, this function fills the id2id_map with pairs, mapping the interim-ids to final and real StringTable ids.
Note that the m_strings table is a std::map and as such is sorted lexicographically. When the transformation into the sortedby multimap is done, it gets sorted by the count. The end result (at least with the glibc standard container/algorithm implementation) is that the string table is sorted first by reverse count (ie descending) and then by reverse lexicographic order.
bool operator< | ( | const string_info & | lhs, |
const string_info & | rhs | ||
) | [friend] |
int Osmium::StringTable::m_size [private] |