Address PR comments

This commit is contained in:
Patrick Niklaus 2017-03-09 22:44:56 +00:00 committed by Patrick Niklaus
parent 4986f5ea2d
commit 94e2a8598d
6 changed files with 49 additions and 45 deletions

View File

@ -60,7 +60,7 @@ class CompressedEdgeContainer
NodeID GetLastEdgeSourceID(const EdgeID edge_id) const;
// Invalidates the internal storage
SegmentDataContainer ToSegmentData();
std::unique_ptr<SegmentDataContainer> ToSegmentData();
private:
int free_list_maximum = 0;
@ -71,7 +71,7 @@ class CompressedEdgeContainer
std::unordered_map<EdgeID, unsigned> m_edge_id_to_list_index_map;
std::unordered_map<EdgeID, unsigned> m_forward_edge_id_to_zipped_index_map;
std::unordered_map<EdgeID, unsigned> m_reverse_edge_id_to_zipped_index_map;
SegmentDataContainer segment_data;
std::unique_ptr<SegmentDataContainer> segment_data;
};
}
}

View File

@ -14,7 +14,7 @@ namespace updater
class Updater
{
public:
Updater(const UpdaterConfig &config) :config(config) {}
Updater(UpdaterConfig config_) :config(std::move(config_)) {}
EdgeID LoadAndUpdateEdgeExpandedGraph(
std::vector<extractor::EdgeBasedEdge> &edge_based_edge_list,

View File

@ -61,7 +61,7 @@ unsigned CompressedEdgeContainer::GetZippedPositionForForwardID(const EdgeID edg
{
auto map_iterator = m_forward_edge_id_to_zipped_index_map.find(edge_id);
BOOST_ASSERT(map_iterator != m_forward_edge_id_to_zipped_index_map.end());
BOOST_ASSERT(map_iterator->second < segment_data.nodes.size());
BOOST_ASSERT(map_iterator->second < segment_data->nodes.size());
return map_iterator->second;
}
@ -69,7 +69,7 @@ unsigned CompressedEdgeContainer::GetZippedPositionForReverseID(const EdgeID edg
{
auto map_iterator = m_reverse_edge_id_to_zipped_index_map.find(edge_id);
BOOST_ASSERT(map_iterator != m_reverse_edge_id_to_zipped_index_map.end());
BOOST_ASSERT(map_iterator->second < segment_data.nodes.size());
BOOST_ASSERT(map_iterator->second < segment_data->nodes.size());
return map_iterator->second;
}
@ -214,12 +214,13 @@ void CompressedEdgeContainer::AddUncompressedEdge(const EdgeID edge_id,
void CompressedEdgeContainer::InitializeBothwayVector()
{
segment_data.index.reserve(m_compressed_oneway_geometries.size());
segment_data.nodes.reserve(m_compressed_oneway_geometries.size());
segment_data.fwd_weights.reserve(m_compressed_oneway_geometries.size());
segment_data.rev_weights.reserve(m_compressed_oneway_geometries.size());
segment_data.fwd_durations.reserve(m_compressed_oneway_geometries.size());
segment_data.rev_durations.reserve(m_compressed_oneway_geometries.size());
segment_data = std::make_unique<SegmentDataContainer>();
segment_data->index.reserve(m_compressed_oneway_geometries.size());
segment_data->nodes.reserve(m_compressed_oneway_geometries.size());
segment_data->fwd_weights.reserve(m_compressed_oneway_geometries.size());
segment_data->rev_weights.reserve(m_compressed_oneway_geometries.size());
segment_data->fwd_durations.reserve(m_compressed_oneway_geometries.size());
segment_data->rev_durations.reserve(m_compressed_oneway_geometries.size());
}
unsigned CompressedEdgeContainer::ZipEdges(const EdgeID f_edge_id, const EdgeID r_edge_id)
@ -229,19 +230,19 @@ unsigned CompressedEdgeContainer::ZipEdges(const EdgeID f_edge_id, const EdgeID
BOOST_ASSERT(forward_bucket.size() == reverse_bucket.size());
const unsigned zipped_geometry_id = segment_data.index.size();
const unsigned zipped_geometry_id = segment_data->index.size();
m_forward_edge_id_to_zipped_index_map[f_edge_id] = zipped_geometry_id;
m_reverse_edge_id_to_zipped_index_map[r_edge_id] = zipped_geometry_id;
segment_data.index.emplace_back(segment_data.nodes.size());
segment_data->index.emplace_back(segment_data->nodes.size());
const auto &first_node = reverse_bucket.back();
segment_data.nodes.emplace_back(first_node.node_id);
segment_data.fwd_weights.emplace_back(INVALID_EDGE_WEIGHT);
segment_data.rev_weights.emplace_back(first_node.weight);
segment_data.fwd_durations.emplace_back(INVALID_EDGE_WEIGHT);
segment_data.rev_durations.emplace_back(first_node.duration);
segment_data->nodes.emplace_back(first_node.node_id);
segment_data->fwd_weights.emplace_back(INVALID_EDGE_WEIGHT);
segment_data->rev_weights.emplace_back(first_node.weight);
segment_data->fwd_durations.emplace_back(INVALID_EDGE_WEIGHT);
segment_data->rev_durations.emplace_back(first_node.duration);
for (std::size_t i = 0; i < forward_bucket.size() - 1; ++i)
{
@ -250,20 +251,20 @@ unsigned CompressedEdgeContainer::ZipEdges(const EdgeID f_edge_id, const EdgeID
BOOST_ASSERT(fwd_node.node_id == rev_node.node_id);
segment_data.nodes.emplace_back(fwd_node.node_id);
segment_data.fwd_weights.emplace_back(fwd_node.weight);
segment_data.rev_weights.emplace_back(rev_node.weight);
segment_data.fwd_durations.emplace_back(fwd_node.duration);
segment_data.rev_durations.emplace_back(rev_node.duration);
segment_data->nodes.emplace_back(fwd_node.node_id);
segment_data->fwd_weights.emplace_back(fwd_node.weight);
segment_data->rev_weights.emplace_back(rev_node.weight);
segment_data->fwd_durations.emplace_back(fwd_node.duration);
segment_data->rev_durations.emplace_back(rev_node.duration);
}
const auto &last_node = forward_bucket.back();
segment_data.nodes.emplace_back(last_node.node_id);
segment_data.fwd_weights.emplace_back(last_node.weight);
segment_data.rev_weights.emplace_back(INVALID_EDGE_WEIGHT);
segment_data.fwd_durations.emplace_back(last_node.duration);
segment_data.rev_durations.emplace_back(INVALID_EDGE_WEIGHT);
segment_data->nodes.emplace_back(last_node.node_id);
segment_data->fwd_weights.emplace_back(last_node.weight);
segment_data->rev_weights.emplace_back(INVALID_EDGE_WEIGHT);
segment_data->fwd_durations.emplace_back(last_node.duration);
segment_data->rev_durations.emplace_back(INVALID_EDGE_WEIGHT);
return zipped_geometry_id;
}
@ -327,7 +328,7 @@ NodeID CompressedEdgeContainer::GetLastEdgeSourceID(const EdgeID edge_id) const
return bucket[bucket.size() - 2].node_id;
}
SegmentDataContainer CompressedEdgeContainer::ToSegmentData()
std::unique_ptr<SegmentDataContainer> CompressedEdgeContainer::ToSegmentData()
{
return std::move(segment_data);
}

View File

@ -514,7 +514,7 @@ Extractor::BuildEdgeExpandedGraph(ScriptingEnvironment &scripting_environment,
});
WriteTurnLaneData(config.turn_lane_descriptions_file_name);
io::write(config.geometry_output_path, compressed_edge_container.ToSegmentData());
io::write(config.geometry_output_path, *compressed_edge_container.ToSegmentData());
edge_based_graph_factory.GetEdgeBasedEdges(edge_based_edge_list);
edge_based_graph_factory.GetEdgeBasedNodes(node_based_edge_list);

View File

@ -43,8 +43,6 @@ StorageConfig::StorageConfig(const boost::filesystem::path &base)
bool StorageConfig::IsValid() const
{
const constexpr auto num_files = 15;
// Common files
if (!CheckFileList({ram_index_path,
file_index_path,

View File

@ -5,19 +5,21 @@
#include <boost/fusion/adapted/std_pair.hpp>
#include <boost/fusion/include/adapt_adt.hpp>
// clang-format off
BOOST_FUSION_ADAPT_STRUCT(osrm::updater::Segment,
(decltype(osrm::updater::Segment::from),
from)(decltype(osrm::updater::Segment::to), to))
(decltype(osrm::updater::Segment::from), from)
(decltype(osrm::updater::Segment::to), to))
BOOST_FUSION_ADAPT_STRUCT(osrm::updater::SpeedSource,
(decltype(osrm::updater::SpeedSource::speed),
speed)(decltype(osrm::updater::SpeedSource::weight), weight))
(decltype(osrm::updater::SpeedSource::speed), speed)
(decltype(osrm::updater::SpeedSource::weight), weight))
BOOST_FUSION_ADAPT_STRUCT(osrm::updater::Turn,
(decltype(osrm::updater::Turn::from),
from)(decltype(osrm::updater::Turn::via),
via)(decltype(osrm::updater::Turn::to), to))
(decltype(osrm::updater::Turn::from), from)
(decltype(osrm::updater::Turn::via), via)
(decltype(osrm::updater::Turn::to), to))
BOOST_FUSION_ADAPT_STRUCT(osrm::updater::PenaltySource,
(decltype(osrm::updater::PenaltySource::duration),
duration)(decltype(osrm::updater::PenaltySource::weight), weight))
(decltype(osrm::updater::PenaltySource::duration), duration)
(decltype(osrm::updater::PenaltySource::weight), weight))
// clang-format on
namespace
{
namespace qi = boost::spirit::qi;
@ -31,16 +33,19 @@ namespace csv
{
SegmentLookupTable readSegmentValues(const std::vector<std::string> &paths)
{
return CSVFilesParser<Segment, SpeedSource>(
1, qi::ulong_long >> ',' >> qi::ulong_long, qi::uint_ >> -(',' >> qi::double_))(paths);
CSVFilesParser<Segment, SpeedSource> parser(
1, qi::ulong_long >> ',' >> qi::ulong_long, qi::uint_ >> -(',' >> qi::double_));
return parser(paths);
}
TurnLookupTable readTurnValues(const std::vector<std::string> &paths)
{
return CSVFilesParser<Turn, PenaltySource>(1,
CSVFilesParser<Turn, PenaltySource> parser(1,
qi::ulong_long >> ',' >> qi::ulong_long >> ',' >>
qi::ulong_long,
qi::double_ >> -(',' >> qi::double_))(paths);
qi::double_ >> -(',' >> qi::double_));
return parser(paths);
}
}
}