Use mmap instead of read - it's a lot faster here.
Also clean up construction of STRONG_TYPEDEF so that it can be
packed properly in structs (this explains all the () -> {}) changes
here.
This commit is contained in:
@@ -43,6 +43,34 @@ namespace osrm
|
||||
namespace extractor
|
||||
{
|
||||
|
||||
namespace lookup
|
||||
{
|
||||
// Set to 1 byte alignment
|
||||
struct SegmentHeaderBlock
|
||||
{
|
||||
std::uint32_t num_osm_nodes;
|
||||
OSMNodeID previous_osm_node_id;
|
||||
} __attribute ((packed));
|
||||
static_assert(sizeof(SegmentHeaderBlock) == 12, "SegmentHeaderBlock is not packed correctly");
|
||||
|
||||
struct SegmentBlock
|
||||
{
|
||||
OSMNodeID this_osm_node_id;
|
||||
double segment_length;
|
||||
std::int32_t segment_weight;
|
||||
} __attribute ((packed));
|
||||
static_assert(sizeof(SegmentBlock) == 20, "SegmentBlock is not packed correctly");
|
||||
|
||||
struct PenaltyBlock
|
||||
{
|
||||
std::uint32_t fixed_penalty;
|
||||
OSMNodeID from_id;
|
||||
OSMNodeID via_id;
|
||||
OSMNodeID to_id;
|
||||
} __attribute ((packed));
|
||||
static_assert(sizeof(PenaltyBlock) == 28, "PenaltyBlock is not packed correctly");
|
||||
}
|
||||
|
||||
class EdgeBasedGraphFactory
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace extractor
|
||||
@@ -26,13 +28,13 @@ struct ExternalMemoryNode : QueryNode
|
||||
static ExternalMemoryNode min_value()
|
||||
{
|
||||
return ExternalMemoryNode(
|
||||
util::FixedLongitude(0), util::FixedLatitude(0), MIN_OSM_NODEID, false, false);
|
||||
util::FixedLongitude{0}, util::FixedLatitude{0}, MIN_OSM_NODEID, false, false);
|
||||
}
|
||||
|
||||
static ExternalMemoryNode max_value()
|
||||
{
|
||||
return ExternalMemoryNode(util::FixedLongitude(std::numeric_limits<int>::max()),
|
||||
util::FixedLatitude(std::numeric_limits<int>::max()),
|
||||
return ExternalMemoryNode(util::FixedLongitude{std::numeric_limits<std::int32_t>::max()},
|
||||
util::FixedLatitude{std::numeric_limits<std::int32_t>::max()},
|
||||
MAX_OSM_NODEID,
|
||||
false,
|
||||
false);
|
||||
|
||||
@@ -68,8 +68,8 @@ struct InternalExtractorEdge
|
||||
bool is_split,
|
||||
LaneDescriptionID lane_description,
|
||||
guidance::RoadClassificationData road_classification)
|
||||
: result(OSMNodeID(source),
|
||||
OSMNodeID(target),
|
||||
: result(source,
|
||||
target,
|
||||
name_id,
|
||||
0,
|
||||
forward,
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "util/coordinate.hpp"
|
||||
|
||||
#include <limits>
|
||||
#include <cstdint>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
@@ -15,16 +16,16 @@ namespace extractor
|
||||
struct QueryNode
|
||||
{
|
||||
using key_type = OSMNodeID; // type of NodeID
|
||||
using value_type = int; // type of lat,lons
|
||||
using value_type = std::int32_t; // type of lat,lons
|
||||
|
||||
explicit QueryNode(const util::FixedLongitude lon_,
|
||||
const util::FixedLatitude lat_,
|
||||
key_type node_id)
|
||||
: lon(lon_), lat(lat_), node_id(std::move(node_id))
|
||||
const key_type node_id_)
|
||||
: lon(lon_), lat(lat_), node_id(node_id_)
|
||||
{
|
||||
}
|
||||
QueryNode()
|
||||
: lon(std::numeric_limits<int>::max()), lat(std::numeric_limits<int>::max()),
|
||||
: lon{std::numeric_limits<value_type>::max()}, lat{std::numeric_limits<value_type>::max()},
|
||||
node_id(SPECIAL_OSM_NODEID)
|
||||
{
|
||||
}
|
||||
@@ -35,15 +36,15 @@ struct QueryNode
|
||||
|
||||
static QueryNode min_value()
|
||||
{
|
||||
return QueryNode(util::FixedLongitude(-180 * COORDINATE_PRECISION),
|
||||
util::FixedLatitude(-90 * COORDINATE_PRECISION),
|
||||
return QueryNode(util::FixedLongitude{static_cast<value_type>(-180 * COORDINATE_PRECISION)},
|
||||
util::FixedLatitude{static_cast<value_type>(-90 * COORDINATE_PRECISION)},
|
||||
MIN_OSM_NODEID);
|
||||
}
|
||||
|
||||
static QueryNode max_value()
|
||||
{
|
||||
return QueryNode(util::FixedLongitude(180 * COORDINATE_PRECISION),
|
||||
util::FixedLatitude(90 * COORDINATE_PRECISION),
|
||||
return QueryNode(util::FixedLongitude{static_cast<value_type>(180 * COORDINATE_PRECISION)},
|
||||
util::FixedLatitude{static_cast<value_type>(90 * COORDINATE_PRECISION)},
|
||||
MAX_OSM_NODEID);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user