Loading...
Searching...
No Matches
osmium::index::map::Map< TId, TValue > Class Template Referenceabstract

`#include <map.hpp>`

Inheritance diagram for osmium::index::map::Map< TId, TValue >:
[legend]
Collaboration diagram for osmium::index::map::Map< TId, TValue >:
[legend]

## Public Types

using | key_type = TId
| The "key" type, usually osmium::unsigned_object_id_type.
using | value_type = TValue
| The "value" type, usually a Location or size_t.

## Public Member Functions

| Map () noexcept=default
| Map (const Map &)=delete
Map & | operator= (const Map &)=delete
virtual | ~Map () noexcept=default
virtual void | reserve (const std::size_t)
virtual void | set (const TId id, const TValue value)=0
| Set the field with id to value.
virtual TValue | get (const TId id) const =0
virtual TValue | get_noexcept (const TId id) const noexcept=0
virtual std::size_t | size () const =0
virtual std::size_t | used_memory () const =0
virtual void | clear ()=0
virtual void | sort ()
virtual void | dump_as_list (const int)
virtual void | dump_as_array (const int)

## Protected Member Functions

| Map (Map &&) noexcept=default
Map & | operator= (Map &&) noexcept=default

## Private Attributes

TId template parameter for class Map must be unsigned integral | type

## Detailed Description

template<typename TId, typename TValue>
class osmium::index::map::Map< TId, TValue >

This abstract class defines an interface to storage classes intended for storing small pieces of data (such as coordinates) indexed by a positive integer (such as an object ID). The storage must be very space efficient and able to scale to billions of objects.

Subclasses have different implementations that store the data in different ways in memory and/or on disk. Some storage classes are better suited when working with the whole planet, some are better for data extracts.

Note that these classes are not required to track "empty" fields. When reading data you have to be sure you have put something in there before.

A typical use for this and derived classes is storage of node locations indexed by node ID. These indexes will only work on 64 bit systems if used in this case. 32 bit systems just can't address that much memory!

Template Parameters

  TId | Id type, usually osmium::unsigned_object_id_type, must be an unsigned integral type.
  TValue | Value type, usually osmium::Location or size_t. Copied by value, so should be "small" type.

## Member Typedef Documentation

## key_type

template<typename TId, typename TValue>

using osmium::index::map::Map< TId, TValue >::key_type = TId

The "key" type, usually osmium::unsigned_object_id_type.

## value_type

template<typename TId, typename TValue>

using osmium::index::map::Map< TId, TValue >::value_type = TValue

The "value" type, usually a Location or size_t.

## Constructor & Destructor Documentation

## Map() [1/3]

template<typename TId, typename TValue>

osmium::index::map::Map< TId, TValue >::Map | ( | Map< TId, TValue > && |  | ) |

protecteddefaultnoexcept

## Map() [2/3]

template<typename TId, typename TValue>

osmium::index::map::Map< TId, TValue >::Map | ( |  | ) |

defaultnoexcept

## Map() [3/3]

template<typename TId, typename TValue>

osmium::index::map::Map< TId, TValue >::Map | ( | const Map< TId, TValue > & |  | ) |

delete

## ~Map()

template<typename TId, typename TValue>

virtual osmium::index::map::Map< TId, TValue >::~Map | ( |  | ) |

virtualdefaultnoexcept

## Member Function Documentation

## clear()

template<typename TId, typename TValue>

virtual void osmium::index::map::Map< TId, TValue >::clear | ( |  | ) |

pure virtual

Clear memory used for this storage. After this you can not use the storage container any more.

Implemented in osmium::index::map::Dummy< TId, TValue >, osmium::index::map::Dummy< osmium::unsigned_object_id_type, osmium::Location >, osmium::index::map::FlexMem< TId, TValue >, and osmium::index::map::SparseMemMap< TId, TValue >.

## dump_as_array()

template<typename TId, typename TValue>

