diff --git a/include/engine/datafacade/internal_datafacade.hpp b/include/engine/datafacade/internal_datafacade.hpp index fcc7eecde..2418792c7 100644 --- a/include/engine/datafacade/internal_datafacade.hpp +++ b/include/engine/datafacade/internal_datafacade.hpp @@ -123,9 +123,8 @@ class InternalDataFacade final : public BaseDataFacade { throw util::exception("Could not open " + properties_path.string() + " for reading."); } - - in_stream.read(reinterpret_cast(&m_profile_properties), - sizeof(m_profile_properties)); + auto PropertiesSize = storage::io::readPropertiesSize(); + storage::io::readProperties(in_stream, reinterpret_cast(&m_profile_properties), PropertiesSize); } void LoadLaneTupleIdPairs(const boost::filesystem::path &lane_data_path) diff --git a/include/storage/io.hpp b/include/storage/io.hpp index 644e9a4bb..31a2df461 100644 --- a/include/storage/io.hpp +++ b/include/storage/io.hpp @@ -15,6 +15,16 @@ namespace storage namespace io { +inline std::size_t readPropertiesSize() { return 1; } + +template +inline void readProperties(boost::filesystem::ifstream &properties_stream, + PropertiesT properties[], + std::size_t PropertiesSize) +{ + properties_stream.read(properties, PropertiesSize); +} + #pragma pack(push, 1) struct HSGRHeader { @@ -39,8 +49,10 @@ inline HSGRHeader readHSGRHeader(boost::filesystem::ifstream &input_stream) HSGRHeader header; input_stream.read(reinterpret_cast(&header.checksum), sizeof(header.checksum)); - input_stream.read(reinterpret_cast(&header.number_of_nodes), sizeof(header.number_of_nodes)); - input_stream.read(reinterpret_cast(&header.number_of_edges), sizeof(header.number_of_edges)); + input_stream.read(reinterpret_cast(&header.number_of_nodes), + sizeof(header.number_of_nodes)); + input_stream.read(reinterpret_cast(&header.number_of_edges), + sizeof(header.number_of_edges)); BOOST_ASSERT_MSG(0 != header.number_of_nodes, "number of nodes is zero"); // number of edges can be zero, this is the case in a few test fixtures @@ -48,7 +60,7 @@ inline HSGRHeader readHSGRHeader(boost::filesystem::ifstream &input_stream) return header; } -// Needs to be called after HSGRHeader() to get the correct offset in the stream +// Needs to be called after readHSGRHeader() to get the correct offset in the stream template void readHSGR(boost::filesystem::ifstream &input_stream, NodeT *node_buffer, @@ -59,7 +71,6 @@ void readHSGR(boost::filesystem::ifstream &input_stream, input_stream.read(reinterpret_cast(node_buffer), number_of_nodes * sizeof(NodeT)); input_stream.read(reinterpret_cast(edge_buffer), number_of_edges * sizeof(EdgeT)); } - // Returns the size of the timestamp in a file inline std::uint32_t readTimestampSize(boost::filesystem::ifstream ×tamp_input_stream) { diff --git a/src/storage/storage.cpp b/src/storage/storage.cpp index 9d682deb1..767b5aae4 100644 --- a/src/storage/storage.cpp +++ b/src/storage/storage.cpp @@ -273,8 +273,10 @@ Storage::ReturnCode Storage::Run(int max_wait) tree_node_file.read((char *)&tree_size, sizeof(uint32_t)); shared_layout_ptr->SetBlockSize(SharedDataLayout::R_SEARCH_TREE, tree_size); - // load profile properties - shared_layout_ptr->SetBlockSize(SharedDataLayout::PROPERTIES, 1); + // allocate space in shared memory for profile properties + std::size_t PropertiesSize = io::readPropertiesSize(); + shared_layout_ptr->SetBlockSize(SharedDataLayout::PROPERTIES, + PropertiesSize); // read timestampsize boost::filesystem::ifstream timestamp_stream(config.timestamp_path); @@ -760,7 +762,7 @@ Storage::ReturnCode Storage::Run(int max_wait) hsgr_input_stream.close(); // load profile properties - auto profile_properties_ptr = + extractor::ProfileProperties *profile_properties_ptr = shared_layout_ptr->GetBlockPtr( shared_memory_ptr, SharedDataLayout::PROPERTIES); boost::filesystem::ifstream profile_properties_stream(config.properties_path); @@ -768,8 +770,9 @@ Storage::ReturnCode Storage::Run(int max_wait) { util::exception("Could not open " + config.properties_path.string() + " for reading!"); } - profile_properties_stream.read(reinterpret_cast(profile_properties_ptr), - sizeof(extractor::ProfileProperties)); + io::readProperties(profile_properties_stream, + reinterpret_cast(profile_properties_ptr), + PropertiesSize); // load intersection classes if (!bearing_class_id_table.empty())