Apply clang-format

This commit is contained in:
Patrick Niklaus 2017-03-09 22:45:27 +00:00 committed by Patrick Niklaus
parent 94e2a8598d
commit fb552fd751
11 changed files with 64 additions and 65 deletions

View File

@ -74,7 +74,6 @@ struct ContractorConfig
//(e.g. 0.8 contracts 80 percent of the hierarchy, leaving a core of 20%)
double core_factor;
};
}
}

View File

@ -8,10 +8,10 @@
#include "engine/algorithm.hpp"
#include "engine/geospatial_query.hpp"
#include "extractor/segment_data_container.hpp"
#include "extractor/guidance/turn_instruction.hpp"
#include "extractor/guidance/turn_lane_types.hpp"
#include "extractor/profile_properties.hpp"
#include "extractor/segment_data_container.hpp"
#include "partition/cell_storage.hpp"
#include "partition/multi_level_partition.hpp"
@ -574,41 +574,41 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
{
auto range = segment_data.GetForwardGeometry(id);
return std::vector<NodeID> {range.begin(), range.end()};
return std::vector<NodeID>{range.begin(), range.end()};
}
virtual std::vector<NodeID> GetUncompressedReverseGeometry(const EdgeID id) const override final
{
auto range = segment_data.GetReverseGeometry(id);
return std::vector<NodeID> {range.begin(), range.end()};
return std::vector<NodeID>{range.begin(), range.end()};
}
virtual std::vector<EdgeWeight>
GetUncompressedForwardDurations(const EdgeID id) const override final
{
auto range = segment_data.GetForwardDurations(id);
return std::vector<EdgeWeight> {range.begin(), range.end()};
return std::vector<EdgeWeight>{range.begin(), range.end()};
}
virtual std::vector<EdgeWeight>
GetUncompressedReverseDurations(const EdgeID id) const override final
{
auto range = segment_data.GetReverseDurations(id);
return std::vector<EdgeWeight> {range.begin(), range.end()};
return std::vector<EdgeWeight>{range.begin(), range.end()};
}
virtual std::vector<EdgeWeight>
GetUncompressedForwardWeights(const EdgeID id) const override final
{
auto range = segment_data.GetForwardWeights(id);
return std::vector<EdgeWeight> {range.begin(), range.end()};
return std::vector<EdgeWeight>{range.begin(), range.end()};
}
virtual std::vector<EdgeWeight>
GetUncompressedReverseWeights(const EdgeID id) const override final
{
auto range = segment_data.GetReverseWeights(id);
return std::vector<EdgeWeight> {range.begin(), range.end()};
return std::vector<EdgeWeight>{range.begin(), range.end()};
}
virtual GeometryID GetGeometryIndexForEdgeID(const EdgeID id) const override final

View File

@ -12,8 +12,7 @@ namespace extractor
namespace io
{
template <>
void read(const boost::filesystem::path &path, SegmentDataContainer &segment_data)
template <> void read(const boost::filesystem::path &path, SegmentDataContainer &segment_data)
{
const auto fingerprint = storage::io::FileReader::HasNoFingerprint;
storage::io::FileReader reader{path, fingerprint};
@ -36,7 +35,8 @@ void read(const boost::filesystem::path &path, SegmentDataContainer &segment_dat
reader.ReadInto(segment_data.rev_durations.data(), segment_data.rev_durations.size());
}
template <> void write(const boost::filesystem::path &path, const SegmentDataContainer &segment_data)
template <>
void write(const boost::filesystem::path &path, const SegmentDataContainer &segment_data)
{
const auto fingerprint = storage::io::FileWriter::HasNoFingerprint;
storage::io::FileWriter writer{path, fingerprint};
@ -54,7 +54,6 @@ template <> void write(const boost::filesystem::path &path, const SegmentDataCon
writer.WriteFrom(segment_data.fwd_durations.data(), segment_data.fwd_durations.size());
writer.WriteFrom(segment_data.rev_durations.data(), segment_data.rev_durations.size());
}
}
}
}

View File

