Use 16bit for SegmentWeight and SegmentDuration
This commit is contained in:
parent
5c4f96e4bc
commit
d6c6a262d8
@ -431,27 +431,27 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
||||
geometries_node_list_ptr,
|
||||
data_layout.num_entries[storage::DataLayout::GEOMETRIES_NODE_LIST]);
|
||||
|
||||
auto geometries_fwd_weight_list_ptr = data_layout.GetBlockPtr<EdgeWeight>(
|
||||
auto geometries_fwd_weight_list_ptr = data_layout.GetBlockPtr<SegmentWeight>(
|
||||
memory_block, storage::DataLayout::GEOMETRIES_FWD_WEIGHT_LIST);
|
||||
util::vector_view<EdgeWeight> geometry_fwd_weight_list(
|
||||
util::vector_view<SegmentWeight> geometry_fwd_weight_list(
|
||||
geometries_fwd_weight_list_ptr,
|
||||
data_layout.num_entries[storage::DataLayout::GEOMETRIES_FWD_WEIGHT_LIST]);
|
||||
|
||||
auto geometries_rev_weight_list_ptr = data_layout.GetBlockPtr<EdgeWeight>(
|
||||
auto geometries_rev_weight_list_ptr = data_layout.GetBlockPtr<SegmentWeight>(
|
||||
memory_block, storage::DataLayout::GEOMETRIES_REV_WEIGHT_LIST);
|
||||
util::vector_view<EdgeWeight> geometry_rev_weight_list(
|
||||
util::vector_view<SegmentWeight> geometry_rev_weight_list(
|
||||
geometries_rev_weight_list_ptr,
|
||||
data_layout.num_entries[storage::DataLayout::GEOMETRIES_REV_WEIGHT_LIST]);
|
||||
|
||||
auto geometries_fwd_duration_list_ptr = data_layout.GetBlockPtr<EdgeWeight>(
|
||||
auto geometries_fwd_duration_list_ptr = data_layout.GetBlockPtr<SegmentDuration>(
|
||||
memory_block, storage::DataLayout::GEOMETRIES_FWD_DURATION_LIST);
|
||||
util::vector_view<EdgeWeight> geometry_fwd_duration_list(
|
||||
util::vector_view<SegmentDuration> geometry_fwd_duration_list(
|
||||
geometries_fwd_duration_list_ptr,
|
||||
data_layout.num_entries[storage::DataLayout::GEOMETRIES_FWD_DURATION_LIST]);
|
||||
|
||||
auto geometries_rev_duration_list_ptr = data_layout.GetBlockPtr<EdgeWeight>(
|
||||
auto geometries_rev_duration_list_ptr = data_layout.GetBlockPtr<SegmentDuration>(
|
||||
memory_block, storage::DataLayout::GEOMETRIES_REV_DURATION_LIST);
|
||||
util::vector_view<EdgeWeight> geometry_rev_duration_list(
|
||||
util::vector_view<SegmentDuration> geometry_rev_duration_list(
|
||||
geometries_rev_duration_list_ptr,
|
||||
data_layout.num_entries[storage::DataLayout::GEOMETRIES_REV_DURATION_LIST]);
|
||||
|
||||
|
@ -371,8 +371,8 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
|
||||
EdgeWeight forward_weight_offset = 0, forward_weight = 0;
|
||||
EdgeWeight reverse_weight_offset = 0, reverse_weight = 0;
|
||||
EdgeWeight forward_duration_offset = 0, forward_duration = 0;
|
||||
EdgeWeight reverse_duration_offset = 0, reverse_duration = 0;
|
||||
EdgeDuration forward_duration_offset = 0, forward_duration = 0;
|
||||
EdgeDuration reverse_duration_offset = 0, reverse_duration = 0;
|
||||
|
||||
const std::vector<EdgeWeight> forward_weight_vector =
|
||||
datafacade.GetUncompressedForwardWeights(data.packed_geometry_id);
|
||||
@ -408,12 +408,12 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
if (data.forward_segment_id.id != SPECIAL_SEGMENTID)
|
||||
{
|
||||
forward_weight = static_cast<EdgeWeight>(forward_weight * ratio);
|
||||
forward_duration = static_cast<EdgeWeight>(forward_duration * ratio);
|
||||
forward_duration = static_cast<EdgeDuration>(forward_duration * ratio);
|
||||
}
|
||||
if (data.reverse_segment_id.id != SPECIAL_SEGMENTID)
|
||||
{
|
||||
reverse_weight -= static_cast<EdgeWeight>(reverse_weight * ratio);
|
||||
reverse_duration -= static_cast<EdgeWeight>(reverse_duration * ratio);
|
||||
reverse_duration -= static_cast<EdgeDuration>(reverse_duration * ratio);
|
||||
}
|
||||
|
||||
auto transformed = PhantomNodeWithDistance{PhantomNode{data,
|
||||
|
@ -22,8 +22,8 @@ class CompressedEdgeContainer
|
||||
{
|
||||
public:
|
||||
NodeID node_id; // refers to an internal node-based-node
|
||||
EdgeWeight weight; // the weight of the edge leading to this node
|
||||
EdgeWeight duration; // the duration of the edge leading to this node
|
||||
SegmentWeight weight; // the weight of the edge leading to this node
|
||||
SegmentDuration duration; // the duration of the edge leading to this node
|
||||
};
|
||||
|
||||
using OnewayEdgeBucket = std::vector<OnewayCompressedEdge>;
|
||||
@ -35,13 +35,13 @@ class CompressedEdgeContainer
|
||||
const NodeID target_node,
|
||||
const EdgeWeight weight1,
|
||||
const EdgeWeight weight2,
|
||||
const EdgeWeight duration1,
|
||||
const EdgeWeight duration2);
|
||||
const EdgeDuration duration1,
|
||||
const EdgeDuration duration2);
|
||||
|
||||
void AddUncompressedEdge(const EdgeID edge_id,
|
||||
const NodeID target_node,
|
||||
const EdgeWeight weight,
|
||||
const EdgeWeight duration);
|
||||
const SegmentWeight weight,
|
||||
const SegmentWeight duration);
|
||||
|
||||
void InitializeBothwayVector();
|
||||
unsigned ZipEdges(const unsigned f_edge_pos, const unsigned r_edge_pos);
|
||||
|
@ -19,7 +19,7 @@ struct NodeBasedEdge
|
||||
NodeID target,
|
||||
NodeID name_id,
|
||||
EdgeWeight weight,
|
||||
EdgeWeight duration,
|
||||
EdgeDuration duration,
|
||||
bool forward,
|
||||
bool backward,
|
||||
bool roundabout,
|
||||
@ -37,7 +37,7 @@ struct NodeBasedEdge
|
||||
NodeID target; // 32 4
|
||||
NodeID name_id; // 32 4
|
||||
EdgeWeight weight; // 32 4
|
||||
EdgeWeight duration; // 32 4
|
||||
EdgeDuration duration; // 32 4
|
||||
std::uint8_t forward : 1; // 1
|
||||
std::uint8_t backward : 1; // 1
|
||||
std::uint8_t roundabout : 1; // 1
|
||||
@ -56,7 +56,7 @@ struct NodeBasedEdgeWithOSM : NodeBasedEdge
|
||||
OSMNodeID target,
|
||||
NodeID name_id,
|
||||
EdgeWeight weight,
|
||||
EdgeWeight duration,
|
||||
EdgeDuration duration,
|
||||
bool forward,
|
||||
bool backward,
|
||||
bool roundabout,
|
||||
@ -86,7 +86,7 @@ inline NodeBasedEdge::NodeBasedEdge(NodeID source,
|
||||
NodeID target,
|
||||
NodeID name_id,
|
||||
EdgeWeight weight,
|
||||
EdgeWeight duration,
|
||||
EdgeDuration duration,
|
||||
bool forward,
|
||||
bool backward,
|
||||
bool roundabout,
|
||||
@ -125,7 +125,7 @@ inline NodeBasedEdgeWithOSM::NodeBasedEdgeWithOSM(OSMNodeID source,
|
||||
OSMNodeID target,
|
||||
NodeID name_id,
|
||||
EdgeWeight weight,
|
||||
EdgeWeight duration,
|
||||
EdgeDuration duration,
|
||||
bool forward,
|
||||
bool backward,
|
||||
bool roundabout,
|
||||
|
@ -55,10 +55,10 @@ template <storage::Ownership Ownership> class SegmentDataContainerImpl
|
||||
|
||||
SegmentDataContainerImpl(Vector<std::uint32_t> index_,
|
||||
Vector<NodeID> nodes_,
|
||||
Vector<EdgeWeight> fwd_weights_,
|
||||
Vector<EdgeWeight> rev_weights_,
|
||||
Vector<EdgeWeight> fwd_durations_,
|
||||
Vector<EdgeWeight> rev_durations_,
|
||||
Vector<SegmentWeight> fwd_weights_,
|
||||
Vector<SegmentWeight> rev_weights_,
|
||||
Vector<SegmentDuration> fwd_durations_,
|
||||
Vector<SegmentDuration> rev_durations_,
|
||||
Vector<DatasourceID> datasources_)
|
||||
: index(std::move(index_)), nodes(std::move(nodes_)), fwd_weights(std::move(fwd_weights_)),
|
||||
rev_weights(std::move(rev_weights_)), fwd_durations(std::move(fwd_durations_)),
|
||||
@ -201,10 +201,10 @@ template <storage::Ownership Ownership> class SegmentDataContainerImpl
|
||||
private:
|
||||
Vector<std::uint32_t> index;
|
||||
Vector<NodeID> nodes;
|
||||
Vector<EdgeWeight> fwd_weights;
|
||||
Vector<EdgeWeight> rev_weights;
|
||||
Vector<EdgeWeight> fwd_durations;
|
||||
Vector<EdgeWeight> rev_durations;
|
||||
Vector<SegmentWeight> fwd_weights;
|
||||
Vector<SegmentWeight> rev_weights;
|
||||
Vector<SegmentDuration> fwd_durations;
|
||||
Vector<SegmentDuration> rev_durations;
|
||||
Vector<DatasourceID> datasources;
|
||||
};
|
||||
}
|
||||
|
@ -58,6 +58,9 @@ using NodeID = std::uint32_t;
|
||||
using EdgeID = std::uint32_t;
|
||||
using NameID = std::uint32_t;
|
||||
using EdgeWeight = std::int32_t;
|
||||
using EdgeDuration = std::int32_t;
|
||||
using SegmentWeight = std::uint16_t;
|
||||
using SegmentDuration = std::uint16_t;
|
||||
using TurnPenalty = std::int16_t; // turn penalty in 100ms units
|
||||
|
||||
static const std::size_t INVALID_INDEX = std::numeric_limits<std::size_t>::max();
|
||||
@ -85,8 +88,10 @@ static const EdgeID SPECIAL_EDGEID = std::numeric_limits<EdgeID>::max();
|
||||
static const NameID INVALID_NAMEID = std::numeric_limits<NameID>::max();
|
||||
static const NameID EMPTY_NAMEID = 0;
|
||||
static const unsigned INVALID_COMPONENTID = 0;
|
||||
static const SegmentWeight INVALID_SEGMENT_WEIGHT = std::numeric_limits<SegmentWeight>::max();
|
||||
static const SegmentDuration INVALID_SEGMENT_DURATION = std::numeric_limits<SegmentDuration>::max();
|
||||
static const EdgeWeight INVALID_EDGE_WEIGHT = std::numeric_limits<EdgeWeight>::max();
|
||||
static const EdgeWeight MAXIMAL_EDGE_DURATION = std::numeric_limits<EdgeWeight>::max();
|
||||
static const EdgeDuration MAXIMAL_EDGE_DURATION = std::numeric_limits<EdgeDuration>::max();
|
||||
static const TurnPenalty INVALID_TURN_PENALTY = std::numeric_limits<TurnPenalty>::max();
|
||||
|
||||
// FIXME the bitfields we use require a reduced maximal duration, this should be kept consistent
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#include <boost/numeric/conversion/cast.hpp>
|
||||
|
||||
#include <limits>
|
||||
#include <string>
|
||||
@ -88,16 +89,16 @@ void CompressedEdgeContainer::CompressEdge(const EdgeID edge_id_1,
|
||||
const NodeID target_node_id,
|
||||
const EdgeWeight weight1,
|
||||
const EdgeWeight weight2,
|
||||
const EdgeWeight duration1,
|
||||
const EdgeWeight duration2)
|
||||
const EdgeDuration duration1,
|
||||
const EdgeDuration duration2)
|
||||
{
|
||||
// remove super-trivial geometries
|
||||
BOOST_ASSERT(SPECIAL_EDGEID != edge_id_1);
|
||||
BOOST_ASSERT(SPECIAL_EDGEID != edge_id_2);
|
||||
BOOST_ASSERT(SPECIAL_NODEID != via_node_id);
|
||||
BOOST_ASSERT(SPECIAL_NODEID != target_node_id);
|
||||
BOOST_ASSERT(INVALID_EDGE_WEIGHT != weight1);
|
||||
BOOST_ASSERT(INVALID_EDGE_WEIGHT != weight2);
|
||||
BOOST_ASSERT(INVALID_SEGMENT_WEIGHT != weight1);
|
||||
BOOST_ASSERT(INVALID_SEGMENT_WEIGHT != weight2);
|
||||
|
||||
// append list of removed edge_id plus via node to surviving edge id:
|
||||
// <surv_1, .. , surv_n, via_node_id, rem_1, .. rem_n
|
||||
@ -134,7 +135,10 @@ void CompressedEdgeContainer::CompressEdge(const EdgeID edge_id_1,
|
||||
// weight1 is the distance to the (currently) last coordinate in the bucket
|
||||
if (edge_bucket_list1.empty())
|
||||
{
|
||||
edge_bucket_list1.emplace_back(OnewayCompressedEdge{via_node_id, weight1, duration1});
|
||||
edge_bucket_list1.emplace_back(
|
||||
OnewayCompressedEdge{via_node_id,
|
||||
boost::numeric_cast<SegmentWeight>(weight1),
|
||||
boost::numeric_cast<SegmentDuration>(duration1)});
|
||||
}
|
||||
|
||||
BOOST_ASSERT(0 < edge_bucket_list1.size());
|
||||
@ -165,14 +169,17 @@ void CompressedEdgeContainer::CompressEdge(const EdgeID edge_id_1,
|
||||
else
|
||||
{
|
||||
// we are certain that the second edge is atomic.
|
||||
edge_bucket_list1.emplace_back(OnewayCompressedEdge{target_node_id, weight2, duration2});
|
||||
edge_bucket_list1.emplace_back(
|
||||
OnewayCompressedEdge{target_node_id,
|
||||
boost::numeric_cast<SegmentWeight>(weight2),
|
||||
boost::numeric_cast<SegmentDuration>(duration2)});
|
||||
}
|
||||
}
|
||||
|
||||
void CompressedEdgeContainer::AddUncompressedEdge(const EdgeID edge_id,
|
||||
const NodeID target_node_id,
|
||||
const EdgeWeight weight,
|
||||
const EdgeWeight duration)
|
||||
const SegmentWeight weight,
|
||||
const SegmentDuration duration)
|
||||
{
|
||||
// remove super-trivial geometries
|
||||
BOOST_ASSERT(SPECIAL_EDGEID != edge_id);
|
||||
|
@ -120,18 +120,18 @@ void GraphCompressor::Compress(const std::unordered_set<NodeID> &barrier_nodes,
|
||||
continue;
|
||||
|
||||
// Get weights before graph is modified
|
||||
const EdgeWeight forward_weight1 = fwd_edge_data1.weight;
|
||||
const EdgeWeight forward_weight2 = fwd_edge_data2.weight;
|
||||
const EdgeWeight forward_duration1 = fwd_edge_data1.duration;
|
||||
const EdgeWeight forward_duration2 = fwd_edge_data2.duration;
|
||||
const auto forward_weight1 = fwd_edge_data1.weight;
|
||||
const auto forward_weight2 = fwd_edge_data2.weight;
|
||||
const auto forward_duration1 = fwd_edge_data1.duration;
|
||||
const auto forward_duration2 = fwd_edge_data2.duration;
|
||||
|
||||
BOOST_ASSERT(0 != forward_weight1);
|
||||
BOOST_ASSERT(0 != forward_weight2);
|
||||
|
||||
const EdgeWeight reverse_weight1 = rev_edge_data1.weight;
|
||||
const EdgeWeight reverse_weight2 = rev_edge_data2.weight;
|
||||
const EdgeWeight reverse_duration1 = rev_edge_data1.duration;
|
||||
const EdgeWeight reverse_duration2 = rev_edge_data2.duration;
|
||||
const auto reverse_weight1 = rev_edge_data1.weight;
|
||||
const auto reverse_weight2 = rev_edge_data2.weight;
|
||||
const auto reverse_duration1 = rev_edge_data1.duration;
|
||||
const auto reverse_duration2 = rev_edge_data2.duration;
|
||||
|
||||
BOOST_ASSERT(0 != reverse_weight1);
|
||||
BOOST_ASSERT(0 != reverse_weight2);
|
||||
|
@ -340,13 +340,13 @@ void Storage::PopulateLayout(DataLayout &layout)
|
||||
const auto number_of_compressed_geometries = reader.ReadVectorSize<NodeID>();
|
||||
layout.SetBlockSize<NodeID>(DataLayout::GEOMETRIES_NODE_LIST,
|
||||
number_of_compressed_geometries);
|
||||
layout.SetBlockSize<EdgeWeight>(DataLayout::GEOMETRIES_FWD_WEIGHT_LIST,
|
||||
layout.SetBlockSize<SegmentWeight>(DataLayout::GEOMETRIES_FWD_WEIGHT_LIST,
|
||||
number_of_compressed_geometries);
|
||||
layout.SetBlockSize<SegmentWeight>(DataLayout::GEOMETRIES_REV_WEIGHT_LIST,
|
||||
number_of_compressed_geometries);
|
||||
layout.SetBlockSize<EdgeWeight>(DataLayout::GEOMETRIES_REV_WEIGHT_LIST,
|
||||
number_of_compressed_geometries);
|
||||
layout.SetBlockSize<EdgeWeight>(DataLayout::GEOMETRIES_FWD_DURATION_LIST,
|
||||
number_of_compressed_geometries);
|
||||
layout.SetBlockSize<EdgeWeight>(DataLayout::GEOMETRIES_REV_DURATION_LIST,
|
||||
layout.SetBlockSize<SegmentDuration>(DataLayout::GEOMETRIES_FWD_DURATION_LIST,
|
||||
number_of_compressed_geometries);
|
||||
layout.SetBlockSize<SegmentDuration>(DataLayout::GEOMETRIES_REV_DURATION_LIST,
|
||||
number_of_compressed_geometries);
|
||||
layout.SetBlockSize<DatasourceID>(DataLayout::DATASOURCES_LIST,
|
||||
number_of_compressed_geometries);
|
||||
@ -641,27 +641,27 @@ void Storage::PopulateData(const DataLayout &layout, char *memory_ptr)
|
||||
geometries_node_list_ptr,
|
||||
layout.num_entries[storage::DataLayout::GEOMETRIES_NODE_LIST]);
|
||||
|
||||
auto geometries_fwd_weight_list_ptr = layout.GetBlockPtr<EdgeWeight, true>(
|
||||
auto geometries_fwd_weight_list_ptr = layout.GetBlockPtr<SegmentWeight, true>(
|
||||
memory_ptr, storage::DataLayout::GEOMETRIES_FWD_WEIGHT_LIST);
|
||||
util::vector_view<EdgeWeight> geometry_fwd_weight_list(
|
||||
util::vector_view<SegmentWeight> geometry_fwd_weight_list(
|
||||
geometries_fwd_weight_list_ptr,
|
||||
layout.num_entries[storage::DataLayout::GEOMETRIES_FWD_WEIGHT_LIST]);
|
||||
|
||||
auto geometries_rev_weight_list_ptr = layout.GetBlockPtr<EdgeWeight, true>(
|
||||
auto geometries_rev_weight_list_ptr = layout.GetBlockPtr<SegmentWeight, true>(
|
||||
memory_ptr, storage::DataLayout::GEOMETRIES_REV_WEIGHT_LIST);
|
||||
util::vector_view<EdgeWeight> geometry_rev_weight_list(
|
||||
util::vector_view<SegmentWeight> geometry_rev_weight_list(
|
||||
geometries_rev_weight_list_ptr,
|
||||
layout.num_entries[storage::DataLayout::GEOMETRIES_REV_WEIGHT_LIST]);
|
||||
|
||||
auto geometries_fwd_duration_list_ptr = layout.GetBlockPtr<EdgeWeight, true>(
|
||||
auto geometries_fwd_duration_list_ptr = layout.GetBlockPtr<SegmentDuration, true>(
|
||||
memory_ptr, storage::DataLayout::GEOMETRIES_FWD_DURATION_LIST);
|
||||
util::vector_view<EdgeWeight> geometry_fwd_duration_list(
|
||||
util::vector_view<SegmentDuration> geometry_fwd_duration_list(
|
||||
geometries_fwd_duration_list_ptr,
|
||||
layout.num_entries[storage::DataLayout::GEOMETRIES_FWD_DURATION_LIST]);
|
||||
|
||||
auto geometries_rev_duration_list_ptr = layout.GetBlockPtr<EdgeWeight, true>(
|
||||
auto geometries_rev_duration_list_ptr = layout.GetBlockPtr<SegmentDuration, true>(
|
||||
memory_ptr, storage::DataLayout::GEOMETRIES_REV_DURATION_LIST);
|
||||
util::vector_view<EdgeWeight> geometry_rev_duration_list(
|
||||
util::vector_view<SegmentDuration> geometry_rev_duration_list(
|
||||
geometries_rev_duration_list_ptr,
|
||||
layout.num_entries[storage::DataLayout::GEOMETRIES_REV_DURATION_LIST]);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user