virtual void osmium::index::map::Map< TId, TValue >::dump_as_array | ( | const int |  | ) |

inlinevirtual

## dump_as_list()

template<typename TId, typename TValue>

virtual void osmium::index::map::Map< TId, TValue >::dump_as_list | ( | const int |  | ) |

inlinevirtual

Reimplemented in osmium::index::map::SparseMemMap< TId, TValue >.

## get()

template<typename TId, typename TValue>

virtual TValue osmium::index::map::Map< TId, TValue >::get | ( | const TId | id | ) | const

pure virtual

Retrieve value by id.

Parameters

  id | The id to look for.

Returns
  Value.

Exceptions

  osmium::not_found | if the id could not be found.

Implemented in osmium::index::map::Dummy< TId, TValue >, osmium::index::map::FlexMem< TId, TValue >, and osmium::index::map::SparseMemMap< TId, TValue >.

## get_noexcept()

template<typename TId, typename TValue>

virtual TValue osmium::index::map::Map< TId, TValue >::get_noexcept | ( | const TId | id | ) | const

pure virtualnoexcept

Retrieve value by id.

Parameters

  id | The id to look for.

Returns
  Value or, if not found, the empty value as defined by osmium::index::empty_value<TValue>() which is usually the default constructed value of type TValue.

Implemented in osmium::index::map::Dummy< TId, TValue >, osmium::index::map::FlexMem< TId, TValue >, and osmium::index::map::SparseMemMap< TId, TValue >.

## operator=() [1/2]

template<typename TId, typename TValue>

Map & osmium::index::map::Map< TId, TValue >::operator= | ( | const Map< TId, TValue > & |  | ) |

delete

## operator=() [2/2]

template<typename TId, typename TValue>

Map & osmium::index::map::Map< TId, TValue >::operator= | ( | Map< TId, TValue > && |  | ) |

protecteddefaultnoexcept

## reserve()

template<typename TId, typename TValue>

virtual void osmium::index::map::Map< TId, TValue >::reserve | ( | const std::size_t |  | ) |

inlinevirtual

## set()

template<typename TId, typename TValue>

virtual void osmium::index::map::Map< TId, TValue >::set | ( | const TId | id,
|  | const TValue | value )

pure virtual

Set the field with id to value.

Implemented in osmium::index::map::Dummy< TId, TValue >, osmium::index::map::FlexMem< TId, TValue >, and osmium::index::map::SparseMemMap< TId, TValue >.

## size()

template<typename TId, typename TValue>

virtual std::size_t osmium::index::map::Map< TId, TValue >::size | ( |  | ) | const

pure 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.

Implemented in osmium::index::map::Dummy< TId, TValue >, osmium::index::map::Dummy< osmium::unsigned_object_id_type, osmium::Location >, osmium::index::map::FlexMem< TId, TValue >, and osmium::index::map::SparseMemMap< TId, TValue >.

## sort()

template<typename TId, typename TValue>

virtual void osmium::index::map::Map< TId, TValue >::sort | ( |  | ) |

inlinevirtual

Sort data in map. Call this after writing all data and before reading. Not all implementations need this.

Reimplemented in osmium::index::map::FlexMem< TId, TValue >.

## used_memory()

template<typename TId, typename TValue>

virtual std::size_t osmium::index::map::Map< TId, TValue >::used_memory | ( |  | ) | const

pure 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.

Implemented in osmium::index::map::Dummy< TId, TValue >, osmium::index::map::Dummy< osmium::unsigned_object_id_type, osmium::Location >, osmium::index::map::FlexMem< TId, TValue >, and osmium::index::map::SparseMemMap< TId, TValue >.

## Member Data Documentation

## type

template<typename TId, typename TValue>

TId template parameter for class Map must be unsigned integral osmium::index::map::Map< TId, TValue >::type

private

The documentation for this class was generated from the following file:

- include/osmium/index/map.hpp