Use 16bit for SegmentWeight and SegmentDuration
This commit is contained in:
committed by
Patrick Niklaus
parent
5c4f96e4bc
commit
d6c6a262d8
@@ -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);
|
||||
|
||||
+14
-14
@@ -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]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user