From 81a4747acbb2645b517a5e992eefd8a52a7d6e68 Mon Sep 17 00:00:00 2001 From: Patrick Niklaus Date: Wed, 28 Mar 2018 23:18:28 +0000 Subject: [PATCH] Fix formating --- include/contractor/contracted_metric.hpp | 3 +- include/contractor/files.hpp | 1 - include/customizer/files.hpp | 20 ++++--- .../contiguous_internalmem_datafacade.hpp | 59 +++++++++++-------- include/storage/io.hpp | 13 ++-- include/storage/serialization.hpp | 21 ++----- include/storage/shared_datatype.hpp | 5 +- .../datafacade/shared_memory_allocator.cpp | 8 +-- src/storage/storage.cpp | 3 +- unit_tests/contractor/files.cpp | 4 +- unit_tests/storage/data_layout.cpp | 12 +++- unit_tests/storage/serialization.cpp | 12 ++-- 12 files changed, 80 insertions(+), 81 deletions(-) diff --git a/include/contractor/contracted_metric.hpp b/include/contractor/contracted_metric.hpp index e8592b32a..f44f49e83 100644 --- a/include/contractor/contracted_metric.hpp +++ b/include/contractor/contracted_metric.hpp @@ -10,8 +10,7 @@ namespace contractor namespace detail { -template -struct ContractedMetric +template struct ContractedMetric { detail::QueryGraph graph; std::vector> edge_filter; diff --git a/include/contractor/files.hpp b/include/contractor/files.hpp index 7ba994423..8dcade795 100644 --- a/include/contractor/files.hpp +++ b/include/contractor/files.hpp @@ -30,7 +30,6 @@ inline void readGraph(const boost::filesystem::path &path, { serialization::read(reader, "/ch/metrics/" + pair.first, pair.second); } - } // writes .osrm.hsgr file diff --git a/include/customizer/files.hpp b/include/customizer/files.hpp index 8b690ecd2..c89b5cb76 100644 --- a/include/customizer/files.hpp +++ b/include/customizer/files.hpp @@ -18,7 +18,8 @@ namespace files // reads .osrm.cell_metrics file template -inline void readCellMetrics(const boost::filesystem::path &path, std::unordered_map> &metrics) +inline void readCellMetrics(const boost::filesystem::path &path, + std::unordered_map> &metrics) { static_assert(std::is_same::value || std::is_same::value, @@ -27,10 +28,10 @@ inline void readCellMetrics(const boost::filesystem::path &path, std::unordered_ const auto fingerprint = storage::tar::FileReader::VerifyFingerprint; storage::tar::FileReader reader{path, fingerprint}; - for (auto& pair : metrics) + for (auto &pair : metrics) { - const auto& metric_name = pair.first; - auto& metric_exclude_classes = pair.second; + const auto &metric_name = pair.first; + auto &metric_exclude_classes = pair.second; auto prefix = "/mld/metrics/" + metric_name + "/exclude"; auto num_exclude_classes = reader.ReadElementCount64(prefix); @@ -46,8 +47,9 @@ inline void readCellMetrics(const boost::filesystem::path &path, std::unordered_ // writes .osrm.cell_metrics file template -inline void writeCellMetrics(const boost::filesystem::path &path, - const std::unordered_map> &metrics) +inline void +writeCellMetrics(const boost::filesystem::path &path, + const std::unordered_map> &metrics) { static_assert(std::is_same::value || std::is_same::value, @@ -56,10 +58,10 @@ inline void writeCellMetrics(const boost::filesystem::path &path, const auto fingerprint = storage::tar::FileWriter::GenerateFingerprint; storage::tar::FileWriter writer{path, fingerprint}; - for (const auto& pair : metrics) + for (const auto &pair : metrics) { - const auto& metric_name = pair.first; - const auto& metric_exclude_classes = pair.second; + const auto &metric_name = pair.first; + const auto &metric_exclude_classes = pair.second; auto prefix = "/mld/metrics/" + metric_name + "/exclude"; writer.WriteElementCount64(prefix, metric_exclude_classes.size()); diff --git a/include/engine/datafacade/contiguous_internalmem_datafacade.hpp b/include/engine/datafacade/contiguous_internalmem_datafacade.hpp index 79ec5f36b..ec3a4491b 100644 --- a/include/engine/datafacade/contiguous_internalmem_datafacade.hpp +++ b/include/engine/datafacade/contiguous_internalmem_datafacade.hpp @@ -83,15 +83,15 @@ class ContiguousInternalMemoryAlgorithmDataFacade : public datafacade::Algor void InitializeGraphPointer(const storage::DataLayout &data_layout, char *memory_block, - const std::string& metric_name, + const std::string &metric_name, const std::size_t exclude_index) { const std::string metric_prefix = "/ch/metrics/" + metric_name; - auto graph_nodes_ptr = - data_layout.GetBlockPtr(memory_block, metric_prefix + "/contracted_graph/node_array"); + auto graph_nodes_ptr = data_layout.GetBlockPtr( + memory_block, metric_prefix + "/contracted_graph/node_array"); - auto graph_edges_ptr = - data_layout.GetBlockPtr(memory_block, metric_prefix + "/contracted_graph/edge_array"); + auto graph_edges_ptr = data_layout.GetBlockPtr( + memory_block, metric_prefix + "/contracted_graph/edge_array"); auto exclude_prefix = metric_prefix + "/exclude/" + std::to_string(exclude_index); auto filter_block_id = exclude_prefix + "/edge_filter"; @@ -100,9 +100,11 @@ class ContiguousInternalMemoryAlgorithmDataFacade : public datafacade::Algor data_layout.GetBlockPtr::Word>(memory_block, filter_block_id); util::vector_view node_list( - graph_nodes_ptr, data_layout.GetBlockEntries(metric_prefix + "/contracted_graph/node_array")); + graph_nodes_ptr, + data_layout.GetBlockEntries(metric_prefix + "/contracted_graph/node_array")); util::vector_view edge_list( - graph_edges_ptr, data_layout.GetBlockEntries(metric_prefix + "/contracted_graph/edge_array")); + graph_edges_ptr, + data_layout.GetBlockEntries(metric_prefix + "/contracted_graph/edge_array")); util::vector_view edge_filter(edge_filter_ptr, data_layout.GetBlockEntries(filter_block_id)); @@ -111,15 +113,18 @@ class ContiguousInternalMemoryAlgorithmDataFacade : public datafacade::Algor public: ContiguousInternalMemoryAlgorithmDataFacade( - std::shared_ptr allocator_, const std::string& metric_name, std::size_t exclude_index) + std::shared_ptr allocator_, + const std::string &metric_name, + std::size_t exclude_index) : allocator(std::move(allocator_)) { - InitializeInternalPointers(allocator->GetLayout(), allocator->GetMemory(), metric_name, exclude_index); + InitializeInternalPointers( + allocator->GetLayout(), allocator->GetMemory(), metric_name, exclude_index); } void InitializeInternalPointers(const storage::DataLayout &data_layout, char *memory_block, - const std::string& metric_name, + const std::string &metric_name, const std::size_t exclude_index) { InitializeGraphPointer(data_layout, memory_block, metric_name, exclude_index); @@ -229,11 +234,11 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade void InitializeProfilePropertiesPointer(const storage::DataLayout &data_layout, char *memory_block, - const std::string& metric_name, + const std::string &metric_name, const std::size_t exclude_index) { // TODO: For multi-metric support we need to have separate exclude classes per metric - (void) metric_name; + (void)metric_name; m_profile_properties = data_layout.GetBlockPtr( memory_block, "/common/properties"); @@ -242,7 +247,8 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade void InitializeChecksumPointer(const storage::DataLayout &data_layout, char *memory_block) { - m_check_sum = *data_layout.GetBlockPtr(memory_block, "/common/connectivity_checksum"); + m_check_sum = + *data_layout.GetBlockPtr(memory_block, "/common/connectivity_checksum"); util::Log() << "set checksum: " << m_check_sum; } @@ -535,7 +541,7 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade void InitializeInternalPointers(const storage::DataLayout &data_layout, char *memory_block, - const std::string& metric_name, + const std::string &metric_name, const std::size_t exclude_index) { InitializeChecksumPointer(data_layout, memory_block); @@ -556,11 +562,12 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade // allows switching between process_memory/shared_memory datafacade, based on the type of // allocator ContiguousInternalMemoryDataFacadeBase(std::shared_ptr allocator_, - const std::string& metric_name, + const std::string &metric_name, const std::size_t exclude_index) : allocator(std::move(allocator_)) { - InitializeInternalPointers(allocator->GetLayout(), allocator->GetMemory(), metric_name, exclude_index); + InitializeInternalPointers( + allocator->GetLayout(), allocator->GetMemory(), metric_name, exclude_index); } // node and edge information access @@ -946,7 +953,7 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade auto found_range = std::equal_range( m_maneuver_overrides.begin(), m_maneuver_overrides.end(), edge_based_node_id, Comp{}); - std::for_each(found_range.first, found_range.second, [&](const auto &override) { + std::for_each(found_range.first, found_range.second, [&](const auto & override) { std::vector sequence( m_maneuver_override_node_sequences.begin() + override.node_sequence_offset_begin, m_maneuver_override_node_sequences.begin() + override.node_sequence_offset_end); @@ -968,7 +975,7 @@ class ContiguousInternalMemoryDataFacade { public: ContiguousInternalMemoryDataFacade(std::shared_ptr allocator, - const std::string& metric_name, + const std::string &metric_name, const std::size_t exclude_index) : ContiguousInternalMemoryDataFacadeBase(allocator, metric_name, exclude_index), ContiguousInternalMemoryAlgorithmDataFacade(allocator, metric_name, exclude_index) @@ -991,7 +998,7 @@ template <> class ContiguousInternalMemoryAlgorithmDataFacade : public Algo void InitializeInternalPointers(const storage::DataLayout &data_layout, char *memory_block, - const std::string& metric_name, + const std::string &metric_name, const std::size_t exclude_index) { InitializeMLDDataPointers(data_layout, memory_block, metric_name, exclude_index); @@ -1000,7 +1007,7 @@ template <> class ContiguousInternalMemoryAlgorithmDataFacade : public Algo void InitializeMLDDataPointers(const storage::DataLayout &data_layout, char *memory_block, - const std::string& metric_name, + const std::string &metric_name, const std::size_t exclude_index) { if (data_layout.GetBlockSize("/mld/multilevelpartition/partition") > 0) @@ -1028,7 +1035,8 @@ template <> class ContiguousInternalMemoryAlgorithmDataFacade : public Algo partitioner::MultiLevelPartitionView{level_data, partition, cell_to_children}; } - const auto exclude_prefix = "/mld/metrics/" + metric_name + "/exclude/" + std::to_string(exclude_index); + const auto exclude_prefix = + "/mld/metrics/" + metric_name + "/exclude/" + std::to_string(exclude_index); const auto weights_block_id = exclude_prefix + "/weights"; const auto durations_block_id = exclude_prefix + "/durations"; @@ -1111,10 +1119,13 @@ template <> class ContiguousInternalMemoryAlgorithmDataFacade : public Algo public: ContiguousInternalMemoryAlgorithmDataFacade( - std::shared_ptr allocator_, const std::string& metric_name, const std::size_t exclude_index) + std::shared_ptr allocator_, + const std::string &metric_name, + const std::size_t exclude_index) : allocator(std::move(allocator_)) { - InitializeInternalPointers(allocator->GetLayout(), allocator->GetMemory(), metric_name, exclude_index); + InitializeInternalPointers( + allocator->GetLayout(), allocator->GetMemory(), metric_name, exclude_index); } const partitioner::MultiLevelPartitionView &GetMultiLevelPartition() const override @@ -1168,7 +1179,7 @@ class ContiguousInternalMemoryDataFacade final private: public: ContiguousInternalMemoryDataFacade(std::shared_ptr allocator, - const std::string& metric_name, + const std::string &metric_name, const std::size_t exclude_index) : ContiguousInternalMemoryDataFacadeBase(allocator, metric_name, exclude_index), ContiguousInternalMemoryAlgorithmDataFacade(allocator, metric_name, exclude_index) diff --git a/include/storage/io.hpp b/include/storage/io.hpp index fe2351ca3..7702c0ddb 100644 --- a/include/storage/io.hpp +++ b/include/storage/io.hpp @@ -11,9 +11,9 @@ #include "util/version.hpp" #include +#include #include #include -#include #include #include @@ -296,11 +296,10 @@ class FileWriter class BufferReader { public: - BufferReader(const std::string &buffer) : BufferReader(buffer.data(), buffer.size()) - { - } + BufferReader(const std::string &buffer) : BufferReader(buffer.data(), buffer.size()) {} - BufferReader(const char* buffer, const std::size_t size) : input_stream(boost::iostreams::array_source(buffer, size)) + BufferReader(const char *buffer, const std::size_t size) + : input_stream(boost::iostreams::array_source(buffer, size)) { if (!input_stream) { @@ -309,9 +308,7 @@ class BufferReader } } - std::size_t GetPosition() { - return input_stream.tellg(); - } + std::size_t GetPosition() { return input_stream.tellg(); } template void ReadInto(T *dest, const std::size_t count) { diff --git a/include/storage/serialization.hpp b/include/storage/serialization.hpp index ebc4d864c..af0d3ec77 100644 --- a/include/storage/serialization.hpp +++ b/include/storage/serialization.hpp @@ -6,8 +6,8 @@ #include "util/vector_view.hpp" #include "storage/io.hpp" -#include "storage/tar.hpp" #include "storage/shared_datatype.hpp" +#include "storage/tar.hpp" #include #include @@ -92,7 +92,6 @@ void writeBoolVector(tar::FileWriter &writer, const std::string &name, const Vec } } - /* All vector formats here use the same on-disk format. * This is important because we want to be able to write from a vector * of one kind, but read it into a vector of another kind. @@ -149,17 +148,12 @@ template void write(io::BufferWriter &writer, const std::vector writer.WriteFrom(data.data(), count); } -template -inline void write(io::BufferWriter &writer, const T &data) +template inline void write(io::BufferWriter &writer, const T &data) { writer.WriteFrom(data); } -template -inline void read(io::BufferReader &reader, T &data) -{ - reader.ReadInto(data); -} +template inline void read(io::BufferReader &reader, T &data) { reader.ReadInto(data); } inline void write(io::BufferWriter &writer, const std::string &data) { @@ -254,7 +248,7 @@ template void read(io::BufferReader &reader, std::map pair; for (auto index : util::irange(0, count)) { - (void) index; + (void)index; read(reader, pair.first); read(reader, pair.second); data.insert(pair); @@ -272,17 +266,12 @@ template void write(io::BufferWriter &writer, const std } } -inline void read(io::BufferReader &reader, DataLayout &layout) -{ - read(reader, layout.blocks); -} +inline void read(io::BufferReader &reader, DataLayout &layout) { read(reader, layout.blocks); } inline void write(io::BufferWriter &writer, const DataLayout &layout) { write(writer, layout.blocks); } - - } } } diff --git a/include/storage/shared_datatype.hpp b/include/storage/shared_datatype.hpp index c00ece841..041457a7f 100644 --- a/include/storage/shared_datatype.hpp +++ b/include/storage/shared_datatype.hpp @@ -71,7 +71,10 @@ class DataLayout inline uint64_t GetBlockSize(const std::string &name) const { return GetBlock(name).byte_size; } - inline bool HasBlock(const std::string &name) const { return blocks.find(name) != blocks.end(); } + inline bool HasBlock(const std::string &name) const + { + return blocks.find(name) != blocks.end(); + } inline uint64_t GetSizeOfLayout() const { diff --git a/src/engine/datafacade/shared_memory_allocator.cpp b/src/engine/datafacade/shared_memory_allocator.cpp index e3ef0f0c1..d6d8be0d2 100644 --- a/src/engine/datafacade/shared_memory_allocator.cpp +++ b/src/engine/datafacade/shared_memory_allocator.cpp @@ -20,7 +20,8 @@ SharedMemoryAllocator::SharedMemoryAllocator(storage::SharedDataType data_region BOOST_ASSERT(storage::SharedMemory::RegionExists(data_region)); m_large_memory = storage::makeSharedMemory(data_region); - storage::io::BufferReader reader(reinterpret_cast(m_large_memory->Ptr()), m_large_memory->Size()); + storage::io::BufferReader reader(reinterpret_cast(m_large_memory->Ptr()), + m_large_memory->Size()); storage::serialization::read(reader, data_layout); layout_size = reader.GetPosition(); util::Log(logDEBUG) << "Data layout has size " << layout_size; @@ -28,10 +29,7 @@ SharedMemoryAllocator::SharedMemoryAllocator(storage::SharedDataType data_region SharedMemoryAllocator::~SharedMemoryAllocator() {} -const storage::DataLayout &SharedMemoryAllocator::GetLayout() -{ - return data_layout; -} +const storage::DataLayout &SharedMemoryAllocator::GetLayout() { return data_layout; } char *SharedMemoryAllocator::GetMemory() { return reinterpret_cast(m_large_memory->Ptr()) + layout_size; diff --git a/src/storage/storage.cpp b/src/storage/storage.cpp index 8b73b658f..ad29febfc 100644 --- a/src/storage/storage.cpp +++ b/src/storage/storage.cpp @@ -405,7 +405,8 @@ void Storage::PopulateData(const DataLayout &layout, char *memory_ptr) std::move(entry_class_ids), std::move(pre_turn_bearings), std::move(post_turn_bearings)); - auto connectivity_checksum_ptr = layout.GetBlockPtr(memory_ptr, "/common/connectivity_checksum"); + auto connectivity_checksum_ptr = + layout.GetBlockPtr(memory_ptr, "/common/connectivity_checksum"); guidance::files::readTurnData( config.GetPath(".osrm.edges"), turn_data, *connectivity_checksum_ptr); diff --git a/unit_tests/contractor/files.cpp b/unit_tests/contractor/files.cpp index b3898c173..ffb9a455b 100644 --- a/unit_tests/contractor/files.cpp +++ b/unit_tests/contractor/files.cpp @@ -42,9 +42,7 @@ BOOST_AUTO_TEST_CASE(read_write_hsgr) unsigned checksum; unsigned connectivity_checksum; - std::unordered_map metrics = { - {"duration", {}} - }; + std::unordered_map metrics = {{"duration", {}}}; contractor::files::readGraph(tmp.path, checksum, metrics, connectivity_checksum); BOOST_CHECK_EQUAL(checksum, reference_checksum); diff --git a/unit_tests/storage/data_layout.cpp b/unit_tests/storage/data_layout.cpp index b97a20206..5335ff7bf 100644 --- a/unit_tests/storage/data_layout.cpp +++ b/unit_tests/storage/data_layout.cpp @@ -93,10 +93,16 @@ BOOST_AUTO_TEST_CASE(layout_list_test) layout.List("/mld/metrics/", std::back_inserter(results_5)); layout.List("/mld/", std::back_inserter(results_6)); - CHECK_EQUAL_RANGE(results_1, "/ch/edge_filter/block1", "/ch/edge_filter/block2", "/ch/edge_filter/block3"); - CHECK_EQUAL_RANGE(results_2, "/ch/edge_filter/block1", "/ch/edge_filter/block2", "/ch/edge_filter/block3"); + CHECK_EQUAL_RANGE( + results_1, "/ch/edge_filter/block1", "/ch/edge_filter/block2", "/ch/edge_filter/block3"); + CHECK_EQUAL_RANGE( + results_2, "/ch/edge_filter/block1", "/ch/edge_filter/block2", "/ch/edge_filter/block3"); CHECK_EQUAL_RANGE(results_3, "/ch/edge_filter"); - CHECK_EQUAL_RANGE(results_4, "/mld/metrics/0/durations", "/mld/metrics/0/weights", "/mld/metrics/1/durations", "/mld/metrics/1/weights"); + CHECK_EQUAL_RANGE(results_4, + "/mld/metrics/0/durations", + "/mld/metrics/0/weights", + "/mld/metrics/1/durations", + "/mld/metrics/1/weights"); CHECK_EQUAL_RANGE(results_5, "/mld/metrics/0", "/mld/metrics/1"); CHECK_EQUAL_RANGE(results_6, "/mld/metrics"); } diff --git a/unit_tests/storage/serialization.cpp b/unit_tests/storage/serialization.cpp index e8153a92f..e42f8ea8e 100644 --- a/unit_tests/storage/serialization.cpp +++ b/unit_tests/storage/serialization.cpp @@ -118,18 +118,14 @@ BOOST_AUTO_TEST_CASE(tar_serialize_deallocting_vector) BOOST_AUTO_TEST_CASE(buffer_serialize_map) { std::map map = { - {"foo", 1}, - {"barrrr", 2}, - {"bal", 3}, - {"bazbar", 4}, - {"foofofofo", 5}, + {"foo", 1}, {"barrrr", 2}, {"bal", 3}, {"bazbar", 4}, {"foofofofo", 5}, }; std::string buffer; { - io::BufferWriter writer; - storage::serialization::write(writer, map); - buffer = writer.GetBuffer(); + io::BufferWriter writer; + storage::serialization::write(writer, map); + buffer = writer.GetBuffer(); } std::map result;