Fix formating

This commit is contained in:
Patrick Niklaus
2018-03-28 23:18:28 +00:00
committed by Patrick Niklaus
parent 9fc2c32408
commit 81a4747acb
12 changed files with 80 additions and 81 deletions
+1 -2
View File
@@ -10,8 +10,7 @@ namespace contractor
namespace detail
{
template<storage::Ownership Ownership>
struct ContractedMetric
template <storage::Ownership Ownership> struct ContractedMetric
{
detail::QueryGraph<Ownership> graph;
std::vector<util::ViewOrVector<bool, Ownership>> edge_filter;
-1
View File
@@ -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
+11 -9
View File
@@ -18,7 +18,8 @@ namespace files
// reads .osrm.cell_metrics file
template <typename CellMetricT>
inline void readCellMetrics(const boost::filesystem::path &path, std::unordered_map<std::string, std::vector<CellMetricT>> &metrics)
inline void readCellMetrics(const boost::filesystem::path &path,
std::unordered_map<std::string, std::vector<CellMetricT>> &metrics)
{
static_assert(std::is_same<CellMetricView, CellMetricT>::value ||
std::is_same<CellMetric, CellMetricT>::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 <typename CellMetricT>
inline void writeCellMetrics(const boost::filesystem::path &path,
const std::unordered_map<std::string, std::vector<CellMetricT>> &metrics)
inline void
writeCellMetrics(const boost::filesystem::path &path,
const std::unordered_map<std::string, std::vector<CellMetricT>> &metrics)
{
static_assert(std::is_same<CellMetricView, CellMetricT>::value ||
std::is_same<CellMetric, CellMetricT>::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());
@@ -83,15 +83,15 @@ class ContiguousInternalMemoryAlgorithmDataFacade<CH> : 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<GraphNode>(memory_block, metric_prefix + "/contracted_graph/node_array");
auto graph_nodes_ptr = data_layout.GetBlockPtr<GraphNode>(
memory_block, metric_prefix + "/contracted_graph/node_array");
auto graph_edges_ptr =
data_layout.GetBlockPtr<GraphEdge>(memory_block, metric_prefix + "/contracted_graph/edge_array");
auto graph_edges_ptr = data_layout.GetBlockPtr<GraphEdge>(
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<CH> : public datafacade::Algor
data_layout.GetBlockPtr<util::vector_view<bool>::Word>(memory_block, filter_block_id);
util::vector_view<GraphNode> 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<GraphEdge> 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<bool> edge_filter(edge_filter_ptr,
data_layout.GetBlockEntries(filter_block_id));
@@ -111,15 +113,18 @@ class ContiguousInternalMemoryAlgorithmDataFacade<CH> : public datafacade::Algor
public:
ContiguousInternalMemoryAlgorithmDataFacade(
std::shared_ptr<ContiguousBlockAllocator> allocator_, const std::string& metric_name, std::size_t exclude_index)
std::shared_ptr<ContiguousBlockAllocator> 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<extractor::ProfileProperties>(
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<std::uint32_t>(memory_block, "/common/connectivity_checksum");
m_check_sum =
*data_layout.GetBlockPtr<std::uint32_t>(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<ContiguousBlockAllocator> 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<NodeID> 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<CH>
{
public:
ContiguousInternalMemoryDataFacade(std::shared_ptr<ContiguousBlockAllocator> allocator,
const std::string& metric_name,
const std::string &metric_name,
const std::size_t exclude_index)
: ContiguousInternalMemoryDataFacadeBase(allocator, metric_name, exclude_index),
ContiguousInternalMemoryAlgorithmDataFacade<CH>(allocator, metric_name, exclude_index)
@@ -991,7 +998,7 @@ template <> class ContiguousInternalMemoryAlgorithmDataFacade<MLD> : 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<MLD> : 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<MLD> : 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<MLD> : public Algo
public:
ContiguousInternalMemoryAlgorithmDataFacade(
std::shared_ptr<ContiguousBlockAllocator> allocator_, const std::string& metric_name, const std::size_t exclude_index)
std::shared_ptr<ContiguousBlockAllocator> 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<MLD> final
private:
public:
ContiguousInternalMemoryDataFacade(std::shared_ptr<ContiguousBlockAllocator> allocator,
const std::string& metric_name,
const std::string &metric_name,
const std::size_t exclude_index)
: ContiguousInternalMemoryDataFacadeBase(allocator, metric_name, exclude_index),
ContiguousInternalMemoryAlgorithmDataFacade<MLD>(allocator, metric_name, exclude_index)
+5 -8
View File
@@ -11,9 +11,9 @@
#include "util/version.hpp"
#include <boost/filesystem/fstream.hpp>
#include <boost/iostreams/device/array.hpp>
#include <boost/iostreams/seek.hpp>
#include <boost/iostreams/stream.hpp>
#include <boost/iostreams/device/array.hpp>
#include <cerrno>
#include <cstring>
@@ -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 <typename T> void ReadInto(T *dest, const std::size_t count)
{
+5 -16
View File
@@ -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 <boost/function_output_iterator.hpp>
#include <boost/iterator/function_input_iterator.hpp>
@@ -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 <typename T> void write(io::BufferWriter &writer, const std::vector<T>
writer.WriteFrom(data.data(), count);
}
template<typename T>
inline void write(io::BufferWriter &writer, const T &data)
template <typename T> inline void write(io::BufferWriter &writer, const T &data)
{
writer.WriteFrom(data);
}
template<typename T>
inline void read(io::BufferReader &reader, T &data)
{
reader.ReadInto(data);
}
template <typename T> 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 <typename K, typename V> void read(io::BufferReader &reader, std::map<K
std::pair<K, V> pair;
for (auto index : util::irange<std::size_t>(0, count))
{
(void) index;
(void)index;
read(reader, pair.first);
read(reader, pair.second);
data.insert(pair);
@@ -272,17 +266,12 @@ template <typename K, typename V> 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);
}
}
}
}
+4 -1
View File
@@ -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
{