Revert "fixing line endings"

This reverts commit dc75469e78.
This commit is contained in:
Dennis Luxen
2014-08-15 18:53:00 +02:00
parent dc75469e78
commit 5efa9664db
131 changed files with 0 additions and 21457 deletions
-78
View File
@@ -1,78 +0,0 @@
#ifndef OSMIUM_DETAIL_MMAP_VECTOR_ANON_HPP
#define OSMIUM_DETAIL_MMAP_VECTOR_ANON_HPP
/*
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#ifdef __linux__
#include <cstddef>
#include <osmium/index/detail/typed_mmap.hpp>
#include <osmium/index/detail/mmap_vector_base.hpp>
namespace osmium {
namespace detail {
/**
* This class looks and behaves like STL vector, but uses mmap internally.
*/
template <typename T>
class mmap_vector_anon : public mmap_vector_base<T, mmap_vector_anon> {
public:
mmap_vector_anon() :
mmap_vector_base<T, osmium::detail::mmap_vector_anon>(
-1,
osmium::detail::mmap_vector_size_increment,
0,
osmium::detail::typed_mmap<T>::map(osmium::detail::mmap_vector_size_increment)) {
}
void reserve(size_t new_capacity) {
if (new_capacity > this->capacity()) {
this->data(osmium::detail::typed_mmap<T>::remap(this->data(), this->capacity(), new_capacity));
this->m_capacity = new_capacity;
}
}
}; // class mmap_vector_anon
} // namespace detail
} // namespace osmium
#endif // __linux__
#endif // OSMIUM_DETAIL_MMAP_VECTOR_ANON_HPP
-183
View File
@@ -1,183 +0,0 @@
#ifndef OSMIUM_DETAIL_MMAP_VECTOR_BASE_HPP
#define OSMIUM_DETAIL_MMAP_VECTOR_BASE_HPP
/*
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include <cstddef>
#include <new>
#include <stdexcept>
#include <osmium/index/detail/typed_mmap.hpp>
namespace osmium {
namespace detail {
constexpr size_t mmap_vector_size_increment = 1024 * 1024;
/**
* This is a base class for implementing classes that look like
* STL vector but use mmap internally. This class can not be used
* on it's own. Use the derived classes mmap_vector_anon or
* mmap_vector_file.
*/
template <typename T, template <typename> class TDerived>
class mmap_vector_base {
protected:
int m_fd;
size_t m_capacity;
size_t m_size;
T* m_data;
explicit mmap_vector_base(int fd, size_t capacity, size_t size, T* data) :
m_fd(fd),
m_capacity(capacity),
m_size(size),
m_data(data) {
}
explicit mmap_vector_base(int fd, size_t capacity, size_t size) :
m_fd(fd),
m_capacity(capacity),
m_size(size),
m_data(osmium::detail::typed_mmap<T>::grow_and_map(capacity, m_fd)) {
}
void data(T* data) {
m_data = data;
}
public:
typedef T value_type;
typedef T& reference;
typedef const T& const_reference;
typedef T* pointer;
typedef const T* const_pointer;
typedef T* iterator;
typedef const T* const_iterator;
~mmap_vector_base() {
osmium::detail::typed_mmap<T>::unmap(m_data, m_capacity);
}
size_t capacity() const {
return m_capacity;
}
size_t size() const {
return m_size;
}
bool empty() const {
return m_size == 0;
}
const T* data() const {
return m_data;
}
T* data() {
return m_data;
}
T& operator[](size_t n) {
return m_data[n];
}
T at(size_t n) const {
if (n >= m_size) {
throw std::out_of_range("out of range");
}
return m_data[n];
}
void clear() {
m_size = 0;
}
void shrink_to_fit() {
// XXX do something here
}
void push_back(const T& value) {
if (m_size >= m_capacity) {
resize(m_size+1);
}
m_data[m_size] = value;
++m_size;
}
void resize(size_t new_size) {
if (new_size > this->capacity()) {
static_cast<TDerived<T>*>(this)->reserve(new_size + osmium::detail::mmap_vector_size_increment);
}
if (new_size > this->size()) {
new (this->data() + this->size()) T[new_size - this->size()];
}
this->m_size = new_size;
}
iterator begin() {
return m_data;
}
iterator end() {
return m_data + m_size;
}
const_iterator begin() const {
return m_data;
}
const_iterator end() const {
return m_data + m_size;
}
const_iterator cbegin() {
return m_data;
}
const_iterator cend() {
return m_data + m_size;
}
}; // class mmap_vector_base
} // namespace detail
} // namespace osmium
#endif // OSMIUM_DETAIL_MMAP_VECTOR_BASE_HPP
-83
View File
@@ -1,83 +0,0 @@
#ifndef OSMIUM_DETAIL_MMAP_VECTOR_FILE_HPP
#define OSMIUM_DETAIL_MMAP_VECTOR_FILE_HPP
/*
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include <cstddef>
#include <osmium/index/detail/typed_mmap.hpp>
#include <osmium/index/detail/mmap_vector_base.hpp>
#include <osmium/index/detail/tmpfile.hpp>
namespace osmium {
namespace detail {
/**
* This class looks and behaves like STL vector, but mmap's a file internally.
*/
template <typename T>
class mmap_vector_file : public mmap_vector_base<T, mmap_vector_file> {
public:
explicit mmap_vector_file() :
mmap_vector_base<T, osmium::detail::mmap_vector_file>(
osmium::detail::create_tmp_file(),
osmium::detail::mmap_vector_size_increment,
0) {
}
explicit mmap_vector_file(int fd) :
mmap_vector_base<T, osmium::detail::mmap_vector_file>(
fd,
osmium::detail::typed_mmap<T>::file_size(fd) == 0 ? osmium::detail::mmap_vector_size_increment : osmium::detail::typed_mmap<T>::file_size(fd),
osmium::detail::typed_mmap<T>::file_size(fd)) {
}
void reserve(size_t new_capacity) {
if (new_capacity > this->capacity()) {
osmium::detail::typed_mmap<T>::unmap(this->data(), this->capacity());
osmium::detail::typed_mmap<T>::grow_file(new_capacity, this->m_fd);
osmium::detail::typed_mmap<T>::map(new_capacity, this->m_fd);
this->m_capacity = new_capacity;
}
}
}; // class mmap_vector_file
} // namespace detail
} // namespace osmium
#endif // OSMIUM_DETAIL_MMAP_VECTOR_FILE_HPP
-62
View File
@@ -1,62 +0,0 @@
#ifndef OSMIUM_DETAIL_TMPFILE_HPP
#define OSMIUM_DETAIL_TMPFILE_HPP
/*
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include <cerrno>
#include <cstdio>
#include <system_error>
namespace osmium {
namespace detail {
/**
* Create and open a temporary file. It is removed after opening.
*
* @return File descriptor of temporary file.
* @exception std::system_error if something went wrong.
*/
inline int create_tmp_file() {
FILE* file = ::tmpfile();
if (!file) {
throw std::system_error(errno, std::system_category(), "tempfile failed");
}
return fileno(file);
}
} // namespace detail
} // namespace osmium
#endif // OSMIUM_DETAIL_TMPFILE
-217
View File
@@ -1,217 +0,0 @@
#ifndef OSMIUM_DETAIL_TYPED_MMAP_HPP
#define OSMIUM_DETAIL_TYPED_MMAP_HPP
/*
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include <cerrno>
#include <cstddef>
#include <stdexcept>
#include <system_error>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
// for bsd systems
#ifndef MAP_ANONYMOUS
# define MAP_ANONYMOUS MAP_ANON
#endif
namespace osmium {
/**
* @brief Namespace for Osmium internal use
*/
namespace detail {
/**
* This is a helper class for working with memory mapped files and
* anonymous shared memory. It wraps the necessary system calls
* adding:
* - error checking: all functions throw exceptions where needed
* - internal casts and size calculations allow use with user defined
* type T instead of void*
*
* This class only contains static functions. It should never be
* instantiated.
*
* @tparam T Type of objects we want to store.
*/
template <typename T>
class typed_mmap {
public:
/**
* Create anonymous private memory mapping with enough space for size
* objects of type T.
*
* Note that no constructor is called for any of the objects in this memory!
*
* @param size Number of objects of type T that should fit into this memory
* @return Pointer to mapped memory
* @exception std::system_error If mmap(2) failed
*/
static T* map(size_t size) {
void* addr = ::mmap(nullptr, sizeof(T) * size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wold-style-cast"
if (addr == MAP_FAILED) {
throw std::system_error(errno, std::system_category(), "mmap failed");
}
#pragma GCC diagnostic pop
return reinterpret_cast<T*>(addr);
}
/**
* Create shared memory mapping of a file with enough space for size
* objects of type T. The file must already have at least the
* required size.
*
* Note that no constructor is called for any of the objects in this memory!
*
* @param size Number of objects of type T that should fit into this memory
* @param fd File descriptor
* @param write True if data should be writable
* @return Pointer to mapped memory
* @exception std::system_error If mmap(2) failed
*/
static T* map(size_t size, int fd, bool write = false) {
int prot = PROT_READ;
if (write) {
prot |= PROT_WRITE;
}
void* addr = ::mmap(nullptr, sizeof(T) * size, prot, MAP_SHARED, fd, 0);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wold-style-cast"
if (addr == MAP_FAILED) {
throw std::system_error(errno, std::system_category(), "mmap failed");
}
#pragma GCC diagnostic pop
return reinterpret_cast<T*>(addr);
}
// mremap(2) is only available on linux systems
#ifdef __linux__
/**
* Grow memory mapping created with map().
*
* Note that no constructor is called for any of the objects in this memory!
*
* @param data Pointer to current mapping (as returned by typed_mmap())
* @param old_size Number of objects currently stored in this memory
* @param new_size Number of objects we want to have space for
* @exception std::system_error If mremap(2) call failed
*/
static T* remap(T* data, size_t old_size, size_t new_size) {
void* addr = ::mremap(reinterpret_cast<void*>(data), sizeof(T) * old_size, sizeof(T) * new_size, MREMAP_MAYMOVE);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wold-style-cast"
if (addr == MAP_FAILED) {
throw std::system_error(errno, std::system_category(), "mremap failed");
}
#pragma GCC diagnostic pop
return reinterpret_cast<T*>(addr);
}
#endif
/**
* Release memory from map() call.
*
* Note that no destructor is called for the objects in this memory!
*
* @param data Pointer to the data
* @param size Number of objects of type T stored
* @exception std::system_error If munmap(2) call failed
*/
static void unmap(T* data, size_t size) {
if (::munmap(reinterpret_cast<void*>(data), sizeof(T) * size) != 0) {
throw std::system_error(errno, std::system_category(), "munmap failed");
}
}
/**
* Get number of objects of type T that would fit into a file.
*
* @param fd File descriptor
* @return Number of objects of type T in this file
* @exception std::system_error If fstat(2) call failed
* @exception std::length_error If size of the file isn't a multiple of sizeof(T)
*/
static size_t file_size(int fd) {
struct stat s;
if (fstat(fd, &s) < 0) {
throw std::system_error(errno, std::system_category(), "fstat failed");
}
if (s.st_size % sizeof(T) != 0) {
throw std::length_error("file size has to be multiple of object size");
}
return s.st_size / sizeof(T);
}
/**
* Grow file so there is enough space for at least new_size objects
* of type T. If the file is large enough already, nothing is done.
* The file is never shrunk.
*
* @param new_size Number of objects of type T that should fit into this file
* @param fd File descriptor
* @exception std::system_error If ftruncate(2) call failed
*/
static void grow_file(size_t new_size, int fd) {
if (file_size(fd) < new_size) {
if (::ftruncate(fd, sizeof(T) * new_size) < 0) {
throw std::system_error(errno, std::system_category(), "ftruncate failed");
}
}
}
/**
* Grow file to given size (if it is smaller) and mmap it.
*
* @param size Number of objects of type T that should fit into this file
* @param fd File descriptor
* @exception Errors thrown by grow_file() or map()
*/
static T* grow_and_map(size_t size, int fd) {
grow_file(size, fd);
return map(size, fd, true);
}
}; // class typed_mmap
} // namespace detail
} // namespace osmium
#endif // OSMIUM_DETAIL_TYPED_MMAP_HPP
-98
View File
@@ -1,98 +0,0 @@
#ifndef OSMIUM_INDEX_INDEX_HPP
#define OSMIUM_INDEX_INDEX_HPP
/*
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include <cstddef>
#include <limits>
#include <sstream>
#include <stdexcept>
#include <string>
namespace osmium {
/**
* Exception signaling that an element could not be
* found in an index.
*/
struct not_found : public std::runtime_error {
not_found(const std::string& what) :
std::runtime_error(what) {
}
not_found(const char* what) :
std::runtime_error(what) {
}
}; // struct not_found
/**
* @brief Indexing of OSM data, Locations, etc.
*/
namespace index {
template <typename TKey>
[[noreturn]] void not_found_error(TKey key) {
std::stringstream s;
s << "id " << key << " no found";
throw not_found(s.str());
}
/**
* Some of the index classes need an "empty" value that can
* never appear in real data. This function must return this
* empty value for any class used as a value in an index.
* The default implementation returns a default constructed
* object, but it can be specialized.
*/
template <typename T>
inline constexpr T empty_value() {
return T{};
}
/**
* The size_t value in indexes is usually used for offsets
* into a buffer or file. It is unlikely that we ever need
* the full range, so the max value is a good "empty" value.
*/
template <>
inline constexpr size_t empty_value<size_t>() {
return std::numeric_limits<size_t>::max();
}
} // namespace index
} // namespace osmium
#endif // OSMIUM_INDEX_INDEX_HPP
-156
View File
@@ -1,156 +0,0 @@
#ifndef OSMIUM_INDEX_MAP_HPP
#define OSMIUM_INDEX_MAP_HPP
/*
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include <cstddef>
#include <type_traits>
#include <osmium/index/index.hpp> // IWYU pragma: export
namespace osmium {
namespace index {
/**
* @brief Key-value containers with unique integer values for a key
*/
namespace map {
/**
* 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!
*
* @tparam TId Id type, usually osmium::unsigned_object_id_type,
* must be an unsigned integral type.
* @tparam TValue Value type, usually osmium::Location or size_t.
* Copied by value, so should be "small" type.
*/
template <typename TId, typename TValue>
class Map {
static_assert(std::is_integral<TId>::value && std::is_unsigned<TId>::value,
"TId template parameter for class Map must be unsigned integral type");
Map(const Map&) = delete;
Map& operator=(const Map&) = delete;
protected:
Map(Map&&) = default;
Map& operator=(Map&&) = default;
public:
/// The "key" type, usually osmium::unsigned_object_id_type.
typedef TId key_type;
/// The "value" type, usually a Location or size_t.
typedef TValue value_type;
Map() = default;
// workaround for a bug in GCC 4.7
#if __GNUC__ == 4 && __GNUC_MINOR__ < 8
virtual ~Map() {}
#else
virtual ~Map() = default;
#endif
virtual void reserve(const size_t) {
// default implementation is empty
}
/// Set the field with id to value.
virtual void set(const TId id, const TValue value) = 0;
/// Retrieve value by id. Does not check for overflow or empty fields.
virtual const TValue get(const TId id) const = 0;
/**
* 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.
*/
virtual size_t size() const = 0;
/**
* 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.
*/
virtual size_t used_memory() const = 0;
/**
* Clear memory used for this storage. After this you can not
* use the storage container any more.
*/
virtual void clear() = 0;
/**
* Sort data in map. Call this after writing all data and
* before reading. Not all implementations need this.
*/
virtual void sort() {
// default implementation is empty
}
}; // class Map
} // namespace map
} // namespace index
} // namespace osmium
#endif // OSMIUM_INDEX_MAP_HPP
-87
View File
@@ -1,87 +0,0 @@
#ifndef OSMIUM_INDEX_MAP_DUMMY_HPP
#define OSMIUM_INDEX_MAP_DUMMY_HPP
/*
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include <cstddef>
#include <osmium/index/map.hpp>
namespace osmium {
namespace index {
namespace map {
/**
* Pseudo map.
* Use this class if you don't need a map, but you
* need an object that behaves like one.
*/
template <typename TId, typename TValue>
class Dummy : public osmium::index::map::Map<TId, TValue> {
public:
Dummy() = default;
~Dummy() override final = default;
void set(const TId, const TValue) override final {
// intentionally left blank
}
const TValue get(const TId id) const override final {
not_found_error(id);
}
size_t size() const override final {
return 0;
}
size_t used_memory() const override final {
return 0;
}
void clear() override final {
}
}; // class Dummy
} // namespace map
} // namespace index
} // namespace osmium
#endif // OSMIUM_INDEX_MAP_DUMMY_HPP
-61
View File
@@ -1,61 +0,0 @@
#ifndef OSMIUM_INDEX_MAP_MMAP_VECTOR_ANON_HPP
#define OSMIUM_INDEX_MAP_MMAP_VECTOR_ANON_HPP
/*
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#ifdef __linux__
#include <osmium/index/map/vector.hpp>
#include <osmium/index/detail/mmap_vector_anon.hpp>
namespace osmium {
namespace index {
namespace map {
template <typename TId, typename TValue>
using DenseMapMmap = VectorBasedDenseMap<osmium::detail::mmap_vector_anon<TValue>, TId, TValue>;
template <typename TId, typename TValue>
using SparseMapMmap = VectorBasedSparseMap<TId, TValue, osmium::detail::mmap_vector_anon>;
} // namespace map
} // namespace index
} // namespace osmium
#endif // __linux__
#endif // OSMIUM_INDEX_MAP_MMAP_VECTOR_ANON_HPP
-57
View File
@@ -1,57 +0,0 @@
#ifndef OSMIUM_INDEX_MAP_MMAP_VECTOR_FILE_HPP
#define OSMIUM_INDEX_MAP_MMAP_VECTOR_FILE_HPP
/*
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include <osmium/index/map/vector.hpp>
#include <osmium/index/detail/mmap_vector_file.hpp>
namespace osmium {
namespace index {
namespace map {
template <typename TId, typename TValue>
using DenseMapFile = VectorBasedDenseMap<osmium::detail::mmap_vector_file<TValue>, TId, TValue>;
template <typename TId, typename TValue>
using SparseMapFile = VectorBasedSparseMap<TId, TValue, osmium::detail::mmap_vector_file>;
} // namespace map
} // namespace index
} // namespace osmium
#endif // OSMIUM_INDEX_MAP_MMAP_VECTOR_FILE_HPP
-140
View File
@@ -1,140 +0,0 @@
#ifndef OSMIUM_INDEX_MAP_SPARSE_TABLE_HPP
#define OSMIUM_INDEX_MAP_SPARSE_TABLE_HPP
/*
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include <cstddef>
#include <stdexcept>
#include <utility>
#include <vector>
#include <google/sparsetable>
#include <osmium/index/map.hpp>
#include <osmium/io/detail/read_write.hpp>
namespace osmium {
namespace index {
namespace map {
/**
* The SparseTable index stores elements in a Google sparsetable,
* a data structure that can hold sparsly filled tables in a
* very space efficient way. It will resize automatically.
*
* Use this index if the ID space is only sparsly
* populated, such as when working with smaller OSM files (like
* country extracts).
*
* This will only work on 64 bit machines.
*/
template <typename TId, typename TValue>
class SparseTable : public osmium::index::map::Map<TId, TValue> {
TId m_grow_size;
google::sparsetable<TValue> m_elements;
static_assert(sizeof(typename google::sparsetable<TValue>::size_type) >= 8, "google::sparsetable needs 64bit machine");
public:
/**
* Constructor.
*
* @param grow_size The initial size of the index (ie number of
* elements that fit into the index).
* The storage will grow by at least this size
* every time it runs out of space.
*/
explicit SparseTable(const TId grow_size=10000) :
m_grow_size(grow_size),
m_elements(grow_size) {
}
~SparseTable() override final = default;
void set(const TId id, const TValue value) override final {
if (id >= m_elements.size()) {
m_elements.resize(id + m_grow_size);
}
m_elements[id] = value;
}
const TValue get(const TId id) const override final {
if (id >= m_elements.size()) {
not_found_error(id);
}
if (m_elements[id] == osmium::index::empty_value<TValue>()) {
not_found_error(id);
}
return m_elements[id];
}
size_t size() const override final {
return m_elements.size();
}
size_t used_memory() const override final {
// unused elements use 1 bit, used elements sizeof(TValue) bytes
// http://google-sparsehash.googlecode.com/svn/trunk/doc/sparsetable.html
return (m_elements.size() / 8) + (m_elements.num_nonempty() * sizeof(TValue));
}
void clear() override final {
m_elements.clear();
}
void dump_as_list(const int fd) const {
std::vector<std::pair<TId, TValue>> v;
int n=0;
for (const TValue value : m_elements) {
if (value != osmium::index::empty_value<TValue>()) {
v.emplace_back(n, value);
}
++n;
}
osmium::io::detail::reliable_write(fd, reinterpret_cast<const char*>(v.data()), sizeof(std::pair<TId, TValue>) * v.size());
}
}; // class SparseTable
} // namespace map
} // namespace index
} // namespace osmium
#endif // OSMIUM_INDEX_BYID_SPARSE_TABLE_HPP
-112
View File
@@ -1,112 +0,0 @@
#ifndef OSMIUM_INDEX_MAP_STL_MAP_HPP
#define OSMIUM_INDEX_MAP_STL_MAP_HPP
/*
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include <algorithm>
#include <cstddef>
#include <iterator>
#include <map>
#include <stdexcept>
#include <vector>
#include <osmium/index/map.hpp>
#include <osmium/io/detail/read_write.hpp>
namespace osmium {
namespace index {
namespace map {
/**
* This implementation uses std::map internally. It uses rather a
* lot of memory, but might make sense for small maps.
*/
template <typename TId, typename TValue>
class StlMap : public osmium::index::map::Map<TId, TValue> {
// This is a rough estimate for the memory needed for each
// element in the map (id + value + pointers to left, right,
// and parent plus some overhead for color of red-black-tree
// or similar).
static constexpr size_t element_size = sizeof(TId) + sizeof(TValue) + sizeof(void*) * 4;
std::map<TId, TValue> m_elements;
public:
StlMap() = default;
~StlMap() override final = default;
void set(const TId id, const TValue value) override final {
m_elements[id] = value;
}
const TValue get(const TId id) const override final {
try {
return m_elements.at(id);
} catch (std::out_of_range&) {
not_found_error(id);
}
}
size_t size() const override final {
return m_elements.size();
}
size_t used_memory() const override final {
return element_size * m_elements.size();
}
void clear() override final {
m_elements.clear();
}
void dump_as_list(const int fd) const {
typedef typename std::map<TId, TValue>::value_type t;
std::vector<t> v;
std::copy(m_elements.begin(), m_elements.end(), std::back_inserter(v));
osmium::io::detail::reliable_write(fd, reinterpret_cast<const char*>(v.data()), sizeof(t) * v.size());
}
}; // class StlMap
} // namespace map
} // namespace index
} // namespace osmium
#endif // OSMIUM_INDEX_MAP_STL_MAP_HPP
-58
View File
@@ -1,58 +0,0 @@
#ifndef OSMIUM_INDEX_MAP_STL_VECTOR_HPP
#define OSMIUM_INDEX_MAP_STL_VECTOR_HPP
/*
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include <vector>
#include <osmium/index/map/vector.hpp>
namespace osmium {
namespace index {
namespace map {
template <typename TId, typename TValue>
using DenseMapMem = VectorBasedDenseMap<std::vector<TValue>, TId, TValue>;
template <typename TId, typename TValue>
using SparseMapMem = VectorBasedSparseMap<TId, TValue, std::vector>;
} // namespace map
} // namespace index
} // namespace osmium
#endif // OSMIUM_INDEX_MAP_STL_VECTOR_HPP
-208
View File
@@ -1,208 +0,0 @@
#ifndef OSMIUM_INDEX_MAP_VECTOR_HPP
#define OSMIUM_INDEX_MAP_VECTOR_HPP
/*
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include <algorithm>
#include <cstddef>
#include <stdexcept>
#include <utility>
#include <osmium/index/map.hpp>
#include <osmium/io/detail/read_write.hpp>
namespace osmium {
namespace index {
namespace map {
template <class TVector, typename TId, typename TValue>
class VectorBasedDenseMap : public Map<TId, TValue> {
TVector m_vector;
public:
VectorBasedDenseMap() :
m_vector() {
}
explicit VectorBasedDenseMap(int fd) :
m_vector(fd) {
}
~VectorBasedDenseMap() {}
void reserve(const size_t size) override final {
m_vector.reserve(size);
}
void set(const TId id, const TValue value) override final {
if (size() <= id) {
m_vector.resize(id+1);
}
m_vector[id] = value;
}
const TValue get(const TId id) const override final {
try {
const TValue& value = m_vector.at(id);
if (value == osmium::index::empty_value<TValue>()) {
not_found_error(id);
}
return value;
} catch (std::out_of_range&) {
not_found_error(id);
}
}
size_t size() const override final {
return m_vector.size();
}
size_t used_memory() const override final {
return sizeof(TValue) * size();
}
void clear() override final {
m_vector.clear();
m_vector.shrink_to_fit();
}
}; // class VectorBasedDenseMap
template <typename TId, typename TValue, template<typename...> class TVector>
class VectorBasedSparseMap : public Map<TId, TValue> {
public:
typedef typename std::pair<TId, TValue> element_type;
typedef TVector<element_type> vector_type;
typedef typename vector_type::iterator iterator;
typedef typename vector_type::const_iterator const_iterator;
private:
vector_type m_vector;
public:
VectorBasedSparseMap() :
m_vector() {
}
VectorBasedSparseMap(int fd) :
m_vector(fd) {
}
~VectorBasedSparseMap() override final = default;
void set(const TId id, const TValue value) override final {
m_vector.push_back(element_type(id, value));
}
const TValue get(const TId id) const override final {
const element_type element {
id,
osmium::index::empty_value<TValue>()
};
const auto result = std::lower_bound(m_vector.begin(), m_vector.end(), element, [](const element_type& a, const element_type& b) {
return a.first < b.first;
});
if (result == m_vector.end() || result->first != id) {
not_found_error(id);
} else {
return result->second;
}
}
size_t size() const override final {
return m_vector.size();
}
size_t byte_size() const {
return m_vector.size() * sizeof(element_type);
}
size_t used_memory() const override final {
return sizeof(element_type) * size();
}
void clear() override final {
m_vector.clear();
m_vector.shrink_to_fit();
}
void sort() override final {
std::sort(m_vector.begin(), m_vector.end());
}
void dump_as_list(int fd) const {
osmium::io::detail::reliable_write(fd, reinterpret_cast<const char*>(m_vector.data()), byte_size());
}
iterator begin() {
return m_vector.begin();
}
iterator end() {
return m_vector.end();
}
const_iterator cbegin() const {
return m_vector.cbegin();
}
const_iterator cend() const {
return m_vector.cend();
}
const_iterator begin() const {
return m_vector.cbegin();
}
const_iterator end() const {
return m_vector.cend();
}
}; // class VectorBasedSparseMap
} // namespace map
} // namespace index
} // namespace osmium
#endif // OSMIUM_INDEX_MAP_VECTOR_HPP
-125
View File
@@ -1,125 +0,0 @@
#ifndef OSMIUM_INDEX_MULTIMAP_HPP
#define OSMIUM_INDEX_MULTIMAP_HPP
/*
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include <cstddef>
#include <type_traits>
#include <utility>
#include <osmium/index/index.hpp> // IWYU pragma: export
namespace osmium {
namespace index {
/**
* @brief Key-value containers with multiple values for an integer key
*/
namespace multimap {
template <typename TId, typename TValue>
class Multimap {
static_assert(std::is_integral<TId>::value && std::is_unsigned<TId>::value,
"TId template parameter for class Multimap must be unsigned integral type");
typedef typename std::pair<TId, TValue> element_type;
Multimap(const Multimap&) = delete;
Multimap& operator=(const Multimap&) = delete;
protected:
Multimap(Multimap&&) = default;
Multimap& operator=(Multimap&&) = default;
public:
/// The "key" type, usually osmium::unsigned_object_id_type.
typedef TId key_type;
/// The "value" type, usually a Location or size_t.
typedef TValue value_type;
Multimap() = default;
virtual ~Multimap() noexcept = default;
/// Set the field with id to value.
virtual void set(const TId id, const TValue value) = 0;
typedef element_type* iterator;
// virtual std::pair<iterator, iterator> get_all(const TId id) const = 0;
/**
* 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.
*/
virtual size_t size() const = 0;
/**
* 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.
*/
virtual size_t used_memory() const = 0;
/**
* Clear memory used for this storage. After this you can not
* use the storage container any more.
*/
virtual void clear() = 0;
/**
* Sort data in map. Call this after writing all data and
* before reading. Not all implementations need this.
*/
virtual void sort() {
// default implementation is empty
}
}; // class Multimap
} // namespace map
} // namespace index
} // namespace osmium
#endif // OSMIUM_INDEX_MULTIMAP_HPP
-199
View File
@@ -1,199 +0,0 @@
#ifndef OSMIUM_INDEX_MULTIMAP_HYBRID_HPP
#define OSMIUM_INDEX_MULTIMAP_HYBRID_HPP
/*
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include <cstddef>
#include <utility>
#include <osmium/index/multimap.hpp>
#include <osmium/index/multimap/stl_vector.hpp>
#include <osmium/index/multimap/stl_multimap.hpp>
namespace osmium {
namespace index {
namespace multimap {
template <typename TId, typename TValue>
class HybridIterator {
typedef SparseMultimapMem<TId, TValue> main_map_type;
typedef StlMultimap<TId, TValue> extra_map_type;
typedef typename std::pair<TId, TValue> element_type;
typename main_map_type::iterator m_begin_main;
typename main_map_type::iterator m_end_main;
typename extra_map_type::iterator m_begin_extra;
typename extra_map_type::iterator m_end_extra;
public:
explicit HybridIterator(typename main_map_type::iterator begin_main,
typename main_map_type::iterator end_main,
typename extra_map_type::iterator begin_extra,
typename extra_map_type::iterator end_extra) :
m_begin_main(begin_main),
m_end_main(end_main),
m_begin_extra(begin_extra),
m_end_extra(end_extra) {
}
HybridIterator& operator++() {
if (m_begin_main == m_end_main) {
++m_begin_extra;
} else {
++m_begin_main;
while (m_begin_main != m_end_main && m_begin_main->second == osmium::index::empty_value<TValue>()) { // ignore removed elements
++m_begin_main;
}
}
return *this;
}
HybridIterator<TId, TValue> operator++(int) {
auto tmp(*this);
operator++();
return tmp;
}
bool operator==(const HybridIterator& rhs) const {
return m_begin_main == rhs.m_begin_main &&
m_end_main == rhs.m_end_main &&
m_begin_extra == rhs.m_begin_extra &&
m_end_extra == rhs.m_end_extra;
}
bool operator!=(const HybridIterator& rhs) const {
return ! operator==(rhs);
}
const element_type& operator*() {
if (m_begin_main == m_end_main) {
return *m_begin_extra;
} else {
return *m_begin_main;
}
}
const element_type* operator->() {
return &operator*();
}
};
template <typename TId, typename TValue>
class Hybrid : public Multimap<TId, TValue> {
typedef SparseMultimapMem<TId, TValue> main_map_type;
typedef StlMultimap<TId, TValue> extra_map_type;
main_map_type m_main;
extra_map_type m_extra;
public:
typedef HybridIterator<TId, TValue> iterator;
typedef const HybridIterator<TId, TValue> const_iterator;
Hybrid() :
m_main(),
m_extra() {
}
size_t size() const override final {
return m_main.size() + m_extra.size();
}
size_t used_memory() const override final {
return m_main.used_memory() + m_extra.used_memory();
}
void reserve(const size_t size) {
m_main.reserve(size);
}
void unsorted_set(const TId id, const TValue value) {
m_main.set(id, value);
}
void set(const TId id, const TValue value) override final {
m_extra.set(id, value);
}
std::pair<iterator, iterator> get_all(const TId id) {
auto result_main = m_main.get_all(id);
auto result_extra = m_extra.get_all(id);
return std::make_pair(iterator(result_main.first, result_main.second, result_extra.first, result_extra.second),
iterator(result_main.second, result_main.second, result_extra.second, result_extra.second));
}
void remove(const TId id, const TValue value) {
m_main.remove(id, value);
m_extra.remove(id, value);
}
void consolidate() {
m_main.erase_removed();
for (const auto& element : m_extra) {
m_main.set(element.first, element.second);
}
m_extra.clear();
m_main.sort();
}
void dump_as_list(int fd) {
consolidate();
m_main.dump_as_list(fd);
}
void clear() override final {
m_main.clear();
m_extra.clear();
}
void sort() override final {
m_main.sort();
}
}; // Hybrid
} // namespace multimap
} // namespace index
} // namespace osmium
#endif // OSMIUM_INDEX_MULTIMAP_HYBRID_HPP
-58
View File
@@ -1,58 +0,0 @@
#ifndef OSMIUM_INDEX_MULTIMAP_MMAP_VECTOR_ANON_HPP
#define OSMIUM_INDEX_MULTIMAP_MMAP_VECTOR_ANON_HPP
/*
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#ifdef __linux__
#include <osmium/index/multimap/vector.hpp>
#include <osmium/index/detail/mmap_vector_anon.hpp>
namespace osmium {
namespace index {
namespace multimap {
template <typename TId, typename TValue>
using SparseMultimapMmap = VectorBasedSparseMultimap<TId, TValue, osmium::detail::mmap_vector_anon>;
} // namespace multimap
} // namespace index
} // namespace osmium
#endif // __linux__
#endif // OSMIUM_INDEX_MULTIMAP_MMAP_VECTOR_ANON_HPP
-54
View File
@@ -1,54 +0,0 @@
#ifndef OSMIUM_INDEX_MULTIMAP_MMAP_VECTOR_FILE_HPP
#define OSMIUM_INDEX_MULTIMAP_MMAP_VECTOR_FILE_HPP
/*
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include <osmium/index/multimap/vector.hpp>
#include <osmium/index/detail/mmap_vector_file.hpp>
namespace osmium {
namespace index {
namespace multimap {
template <typename TId, typename TValue>
using SparseMultimapFile = VectorBasedSparseMultimap<TId, TValue, osmium::detail::mmap_vector_file>;
} // namespace multimap
} // namespace index
} // namespace osmium
#endif // OSMIUM_INDEX_MULTIMAP_MMAP_VECTOR_FILE_HPP
-151
View File
@@ -1,151 +0,0 @@
#ifndef OSMIUM_INDEX_MULTIMAP_STL_MULTIMAP_HPP
#define OSMIUM_INDEX_MULTIMAP_STL_MULTIMAP_HPP
/*
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include <algorithm>
#include <cstddef>
#include <map>
#include <utility>
#include <vector>
#include <osmium/index/multimap.hpp>
#include <osmium/io/detail/read_write.hpp>
namespace osmium {
namespace index {
namespace multimap {
/**
* This implementation uses std::multimap internally. It uses rather a
* lot of memory, but might make sense for small maps.
*/
template <typename TId, typename TValue>
class StlMultimap : public osmium::index::multimap::Multimap<TId, TValue> {
// This is a rough estimate for the memory needed for each
// element in the map (id + value + pointers to left, right,
// and parent plus some overhead for color of red-black-tree
// or similar).
static constexpr size_t element_size = sizeof(TId) + sizeof(TValue) + sizeof(void*) * 4;
public:
typedef typename std::multimap<const TId, TValue> collection_type;
typedef typename collection_type::iterator iterator;
typedef typename collection_type::const_iterator const_iterator;
typedef typename collection_type::value_type value_type;
typedef typename std::pair<TId, TValue> element_type;
private:
collection_type m_elements;
public:
StlMultimap() = default;
~StlMultimap() noexcept override final = default;
void unsorted_set(const TId id, const TValue value) {
m_elements.emplace(id, value);
}
void set(const TId id, const TValue value) override final {
m_elements.emplace(id, value);
}
std::pair<iterator, iterator> get_all(const TId id) {
return m_elements.equal_range(id);
}
std::pair<const_iterator, const_iterator> get_all(const TId id) const {
return m_elements.equal_range(id);
}
void remove(const TId id, const TValue value) {
std::pair<iterator, iterator> r = get_all(id);
for (iterator it = r.first; it != r.second; ++it) {
if (it->second == value) {
m_elements.erase(it);
return;
}
}
}
iterator begin() {
return m_elements.begin();
}
iterator end() {
return m_elements.end();
}
size_t size() const override final {
return m_elements.size();
}
size_t used_memory() const override final {
return element_size * m_elements.size();
}
void clear() override final {
m_elements.clear();
}
void consolidate() {
// intentionally left blank
}
void dump_as_list(const int fd) const {
std::vector<element_type> v;
for (const auto& element : m_elements) {
v.emplace_back(element.first, element.second);
}
// std::copy(m_elements.cbegin(), m_elements.cend(), std::back_inserter(v));
std::sort(v.begin(), v.end());
osmium::io::detail::reliable_write(fd, reinterpret_cast<const char*>(v.data()), sizeof(element_type) * v.size());
}
}; // class StlMultimap
} // namespace multimap
} // namespace index
} // namespace osmium
#endif // OSMIUM_INDEX_MULTIMAP_STL_MULTIMAP_HPP
-55
View File
@@ -1,55 +0,0 @@
#ifndef OSMIUM_INDEX_MULTIMAP_STL_VECTOR_HPP
#define OSMIUM_INDEX_MULTIMAP_STL_VECTOR_HPP
/*
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include <vector>
#include <osmium/index/multimap/vector.hpp>
namespace osmium {
namespace index {
namespace multimap {
template <typename TId, typename TValue>
using SparseMultimapMem = VectorBasedSparseMultimap<TId, TValue, std::vector>;
} // namespace multimap
} // namespace index
} // namespace osmium
#endif // OSMIUM_INDEX_MULTIMAP_STL_VECTOR_HPP
-141
View File
@@ -1,141 +0,0 @@
#ifndef OSMIUM_INDEX_MULTIMAP_VECTOR_HPP
#define OSMIUM_INDEX_MULTIMAP_VECTOR_HPP
/*
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include <algorithm>
#include <cstddef>
#include <utility>
#include <osmium/index/multimap.hpp>
#include <osmium/io/detail/read_write.hpp>
namespace osmium {
namespace index {
namespace multimap {
template <typename TId, typename TValue, template<typename...> class TVector>
class VectorBasedSparseMultimap : public Multimap<TId, TValue> {
public:
typedef typename std::pair<TId, TValue> element_type;
typedef TVector<element_type> vector_type;
typedef typename vector_type::iterator iterator;
typedef typename vector_type::const_iterator const_iterator;
private:
vector_type m_vector;
static bool is_removed(element_type& element) {
return element.second == osmium::index::empty_value<TValue>();
}
public:
void set(const TId id, const TValue value) override final {
m_vector.push_back(element_type(id, value));
}
void unsorted_set(const TId id, const TValue value) {
m_vector.push_back(element_type(id, value));
}
std::pair<iterator, iterator> get_all(const TId id) {
const element_type element {
id,
osmium::index::empty_value<TValue>()
};
return std::equal_range(m_vector.begin(), m_vector.end(), element, [](const element_type& a, const element_type& b) {
return a.first < b.first;
});
}
size_t size() const override final {
return m_vector.size();
}
size_t byte_size() const {
return m_vector.size() * sizeof(element_type);
}
size_t used_memory() const override final {
return sizeof(element_type) * size();
}
void clear() override final {
m_vector.clear();
m_vector.shrink_to_fit();
}
void sort() override final {
std::sort(m_vector.begin(), m_vector.end());
}
void remove(const TId id, const TValue value) {
auto r = get_all(id);
for (auto it = r.first; it != r.second; ++it) {
if (it->second == value) {
it->second = 0;
return;
}
}
}
void consolidate() {
std::sort(m_vector.begin(), m_vector.end());
}
void erase_removed() {
m_vector.erase(
std::remove_if(m_vector.begin(), m_vector.end(), is_removed),
m_vector.end()
);
}
void dump_as_list(int fd) const {
osmium::io::detail::reliable_write(fd, reinterpret_cast<const char*>(m_vector.data()), byte_size());
}
}; // class VectorBasedSparseMultimap
} // namespace multimap
} // namespace index
} // namespace osmium
#endif // OSMIUM_INDEX_MULTIMAP_VECTOR_HPP