@ -4,9 +4,9 @@
#include "util/shared_memory_vector_wrapper.hpp"
#include "util/typedefs.hpp"
#include <boost/filesystem/path.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/filesystem/path.hpp>
#include <unordered_map>
@ -28,9 +28,11 @@ template <bool UseShareMemory> class SegmentDataContainerImpl;
namespace io
{
template <bool UseShareMemory>
inline void read(const boost::filesystem::path &path, detail::SegmentDataContainerImpl<UseShareMemory> &segment_data);
inline void read(const boost::filesystem::path &path,
detail::SegmentDataContainerImpl<UseShareMemory> &segment_data);
template <bool UseShareMemory>
inline void write(const boost::filesystem::path &path, const detail::SegmentDataContainerImpl<UseShareMemory> &segment_data);
inline void write(const boost::filesystem::path &path,
const detail::SegmentDataContainerImpl<UseShareMemory> &segment_data);
}
namespace detail
@ -61,19 +63,19 @@ template <bool UseShareMemory> class SegmentDataContainerImpl
}
// TODO these random access functions can be removed after we implemented #3737
auto& ForwardDuration(const DirectionalGeometryID id, const SegmentOffset offset)
auto &ForwardDuration(const DirectionalGeometryID id, const SegmentOffset offset)
{
return fwd_durations[index[id] + 1 + offset];
}
auto& ReverseDuration(const DirectionalGeometryID id, const SegmentOffset offset)
auto &ReverseDuration(const DirectionalGeometryID id, const SegmentOffset offset)
{
return rev_durations[index[id] + offset];
}
auto& ForwardWeight(const DirectionalGeometryID id, const SegmentOffset offset)
auto &ForwardWeight(const DirectionalGeometryID id, const SegmentOffset offset)
{
return fwd_weights[index[id] + 1 + offset];
}
auto& ReverseWeight(const DirectionalGeometryID id, const SegmentOffset offset)
auto &ReverseWeight(const DirectionalGeometryID id, const SegmentOffset offset)
{
return rev_weights[index[id] + offset];
}
@ -129,15 +131,14 @@ template <bool UseShareMemory> class SegmentDataContainerImpl
return boost::adaptors::reverse(boost::make_iterator_range(begin, end));
}
auto GetNumberOfSegments() const
{
return fwd_weights.size();
}
auto GetNumberOfSegments() const { return fwd_weights.size(); }
friend void io::read<UseShareMemory>(const boost::filesystem::path &path,
detail::SegmentDataContainerImpl<UseShareMemory> &segment_data);
friend void io::write<UseShareMemory>(const boost::filesystem::path &path,
const detail::SegmentDataContainerImpl<UseShareMemory> &segment_data);
friend void
io::read<UseShareMemory>(const boost::filesystem::path &path,
detail::SegmentDataContainerImpl<UseShareMemory> &segment_data);
friend void
io::write<UseShareMemory>(const boost::filesystem::path &path,
const detail::SegmentDataContainerImpl<UseShareMemory> &segment_data);
private:
Vector<std::uint32_t> index;

View File

@ -3,9 +3,9 @@
#include "updater/source.hpp"
#include "util/log.hpp"
#include "util/exception.hpp"
#include "util/exception_utils.hpp"
#include "util/log.hpp"
#include <tbb/parallel_for.h>
#include <tbb/spin_mutex.h>
@ -51,16 +51,18 @@ template <typename Key, typename Value> struct CSVFilesParser
{
tbb::spin_mutex mutex;
std::vector<std::pair<Key, Value>> lookup;
tbb::parallel_for(std::size_t{0}, csv_filenames.size(), [&](const std::size_t idx) {
auto local = ParseCSVFile(csv_filenames[idx], start_index + idx);
tbb::parallel_for(std::size_t{0},
csv_filenames.size(),
[&](const std::size_t idx) {
auto local = ParseCSVFile(csv_filenames[idx], start_index + idx);
{ // Merge local CSV results into a flat global vector
tbb::spin_mutex::scoped_lock _{mutex};
lookup.insert(end(lookup),
std::make_move_iterator(begin(local)),
std::make_move_iterator(end(local)));
}
});
{ // Merge local CSV results into a flat global vector
tbb::spin_mutex::scoped_lock _{mutex};
lookup.insert(end(lookup),
std::make_move_iterator(begin(local)),
std::make_move_iterator(end(local)));
}
});
// With flattened map-ish view of all the files, make a stable sort on key and source
// and unique them on key to keep only the value with the largest file index
@ -78,8 +80,8 @@ template <typename Key, typename Value> struct CSVFilesParser
});
lookup.erase(it, end(lookup));
util::Log() << "In total loaded " << csv_filenames.size()
<< " file(s) with a total of " << lookup.size() << " unique values";
util::Log() << "In total loaded " << csv_filenames.size() << " file(s) with a total of "
<< lookup.size() << " unique values";
return LookupTable<Key, Value>{lookup};
}

View File

@ -9,11 +9,10 @@ namespace updater
{
namespace csv
{
SegmentLookupTable readSegmentValues(const std::vector<std::string> &paths);
TurnLookupTable readTurnValues(const std::vector<std::string> &paths);
SegmentLookupTable readSegmentValues(const std::vector<std::string> &paths);
TurnLookupTable readTurnValues(const std::vector<std::string> &paths);
}
}
}
#endif

