Osmium
0.1
|
#include <byid.hpp>
Public Member Functions | |
FixedArray (const uint64_t max_id) | |
~FixedArray () | |
void | set (uint64_t id, TValue value) |
Set the field with id to value. | |
const TValue & | operator[] (uint64_t id) const |
Retrieve value by key. Does not check for overflow or empty fields. | |
uint64_t | size () const |
uint64_t | used_memory () const |
void | clear () |
Private Attributes | |
TValue * | m_items |
uint64_t | m_size |
The FixedArray storage stores location in a huge array. The size of the array is given when initializing the object, it must be large enough to hold all items.
Only use this store when you know beforehand how many IDs there are. It is mainly provided for cases where the more flexible Mmap storage class does not work.
There is no range checking on accessing the store.
If you are storing node coordinates, you'll need 8 bytes for each node. At the time of writing this, the largest node ID is about 1.3 billion, so you'll need about 10 GB of memory.
Note that this storage class will only work on 64 bit systems if used for storing node coordinates. 32 bit systems just can't address that much memory!
Osmium::Storage::FixedArray< TValue >::FixedArray | ( | const uint64_t | max_id | ) | [inline] |
Constructor.
max_id | One larger than the largest ID you will ever have. |
std::bad_alloc | Thrown when there is not enough memory. |
Osmium::Storage::FixedArray< TValue >::~FixedArray | ( | ) | [inline] |
void Osmium::Storage::FixedArray< TValue >::clear | ( | ) | [inline, virtual] |
Clear memory used for this storage. After this you can not use the storage container any more.
Implements Osmium::Storage::ById< TValue >.
const TValue& Osmium::Storage::FixedArray< TValue >::operator[] | ( | uint64_t | id | ) | const [inline, virtual] |
Retrieve value by key. Does not check for overflow or empty fields.
Implements Osmium::Storage::ById< TValue >.
void Osmium::Storage::FixedArray< TValue >::set | ( | uint64_t | id, |
TValue | value | ||
) | [inline, virtual] |
Set the field with id to value.
Implements Osmium::Storage::ById< TValue >.
uint64_t Osmium::Storage::FixedArray< TValue >::size | ( | ) | const [inline, virtual] |
Get the approximate number of items in the storage. The storage might allocate memory in blocks, so this size might not be accurate. You can not use this to find out how much memory the storage uses. Use used_memory() for that.
Implements Osmium::Storage::ById< TValue >.
uint64_t Osmium::Storage::FixedArray< TValue >::used_memory | ( | ) | const [inline, virtual] |
Get the memory used for this storage in bytes. Note that this is not necessarily entirely accurate but an approximation. For storage classes that store the data in memory, this is the main memory used, for storage classes storing data on disk this is the memory used on disk.
Implements Osmium::Storage::ById< TValue >.
TValue* Osmium::Storage::FixedArray< TValue >::m_items [private] |
uint64_t Osmium::Storage::FixedArray< TValue >::m_size [private] |