Fix formating
This commit is contained in:
parent
9fc2c32408
commit
81a4747acb
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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,7 +47,8 @@ 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,
|
||||
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 ||
|
||||
@ -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)
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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<char *>(m_large_memory->Ptr()), m_large_memory->Size());
|
||||
storage::io::BufferReader reader(reinterpret_cast<char *>(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<char *>(m_large_memory->Ptr()) + layout_size;
|
||||
|
@ -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<std::uint32_t, true>(memory_ptr, "/common/connectivity_checksum");
|
||||
auto connectivity_checksum_ptr =
|
||||
layout.GetBlockPtr<std::uint32_t, true>(memory_ptr, "/common/connectivity_checksum");
|
||||
|
||||
guidance::files::readTurnData(
|
||||
config.GetPath(".osrm.edges"), turn_data, *connectivity_checksum_ptr);
|
||||
|
@ -42,9 +42,7 @@ BOOST_AUTO_TEST_CASE(read_write_hsgr)
|
||||
unsigned checksum;
|
||||
unsigned connectivity_checksum;
|
||||
|
||||
std::unordered_map<std::string, ContractedMetric> metrics = {
|
||||
{"duration", {}}
|
||||
};
|
||||
std::unordered_map<std::string, ContractedMetric> metrics = {{"duration", {}}};
|
||||
contractor::files::readGraph(tmp.path, checksum, metrics, connectivity_checksum);
|
||||
|
||||
BOOST_CHECK_EQUAL(checksum, reference_checksum);
|
||||
|
@ -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");
|
||||
}
|
||||
|
@ -118,11 +118,7 @@ BOOST_AUTO_TEST_CASE(tar_serialize_deallocting_vector)
|
||||
BOOST_AUTO_TEST_CASE(buffer_serialize_map)
|
||||
{
|
||||
std::map<std::string, std::int32_t> map = {
|
||||
{"foo", 1},
|
||||
{"barrrr", 2},
|
||||
{"bal", 3},
|
||||
{"bazbar", 4},
|
||||
{"foofofofo", 5},
|
||||
{"foo", 1}, {"barrrr", 2}, {"bal", 3}, {"bazbar", 4}, {"foofofofo", 5},
|
||||
};
|
||||
|
||||
std::string buffer;
|
||||
|
Loading…
Reference in New Issue
Block a user