View File

@ -63,7 +63,7 @@ struct Turn final
: from(from), via(via), to(to)
{
}
template<typename Other>
template <typename Other>
Turn(const Other &turn)
: from(static_cast<std::uint64_t>(turn.from_id)),
via(static_cast<std::uint64_t>(turn.via_id)), to(static_cast<std::uint64_t>(turn.to_id))
@ -89,7 +89,6 @@ struct PenaltySource final
using SegmentLookupTable = LookupTable<Segment, SpeedSource>;
using TurnLookupTable = LookupTable<Turn, PenaltySource>;
}
}

View File

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

View File

@ -332,6 +332,5 @@ std::unique_ptr<SegmentDataContainer> CompressedEdgeContainer::ToSegmentData()
{
return std::move(segment_data);
}
}
}

View File

@ -58,7 +58,8 @@ return_code parseArguments(int argc, char *argv[], contractor::ContractorConfig
->default_value(false),
"Use .level file to retain the contaction level for each node from the last run.")(
"edge-weight-updates-over-factor",
boost::program_options::value<double>(&contractor_config.updater_config.log_edge_updates_factor)
boost::program_options::value<double>(
&contractor_config.updater_config.log_edge_updates_factor)
->default_value(0.0),
"Use with `--segment-speed-file`. Provide an `x` factor, by which Extractor will log edge "
"weights updated by more than this factor");

View File

@ -4,8 +4,8 @@
#include "extractor/compressed_edge_container.hpp"
#include "extractor/edge_based_graph_factory.hpp"
#include "extractor/node_based_edge.hpp"
#include "extractor/io.hpp"
#include "extractor/node_based_edge.hpp"
#include "storage/io.hpp"
#include "util/exception.hpp"
@ -21,10 +21,10 @@
#include "util/typedefs.hpp"
#include <boost/assert.hpp>
#include <boost/interprocess/mapped_region.hpp>
#include <boost/interprocess/file_mapping.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/functional/hash.hpp>
#include <boost/interprocess/file_mapping.hpp>
#include <boost/interprocess/mapped_region.hpp>
#include <tbb/blocked_range.h>
#include <tbb/concurrent_unordered_map.h>
@ -53,13 +53,11 @@ template <typename T> inline bool is_aligned(const void *pointer)
} // anon ns
namespace osrm
{
namespace updater
{
// Returns duration in deci-seconds
inline EdgeWeight ConvertToDuration(double distance_in_meters, double speed_in_kmh)
{
@ -343,10 +341,8 @@ Updater::LoadAndUpdateEdgeExpandedGraph(std::vector<extractor::EdgeBasedEdge> &e
BOOST_ASSERT(u_index < nodes_range.size());
BOOST_ASSERT(v_index < nodes_range.size());
const extractor::QueryNode &u =
internal_to_external_node_map[nodes_range[u_index]];
const extractor::QueryNode &v =
internal_to_external_node_map[nodes_range[v_index]];
const extractor::QueryNode &u = internal_to_external_node_map[nodes_range[u_index]];
const extractor::QueryNode &v = internal_to_external_node_map[nodes_range[v_index]];
const double segment_length = util::coordinate_calculation::greatCircleDistance(
util::Coordinate{u.lon, u.lat}, util::Coordinate{v.lon, v.lat});
@ -366,8 +362,10 @@ Updater::LoadAndUpdateEdgeExpandedGraph(std::vector<extractor::EdgeBasedEdge> &e
new_segment_duration);
segment_data.ForwardWeight(geometry_id, segment_offset) = new_segment_weight;
segment_data.ForwardDuration(geometry_id, segment_offset) = new_segment_duration;
geometry_datasource[segment_data.GetOffset(geometry_id, segment_offset)+1] = value->source;
segment_data.ForwardDuration(geometry_id, segment_offset) =
new_segment_duration;
geometry_datasource[segment_data.GetOffset(geometry_id, segment_offset) + 1] =
value->source;
fwd_source = value->source;
}
@ -385,8 +383,10 @@ Updater::LoadAndUpdateEdgeExpandedGraph(std::vector<extractor::EdgeBasedEdge> &e
new_segment_duration);
segment_data.ReverseWeight(geometry_id, segment_offset) = new_segment_weight;
segment_data.ReverseDuration(geometry_id, segment_offset) = new_segment_duration;
geometry_datasource[segment_data.GetOffset(geometry_id, segment_offset)] = value->source;
segment_data.ReverseDuration(geometry_id, segment_offset) =
new_segment_duration;
geometry_datasource[segment_data.GetOffset(geometry_id, segment_offset)] =
value->source;
rev_source = value->source;
}