Osmium  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Private Attributes
Osmium::Storage::FixedArray< TValue > Class Template Reference

#include <byid.hpp>

Inheritance diagram for Osmium::Storage::FixedArray< TValue >:
Inheritance graph
[legend]
Collaboration diagram for Osmium::Storage::FixedArray< TValue >:
Collaboration graph
[legend]

List of all members.

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

Detailed Description

template<typename TValue>
class Osmium::Storage::FixedArray< TValue >

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!


Constructor & Destructor Documentation

template<typename TValue >
Osmium::Storage::FixedArray< TValue >::FixedArray ( const uint64_t  max_id) [inline]

Constructor.

Parameters:
max_idOne larger than the largest ID you will ever have.
Exceptions:
std::bad_allocThrown when there is not enough memory.
template<typename TValue >
Osmium::Storage::FixedArray< TValue >::~FixedArray ( ) [inline]

Member Function Documentation

template<typename TValue >
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 >.

template<typename 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 >.

template<typename 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 >.

template<typename 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 >.

template<typename 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 >.


Member Data Documentation

template<typename TValue >
TValue* Osmium::Storage::FixedArray< TValue >::m_items [private]
template<typename TValue >
uint64_t Osmium::Storage::FixedArray< TValue >::m_size [private]

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines