Osmium
0.1
|
#include <byid.hpp>
Public Member Functions | |
Mmap () | |
Mmap (std::string &filename, bool remove=true) | |
~Mmap () | |
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 () |
Static Public Attributes | |
static const uint64_t | size_increment = 10 * 1024 * 1024 |
Private Member Functions | |
uint64_t | get_file_size () |
Get file size in bytes. | |
Private Attributes | |
uint64_t | m_size |
int | m_fd |
TValue * | m_items |
The Mmap store stores location using the mmap() system call, either backed by a file on disk or just in-memory. It will grow automatically.
If you have enough memory it is preferred to use the in-memory version. If you don't have enough memory or want the information to persist, use the file-backed version. Note that you still need substantial amounts of memory for this to work efficiently.
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::Mmap< TValue >::Mmap | ( | ) | [inline] |
Create anonymous mapping without a backing file.
std::bad_alloc | Thrown when there is not enough memory. |
Osmium::Storage::Mmap< TValue >::Mmap | ( | std::string & | filename, |
bool | remove = true |
||
) | [inline] |
Create mapping backed by file. If filename is empty, a temporary file will be created.
filename | The filename (including the path) for the storage. |
remove | Should the file be removed after use? |
std::bad_alloc | Thrown when there is not enough memory or some other problem. |
Osmium::Storage::Mmap< TValue >::~Mmap | ( | ) | [inline] |
void Osmium::Storage::Mmap< 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 >.
uint64_t Osmium::Storage::Mmap< TValue >::get_file_size | ( | ) | [inline, private] |
Get file size in bytes.
const TValue& Osmium::Storage::Mmap< 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::Mmap< 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::Mmap< 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::Mmap< 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 >.
int Osmium::Storage::Mmap< TValue >::m_fd [private] |
TValue* Osmium::Storage::Mmap< TValue >::m_items [private] |
uint64_t Osmium::Storage::Mmap< TValue >::m_size [private] |
const uint64_t Osmium::Storage::Mmap< TValue >::size_increment = 10 * 1024 * 1024 [static] |