Switch from stxxl::vector to std::vector in extractor

This commit is contained in:
Michael Krasnyk
2017-07-07 12:09:52 +02:00
committed by Patrick Niklaus
parent a498ba6537
commit 3940cc1641
7 changed files with 96 additions and 58 deletions
+20 -18
View File
@@ -11,9 +11,12 @@
#include "storage/io.hpp"
#include <cstdint>
#include <stxxl/vector>
#include <unordered_map>
#if USE_STXXL_LIBRARY
#include <stxxl/vector>
#endif
namespace osrm
{
namespace extractor
@@ -27,13 +30,12 @@ namespace extractor
*/
class ExtractionContainers
{
#ifndef _MSC_VER
constexpr static unsigned stxxl_memory =
((sizeof(std::size_t) == 4) ? std::numeric_limits<int>::max()
: std::numeric_limits<unsigned>::max());
#if USE_STXXL_LIBRARY
template <typename T> using ExternalVector = stxxl::vector<T>;
#else
const static unsigned stxxl_memory = ((sizeof(std::size_t) == 4) ? INT_MAX : UINT_MAX);
template <typename T> using ExternalVector = std::vector<T>;
#endif
void FlushVectors();
void PrepareNodes();
void PrepareRestrictions();
@@ -45,24 +47,24 @@ class ExtractionContainers
void WriteCharData(const std::string &file_name);
public:
using STXXLNodeIDVector = stxxl::vector<OSMNodeID>;
using STXXLNodeVector = stxxl::vector<QueryNode>;
using STXXLEdgeVector = stxxl::vector<InternalExtractorEdge>;
using NodeIDVector = ExternalVector<OSMNodeID>;
using NodeVector = ExternalVector<QueryNode>;
using EdgeVector = ExternalVector<InternalExtractorEdge>;
using RestrictionsVector = std::vector<InputRestrictionContainer>;
using STXXLWayIDStartEndVector = stxxl::vector<FirstAndLastSegmentOfWay>;
using STXXLNameCharData = stxxl::vector<unsigned char>;
using STXXLNameOffsets = stxxl::vector<unsigned>;
using WayIDStartEndVector = ExternalVector<FirstAndLastSegmentOfWay>;
using NameCharData = ExternalVector<unsigned char>;
using NameOffsets = ExternalVector<unsigned>;
std::vector<OSMNodeID> barrier_nodes;
std::vector<OSMNodeID> traffic_lights;
STXXLNodeIDVector used_node_id_list;
STXXLNodeVector all_nodes_list;
STXXLEdgeVector all_edges_list;
STXXLNameCharData name_char_data;
STXXLNameOffsets name_offsets;
NodeIDVector used_node_id_list;
NodeVector all_nodes_list;
EdgeVector all_edges_list;
NameCharData name_char_data;
NameOffsets name_offsets;
// an adjacency array containing all turn lane masks
RestrictionsVector restrictions_list;
STXXLWayIDStartEndVector way_start_end_id_list;
WayIDStartEndVector way_start_end_id_list;
unsigned max_internal_node_id;
std::vector<TurnRestriction> unconditional_turn_restrictions;
@@ -43,7 +43,7 @@ struct FirstAndLastSegmentOfWay
}
};
struct FirstAndLastSegmentOfWayStxxlCompare
struct FirstAndLastSegmentOfWayCompare
{
using value_type = FirstAndLastSegmentOfWay;
bool operator()(const FirstAndLastSegmentOfWay &a, const FirstAndLastSegmentOfWay &b) const
+7
View File
@@ -7,8 +7,13 @@
#include "storage/io.hpp"
#include <cmath>
#include <cstdint>
#if USE_STXXL_LIBRARY
#include <stxxl/vector>
#endif
namespace osrm
{
namespace storage
@@ -58,6 +63,7 @@ inline void write(storage::io::FileWriter &writer, const util::DeallocatingVecto
writer.WriteFrom(vec.bucket_list.back(), last_block_size);
}
#if USE_STXXL_LIBRARY
template <typename T> inline void read(storage::io::FileReader &reader, stxxl::vector<T> &vec)
{
auto size = reader.ReadOne<std::uint64_t>();
@@ -78,6 +84,7 @@ inline void write(storage::io::FileWriter &writer, const stxxl::vector<T> &vec)
writer.WriteOne<T>(vec[idx]);
}
}
#endif
template <typename T> void read(io::FileReader &reader, std::vector<T> &data)
{
+6 -1
View File
@@ -3,11 +3,14 @@
#include "util/log.hpp"
#include <stxxl/mng>
#ifndef _WIN32
#include <sys/resource.h>
#endif
#if USE_STXXL_LIBRARY
#include <stxxl/mng>
#endif
namespace osrm
{
namespace util
@@ -15,6 +18,7 @@ namespace util
inline void DumpSTXXLStats()
{
#if USE_STXXL_LIBRARY
#if STXXL_VERSION_MAJOR > 1 || (STXXL_VERSION_MAJOR == 1 && STXXL_VERSION_MINOR >= 4)
auto manager = stxxl::block_manager::get_instance();
util::Log() << "STXXL: peak bytes used: " << manager->get_maximum_allocation();
@@ -23,6 +27,7 @@ inline void DumpSTXXLStats()
#warning STXXL 1.4+ recommended - STXXL memory summary will not be available
util::Log() << "STXXL: memory summary not available, needs STXXL 1.4 or higher";
#endif
#endif
}
inline void DumpMemoryStats()
+11 -3
View File
@@ -6,8 +6,6 @@
#include "storage/shared_memory_ownership.hpp"
#include <stxxl/vector>
#include <boost/assert.hpp>
#include <boost/iterator/iterator_facade.hpp>
#include <boost/iterator/reverse_iterator.hpp>
@@ -21,6 +19,10 @@
#include <utility>
#include <vector>
#if USE_STXXL_LIBRARY
#include <stxxl/vector>
#endif
namespace osrm
{
namespace util
@@ -209,10 +211,16 @@ template <typename DataT> void swap(vector_view<DataT> &lhs, vector_view<DataT>
std::swap(lhs.m_size, rhs.m_size);
}
#if USE_STXXL_LIBRARY
template <typename T> using ExternalVector = stxxl::vector<T>;
#else
template <typename T> using ExternalVector = std::vector<T>;
#endif
template <typename DataT, storage::Ownership Ownership>
using InternalOrExternalVector =
typename std::conditional<Ownership == storage::Ownership::External,
stxxl::vector<DataT>,
ExternalVector<DataT>,
std::vector<DataT>>::type;
template <typename DataT, storage::Ownership Ownership>