renamed: Server/DataStructures/*.h -> Server/data_structures/*.hpp
This commit is contained in:
parent
872cb2d9c8
commit
0c1101739d
@ -75,7 +75,7 @@ file(GLOB DatastructureGlob data_structures/search_engine_data.cpp data_structur
|
|||||||
list(REMOVE_ITEM DatastructureGlob data_structures/Coordinate.cpp)
|
list(REMOVE_ITEM DatastructureGlob data_structures/Coordinate.cpp)
|
||||||
file(GLOB CoordinateGlob data_structures/coordinate*.cpp)
|
file(GLOB CoordinateGlob data_structures/coordinate*.cpp)
|
||||||
file(GLOB AlgorithmGlob algorithms/*.cpp)
|
file(GLOB AlgorithmGlob algorithms/*.cpp)
|
||||||
file(GLOB HttpGlob Server/Http/*.cpp)
|
file(GLOB HttpGlob Server/http/*.cpp)
|
||||||
file(GLOB LibOSRMGlob Library/*.cpp)
|
file(GLOB LibOSRMGlob Library/*.cpp)
|
||||||
file(GLOB DataStructureTestsGlob unit_tests/data_structures/*.cpp data_structures/hilbert_value.cpp)
|
file(GLOB DataStructureTestsGlob unit_tests/data_structures/*.cpp data_structures/hilbert_value.cpp)
|
||||||
file(GLOB AlgorithmTestsGlob unit_tests/algorithms/*.cpp)
|
file(GLOB AlgorithmTestsGlob unit_tests/algorithms/*.cpp)
|
||||||
|
@ -25,7 +25,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace boost { namespace interprocess { class named_mutex; } }
|
namespace boost
|
||||||
|
{
|
||||||
|
namespace interprocess
|
||||||
|
{
|
||||||
|
class named_mutex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#include "OSRM_impl.h"
|
#include "OSRM_impl.h"
|
||||||
#include "OSRM.h"
|
#include "OSRM.h"
|
||||||
@ -36,10 +42,10 @@ namespace boost { namespace interprocess { class named_mutex; } }
|
|||||||
#include "../plugins/nearest.hpp"
|
#include "../plugins/nearest.hpp"
|
||||||
#include "../plugins/timestamp.hpp"
|
#include "../plugins/timestamp.hpp"
|
||||||
#include "../plugins/viaroute.hpp"
|
#include "../plugins/viaroute.hpp"
|
||||||
#include "../Server/DataStructures/BaseDataFacade.h"
|
#include "../Server/data_structures/datafacade_base.hpp"
|
||||||
#include "../Server/DataStructures/InternalDataFacade.h"
|
#include "../Server/data_structures/internal_datafacade.hpp"
|
||||||
#include "../Server/DataStructures/SharedBarriers.h"
|
#include "../Server/data_structures/shared_barriers.hpp"
|
||||||
#include "../Server/DataStructures/SharedDataFacade.h"
|
#include "../Server/data_structures/shared_datafacade.hpp"
|
||||||
#include "../Util/make_unique.hpp"
|
#include "../Util/make_unique.hpp"
|
||||||
#include "../Util/ProgramOptions.h"
|
#include "../Util/ProgramOptions.h"
|
||||||
#include "../Util/simple_logger.hpp"
|
#include "../Util/simple_logger.hpp"
|
||||||
@ -70,8 +76,8 @@ OSRM_impl::OSRM_impl(libosrm_config &lib_config)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The following plugins handle all requests.
|
// The following plugins handle all requests.
|
||||||
RegisterPlugin(new DistanceTablePlugin<BaseDataFacade<QueryEdge::EdgeData>>(query_data_facade,
|
RegisterPlugin(new DistanceTablePlugin<BaseDataFacade<QueryEdge::EdgeData>>(
|
||||||
lib_config.max_locations_distance_table));
|
query_data_facade, lib_config.max_locations_distance_table));
|
||||||
RegisterPlugin(new HelloWorldPlugin());
|
RegisterPlugin(new HelloWorldPlugin());
|
||||||
RegisterPlugin(new LocatePlugin<BaseDataFacade<QueryEdge::EdgeData>>(query_data_facade));
|
RegisterPlugin(new LocatePlugin<BaseDataFacade<QueryEdge::EdgeData>>(query_data_facade));
|
||||||
RegisterPlugin(new NearestPlugin<BaseDataFacade<QueryEdge::EdgeData>>(query_data_facade));
|
RegisterPlugin(new NearestPlugin<BaseDataFacade<QueryEdge::EdgeData>>(query_data_facade));
|
||||||
@ -162,10 +168,7 @@ void OSRM_impl::increase_concurrent_query_count()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// proxy code for compilation firewall
|
// proxy code for compilation firewall
|
||||||
OSRM::OSRM(libosrm_config &lib_config)
|
OSRM::OSRM(libosrm_config &lib_config) : OSRM_pimpl_(osrm::make_unique<OSRM_impl>(lib_config)) {}
|
||||||
: OSRM_pimpl_(osrm::make_unique<OSRM_impl>(lib_config))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
OSRM::~OSRM() { OSRM_pimpl_.reset(); }
|
OSRM::~OSRM() { OSRM_pimpl_.reset(); }
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
|
|
||||||
Copyright (c) 2014, Project OSRM, Dennis Luxen, others
|
Copyright (c) 2015, Project OSRM, Dennis Luxen, others
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
Redistribution and use in source and binary forms, with or without modification,
|
||||||
@ -25,8 +25,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef BASE_DATA_FACADE_H
|
#ifndef DATAFACADE_BASE_HPP
|
||||||
#define BASE_DATA_FACADE_H
|
#define DATAFACADE_BASE_HPP
|
||||||
|
|
||||||
// Exposes all data access interfaces to the algorithms via base class ptr
|
// Exposes all data access interfaces to the algorithms via base class ptr
|
||||||
|
|
||||||
@ -123,4 +123,4 @@ template <class EdgeDataT> class BaseDataFacade
|
|||||||
virtual std::string GetTimestamp() const = 0;
|
virtual std::string GetTimestamp() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BASE_DATA_FACADE_H
|
#endif // DATAFACADE_BASE_HPP
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
|
|
||||||
Copyright (c) 2013, Project OSRM, Dennis Luxen, others
|
Copyright (c) 2015, Project OSRM, Dennis Luxen, others
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
Redistribution and use in source and binary forms, with or without modification,
|
||||||
@ -25,12 +25,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef INTERNAL_DATA_FACADE
|
#ifndef INTERNAL_DATAFACADE_HPP
|
||||||
#define INTERNAL_DATA_FACADE
|
#define INTERNAL_DATAFACADE_HPP
|
||||||
|
|
||||||
// implements all data storage when shared memory is _NOT_ used
|
// implements all data storage when shared memory is _NOT_ used
|
||||||
|
|
||||||
#include "BaseDataFacade.h"
|
#include "datafacade_base.hpp"
|
||||||
|
|
||||||
#include "../../data_structures/original_edge_data.hpp"
|
#include "../../data_structures/original_edge_data.hpp"
|
||||||
#include "../../data_structures/query_node.hpp"
|
#include "../../data_structures/query_node.hpp"
|
||||||
@ -359,10 +359,7 @@ template <class EdgeDataT> class InternalDataFacade : public BaseDataFacade<Edge
|
|||||||
return m_turn_instruction_list.at(id);
|
return m_turn_instruction_list.at(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
TravelMode GetTravelModeForEdgeID(const unsigned id) const
|
TravelMode GetTravelModeForEdgeID(const unsigned id) const { return m_travel_mode_list.at(id); }
|
||||||
{
|
|
||||||
return m_travel_mode_list.at(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LocateClosestEndPointForCoordinate(const FixedPointCoordinate &input_coordinate,
|
bool LocateClosestEndPointForCoordinate(const FixedPointCoordinate &input_coordinate,
|
||||||
FixedPointCoordinate &result,
|
FixedPointCoordinate &result,
|
||||||
@ -373,18 +370,16 @@ template <class EdgeDataT> class InternalDataFacade : public BaseDataFacade<Edge
|
|||||||
LoadRTree();
|
LoadRTree();
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_static_rtree->LocateClosestEndPointForCoordinate(
|
return m_static_rtree->LocateClosestEndPointForCoordinate(input_coordinate, result,
|
||||||
input_coordinate, result, zoom_level);
|
zoom_level);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool IncrementalFindPhantomNodeForCoordinate(const FixedPointCoordinate &input_coordinate,
|
||||||
IncrementalFindPhantomNodeForCoordinate(const FixedPointCoordinate &input_coordinate,
|
PhantomNode &resulting_phantom_node) final
|
||||||
PhantomNode &resulting_phantom_node) final
|
|
||||||
{
|
{
|
||||||
std::vector<PhantomNode> resulting_phantom_node_vector;
|
std::vector<PhantomNode> resulting_phantom_node_vector;
|
||||||
auto result = IncrementalFindPhantomNodeForCoordinate(input_coordinate,
|
auto result = IncrementalFindPhantomNodeForCoordinate(input_coordinate,
|
||||||
resulting_phantom_node_vector,
|
resulting_phantom_node_vector, 1);
|
||||||
1);
|
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(!resulting_phantom_node_vector.empty());
|
BOOST_ASSERT(!resulting_phantom_node_vector.empty());
|
||||||
@ -428,8 +423,7 @@ template <class EdgeDataT> class InternalDataFacade : public BaseDataFacade<Edge
|
|||||||
{
|
{
|
||||||
result.resize(range.back() - range.front() + 1);
|
result.resize(range.back() - range.front() + 1);
|
||||||
std::copy(m_names_char_list.begin() + range.front(),
|
std::copy(m_names_char_list.begin() + range.front(),
|
||||||
m_names_char_list.begin() + range.back() + 1,
|
m_names_char_list.begin() + range.back() + 1, result.begin());
|
||||||
result.begin());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -445,11 +439,11 @@ template <class EdgeDataT> class InternalDataFacade : public BaseDataFacade<Edge
|
|||||||
const unsigned end = m_geometry_indices.at(id + 1);
|
const unsigned end = m_geometry_indices.at(id + 1);
|
||||||
|
|
||||||
result_nodes.clear();
|
result_nodes.clear();
|
||||||
result_nodes.insert(
|
result_nodes.insert(result_nodes.begin(), m_geometry_list.begin() + begin,
|
||||||
result_nodes.begin(), m_geometry_list.begin() + begin, m_geometry_list.begin() + end);
|
m_geometry_list.begin() + end);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetTimestamp() const final { return m_timestamp; }
|
std::string GetTimestamp() const final { return m_timestamp; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INTERNAL_DATA_FACADE
|
#endif // INTERNAL_DATAFACADE_HPP
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
|
|
||||||
Copyright (c) 2013, Project OSRM, Dennis Luxen, others
|
Copyright (c) 2015, Project OSRM, Dennis Luxen, others
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
Redistribution and use in source and binary forms, with or without modification,
|
||||||
@ -25,8 +25,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SHARED_BARRIER_H
|
#ifndef SHARED_BARRIERS_HPP
|
||||||
#define SHARED_BARRIER_H
|
#define SHARED_BARRIERS_HPP
|
||||||
|
|
||||||
#include <boost/interprocess/sync/named_mutex.hpp>
|
#include <boost/interprocess/sync/named_mutex.hpp>
|
||||||
#include <boost/interprocess/sync/named_condition.hpp>
|
#include <boost/interprocess/sync/named_condition.hpp>
|
||||||
@ -57,4 +57,4 @@ struct SharedBarriers
|
|||||||
int number_of_queries;
|
int number_of_queries;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SHARED_BARRIER_H
|
#endif // SHARED_BARRIERS_HPP
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
|
|
||||||
Copyright (c) 2014, Project OSRM, Dennis Luxen, others
|
Copyright (c) 2015, Project OSRM, Dennis Luxen, others
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
Redistribution and use in source and binary forms, with or without modification,
|
||||||
@ -25,13 +25,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SHARED_DATA_FACADE_H
|
#ifndef SHARED_DATAFACADE_HPP
|
||||||
#define SHARED_DATA_FACADE_H
|
#define SHARED_DATAFACADE_HPP
|
||||||
|
|
||||||
// implements all data storage when shared memory _IS_ used
|
// implements all data storage when shared memory _IS_ used
|
||||||
|
|
||||||
#include "BaseDataFacade.h"
|
#include "datafacade_base.hpp"
|
||||||
#include "SharedDataType.h"
|
#include "shared_datatype.hpp"
|
||||||
|
|
||||||
#include "../../data_structures/range_table.hpp"
|
#include "../../data_structures/range_table.hpp"
|
||||||
#include "../../data_structures/static_graph.hpp"
|
#include "../../data_structures/static_graph.hpp"
|
||||||
@ -112,12 +112,11 @@ template <class EdgeDataT> class SharedDataFacade : public BaseDataFacade<EdgeDa
|
|||||||
|
|
||||||
RTreeNode *tree_ptr =
|
RTreeNode *tree_ptr =
|
||||||
data_layout->GetBlockPtr<RTreeNode>(shared_memory, SharedDataLayout::R_SEARCH_TREE);
|
data_layout->GetBlockPtr<RTreeNode>(shared_memory, SharedDataLayout::R_SEARCH_TREE);
|
||||||
m_static_rtree.reset(new TimeStampedRTreePair(CURRENT_TIMESTAMP,
|
m_static_rtree.reset(new TimeStampedRTreePair(
|
||||||
|
CURRENT_TIMESTAMP,
|
||||||
osrm::make_unique<SharedRTree>(
|
osrm::make_unique<SharedRTree>(
|
||||||
tree_ptr,
|
tree_ptr, data_layout->num_entries[SharedDataLayout::R_SEARCH_TREE],
|
||||||
data_layout->num_entries[SharedDataLayout::R_SEARCH_TREE],
|
file_index_path, m_coordinate_list)));
|
||||||
file_index_path,
|
|
||||||
m_coordinate_list)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadGraph()
|
void LoadGraph()
|
||||||
@ -143,11 +142,10 @@ template <class EdgeDataT> class SharedDataFacade : public BaseDataFacade<EdgeDa
|
|||||||
m_coordinate_list = osrm::make_unique<ShM<FixedPointCoordinate, true>::vector>(
|
m_coordinate_list = osrm::make_unique<ShM<FixedPointCoordinate, true>::vector>(
|
||||||
coordinate_list_ptr, data_layout->num_entries[SharedDataLayout::COORDINATE_LIST]);
|
coordinate_list_ptr, data_layout->num_entries[SharedDataLayout::COORDINATE_LIST]);
|
||||||
|
|
||||||
TravelMode *travel_mode_list_ptr = data_layout->GetBlockPtr<TravelMode>(
|
TravelMode *travel_mode_list_ptr =
|
||||||
shared_memory, SharedDataLayout::TRAVEL_MODE);
|
data_layout->GetBlockPtr<TravelMode>(shared_memory, SharedDataLayout::TRAVEL_MODE);
|
||||||
typename ShM<TravelMode, true>::vector travel_mode_list(
|
typename ShM<TravelMode, true>::vector travel_mode_list(
|
||||||
travel_mode_list_ptr,
|
travel_mode_list_ptr, data_layout->num_entries[SharedDataLayout::TRAVEL_MODE]);
|
||||||
data_layout->num_entries[SharedDataLayout::TRAVEL_MODE]);
|
|
||||||
m_travel_mode_list.swap(travel_mode_list);
|
m_travel_mode_list.swap(travel_mode_list);
|
||||||
|
|
||||||
TurnInstruction *turn_instruction_list_ptr = data_layout->GetBlockPtr<TurnInstruction>(
|
TurnInstruction *turn_instruction_list_ptr = data_layout->GetBlockPtr<TurnInstruction>(
|
||||||
@ -259,7 +257,7 @@ template <class EdgeDataT> class SharedDataFacade : public BaseDataFacade<EdgeDa
|
|||||||
{
|
{
|
||||||
SimpleLogger().Write(logDEBUG) << "Leaf file name " << file_index_path.string();
|
SimpleLogger().Write(logDEBUG) << "Leaf file name " << file_index_path.string();
|
||||||
throw osrm::exception("Could not load leaf index file."
|
throw osrm::exception("Could not load leaf index file."
|
||||||
"Is any data loaded into shared memory?");
|
"Is any data loaded into shared memory?");
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadGraph();
|
LoadGraph();
|
||||||
@ -337,8 +335,8 @@ template <class EdgeDataT> class SharedDataFacade : public BaseDataFacade<EdgeDa
|
|||||||
const unsigned end = m_geometry_indices.at(id + 1);
|
const unsigned end = m_geometry_indices.at(id + 1);
|
||||||
|
|
||||||
result_nodes.clear();
|
result_nodes.clear();
|
||||||
result_nodes.insert(
|
result_nodes.insert(result_nodes.begin(), m_geometry_list.begin() + begin,
|
||||||
result_nodes.begin(), m_geometry_list.begin() + begin, m_geometry_list.begin() + end);
|
m_geometry_list.begin() + end);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual unsigned GetGeometryIndexForEdgeID(const unsigned id) const final
|
virtual unsigned GetGeometryIndexForEdgeID(const unsigned id) const final
|
||||||
@ -351,10 +349,7 @@ template <class EdgeDataT> class SharedDataFacade : public BaseDataFacade<EdgeDa
|
|||||||
return m_turn_instruction_list.at(id);
|
return m_turn_instruction_list.at(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
TravelMode GetTravelModeForEdgeID(const unsigned id) const
|
TravelMode GetTravelModeForEdgeID(const unsigned id) const { return m_travel_mode_list.at(id); }
|
||||||
{
|
|
||||||
return m_travel_mode_list.at(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LocateClosestEndPointForCoordinate(const FixedPointCoordinate &input_coordinate,
|
bool LocateClosestEndPointForCoordinate(const FixedPointCoordinate &input_coordinate,
|
||||||
FixedPointCoordinate &result,
|
FixedPointCoordinate &result,
|
||||||
@ -365,18 +360,16 @@ template <class EdgeDataT> class SharedDataFacade : public BaseDataFacade<EdgeDa
|
|||||||
LoadRTree();
|
LoadRTree();
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_static_rtree->second->LocateClosestEndPointForCoordinate(
|
return m_static_rtree->second->LocateClosestEndPointForCoordinate(input_coordinate, result,
|
||||||
input_coordinate, result, zoom_level);
|
zoom_level);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool IncrementalFindPhantomNodeForCoordinate(const FixedPointCoordinate &input_coordinate,
|
||||||
IncrementalFindPhantomNodeForCoordinate(const FixedPointCoordinate &input_coordinate,
|
PhantomNode &resulting_phantom_node) final
|
||||||
PhantomNode &resulting_phantom_node) final
|
|
||||||
{
|
{
|
||||||
std::vector<PhantomNode> resulting_phantom_node_vector;
|
std::vector<PhantomNode> resulting_phantom_node_vector;
|
||||||
auto result = IncrementalFindPhantomNodeForCoordinate(input_coordinate,
|
auto result = IncrementalFindPhantomNodeForCoordinate(input_coordinate,
|
||||||
resulting_phantom_node_vector,
|
resulting_phantom_node_vector, 1);
|
||||||
1);
|
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(!resulting_phantom_node_vector.empty());
|
BOOST_ASSERT(!resulting_phantom_node_vector.empty());
|
||||||
@ -420,12 +413,11 @@ template <class EdgeDataT> class SharedDataFacade : public BaseDataFacade<EdgeDa
|
|||||||
{
|
{
|
||||||
result.resize(range.back() - range.front() + 1);
|
result.resize(range.back() - range.front() + 1);
|
||||||
std::copy(m_names_char_list.begin() + range.front(),
|
std::copy(m_names_char_list.begin() + range.front(),
|
||||||
m_names_char_list.begin() + range.back() + 1,
|
m_names_char_list.begin() + range.back() + 1, result.begin());
|
||||||
result.begin());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetTimestamp() const final { return m_timestamp; }
|
std::string GetTimestamp() const final { return m_timestamp; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SHARED_DATA_FACADE_H
|
#endif // SHARED_DATAFACADE_HPP
|
@ -25,8 +25,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SHARED_DATA_TYPE_H_
|
#ifndef SHARED_DATA_TYPE_HPP
|
||||||
#define SHARED_DATA_TYPE_H_
|
#define SHARED_DATA_TYPE_HPP
|
||||||
|
|
||||||
#include "../../Util/osrm_exception.hpp"
|
#include "../../Util/osrm_exception.hpp"
|
||||||
#include "../../Util/simple_logger.hpp"
|
#include "../../Util/simple_logger.hpp"
|
||||||
@ -35,12 +35,16 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
// Added at the start and end of each block as sanity check
|
// Added at the start and end of each block as sanity check
|
||||||
static const char CANARY[] = "OSRM";
|
constexpr static const char CANARY[] = "OSRM";
|
||||||
|
}
|
||||||
|
|
||||||
struct SharedDataLayout
|
struct SharedDataLayout
|
||||||
{
|
{
|
||||||
enum BlockID {
|
enum BlockID
|
||||||
|
{
|
||||||
NAME_OFFSETS = 0,
|
NAME_OFFSETS = 0,
|
||||||
NAME_BLOCKS,
|
NAME_BLOCKS,
|
||||||
NAME_CHAR_LIST,
|
NAME_CHAR_LIST,
|
||||||
@ -64,54 +68,81 @@ struct SharedDataLayout
|
|||||||
std::array<uint64_t, NUM_BLOCKS> num_entries;
|
std::array<uint64_t, NUM_BLOCKS> num_entries;
|
||||||
std::array<uint64_t, NUM_BLOCKS> entry_size;
|
std::array<uint64_t, NUM_BLOCKS> entry_size;
|
||||||
|
|
||||||
SharedDataLayout()
|
SharedDataLayout() : num_entries(), entry_size() {}
|
||||||
: num_entries()
|
|
||||||
, entry_size()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void PrintInformation() const
|
void PrintInformation() const
|
||||||
{
|
{
|
||||||
SimpleLogger().Write(logDEBUG) << "-";
|
SimpleLogger().Write(logDEBUG) << "-";
|
||||||
SimpleLogger().Write(logDEBUG) << "name_offsets_size: " << num_entries[NAME_OFFSETS];
|
SimpleLogger().Write(logDEBUG)
|
||||||
SimpleLogger().Write(logDEBUG) << "name_blocks_size: " << num_entries[NAME_BLOCKS];
|
<< "name_offsets_size: " << num_entries[NAME_OFFSETS];
|
||||||
SimpleLogger().Write(logDEBUG) << "name_char_list_size: " << num_entries[NAME_CHAR_LIST];
|
SimpleLogger().Write(logDEBUG)
|
||||||
SimpleLogger().Write(logDEBUG) << "name_id_list_size: " << num_entries[NAME_ID_LIST];
|
<< "name_blocks_size: " << num_entries[NAME_BLOCKS];
|
||||||
SimpleLogger().Write(logDEBUG) << "via_node_list_size: " << num_entries[VIA_NODE_LIST];
|
SimpleLogger().Write(logDEBUG)
|
||||||
SimpleLogger().Write(logDEBUG) << "graph_node_list_size: " << num_entries[GRAPH_NODE_LIST];
|
<< "name_char_list_size: " << num_entries[NAME_CHAR_LIST];
|
||||||
SimpleLogger().Write(logDEBUG) << "graph_edge_list_size: " << num_entries[GRAPH_EDGE_LIST];
|
SimpleLogger().Write(logDEBUG)
|
||||||
|
<< "name_id_list_size: " << num_entries[NAME_ID_LIST];
|
||||||
|
SimpleLogger().Write(logDEBUG)
|
||||||
|
<< "via_node_list_size: " << num_entries[VIA_NODE_LIST];
|
||||||
|
SimpleLogger().Write(logDEBUG)
|
||||||
|
<< "graph_node_list_size: " << num_entries[GRAPH_NODE_LIST];
|
||||||
|
SimpleLogger().Write(logDEBUG)
|
||||||
|
<< "graph_edge_list_size: " << num_entries[GRAPH_EDGE_LIST];
|
||||||
SimpleLogger().Write(logDEBUG) << "timestamp_length: " << num_entries[TIMESTAMP];
|
SimpleLogger().Write(logDEBUG) << "timestamp_length: " << num_entries[TIMESTAMP];
|
||||||
SimpleLogger().Write(logDEBUG) << "coordinate_list_size: " << num_entries[COORDINATE_LIST];
|
SimpleLogger().Write(logDEBUG)
|
||||||
SimpleLogger().Write(logDEBUG) << "turn_instruction_list_size: " << num_entries[TURN_INSTRUCTION];
|
<< "coordinate_list_size: " << num_entries[COORDINATE_LIST];
|
||||||
SimpleLogger().Write(logDEBUG) << "travel_mode_list_size: " << num_entries[TRAVEL_MODE];
|
SimpleLogger().Write(logDEBUG)
|
||||||
SimpleLogger().Write(logDEBUG) << "r_search_tree_size: " << num_entries[R_SEARCH_TREE];
|
<< "turn_instruction_list_size: " << num_entries[TURN_INSTRUCTION];
|
||||||
SimpleLogger().Write(logDEBUG) << "geometries_indicators: " << num_entries[GEOMETRIES_INDICATORS]
|
SimpleLogger().Write(logDEBUG)
|
||||||
<< "/" << ((num_entries[GEOMETRIES_INDICATORS] / 8) + 1);
|
<< "travel_mode_list_size: " << num_entries[TRAVEL_MODE];
|
||||||
SimpleLogger().Write(logDEBUG) << "geometries_index_list_size: " << num_entries[GEOMETRIES_INDEX];
|
SimpleLogger().Write(logDEBUG)
|
||||||
SimpleLogger().Write(logDEBUG) << "geometries_list_size: " << num_entries[GEOMETRIES_LIST];
|
<< "r_search_tree_size: " << num_entries[R_SEARCH_TREE];
|
||||||
SimpleLogger().Write(logDEBUG) << "sizeof(checksum): " << entry_size[HSGR_CHECKSUM];
|
SimpleLogger().Write(logDEBUG)
|
||||||
|
<< "geometries_indicators: " << num_entries[GEOMETRIES_INDICATORS] << "/"
|
||||||
|
<< ((num_entries[GEOMETRIES_INDICATORS] / 8) + 1);
|
||||||
|
SimpleLogger().Write(logDEBUG)
|
||||||
|
<< "geometries_index_list_size: " << num_entries[GEOMETRIES_INDEX];
|
||||||
|
SimpleLogger().Write(logDEBUG)
|
||||||
|
<< "geometries_list_size: " << num_entries[GEOMETRIES_LIST];
|
||||||
|
SimpleLogger().Write(logDEBUG)
|
||||||
|
<< "sizeof(checksum): " << entry_size[HSGR_CHECKSUM];
|
||||||
|
|
||||||
SimpleLogger().Write(logDEBUG) << "NAME_OFFSETS " << ": " << GetBlockSize(NAME_OFFSETS );
|
SimpleLogger().Write(logDEBUG) << "NAME_OFFSETS "
|
||||||
SimpleLogger().Write(logDEBUG) << "NAME_BLOCKS " << ": " << GetBlockSize(NAME_BLOCKS );
|
<< ": " << GetBlockSize(NAME_OFFSETS);
|
||||||
SimpleLogger().Write(logDEBUG) << "NAME_CHAR_LIST " << ": " << GetBlockSize(NAME_CHAR_LIST );
|
SimpleLogger().Write(logDEBUG) << "NAME_BLOCKS "
|
||||||
SimpleLogger().Write(logDEBUG) << "NAME_ID_LIST " << ": " << GetBlockSize(NAME_ID_LIST );
|
<< ": " << GetBlockSize(NAME_BLOCKS);
|
||||||
SimpleLogger().Write(logDEBUG) << "VIA_NODE_LIST " << ": " << GetBlockSize(VIA_NODE_LIST );
|
SimpleLogger().Write(logDEBUG) << "NAME_CHAR_LIST "
|
||||||
SimpleLogger().Write(logDEBUG) << "GRAPH_NODE_LIST " << ": " << GetBlockSize(GRAPH_NODE_LIST );
|
<< ": " << GetBlockSize(NAME_CHAR_LIST);
|
||||||
SimpleLogger().Write(logDEBUG) << "GRAPH_EDGE_LIST " << ": " << GetBlockSize(GRAPH_EDGE_LIST );
|
SimpleLogger().Write(logDEBUG) << "NAME_ID_LIST "
|
||||||
SimpleLogger().Write(logDEBUG) << "COORDINATE_LIST " << ": " << GetBlockSize(COORDINATE_LIST );
|
<< ": " << GetBlockSize(NAME_ID_LIST);
|
||||||
SimpleLogger().Write(logDEBUG) << "TURN_INSTRUCTION " << ": " << GetBlockSize(TURN_INSTRUCTION );
|
SimpleLogger().Write(logDEBUG) << "VIA_NODE_LIST "
|
||||||
SimpleLogger().Write(logDEBUG) << "TRAVEL_MODE " << ": " << GetBlockSize(TRAVEL_MODE );
|
<< ": " << GetBlockSize(VIA_NODE_LIST);
|
||||||
SimpleLogger().Write(logDEBUG) << "R_SEARCH_TREE " << ": " << GetBlockSize(R_SEARCH_TREE );
|
SimpleLogger().Write(logDEBUG) << "GRAPH_NODE_LIST "
|
||||||
SimpleLogger().Write(logDEBUG) << "GEOMETRIES_INDEX " << ": " << GetBlockSize(GEOMETRIES_INDEX );
|
<< ": " << GetBlockSize(GRAPH_NODE_LIST);
|
||||||
SimpleLogger().Write(logDEBUG) << "GEOMETRIES_LIST " << ": " << GetBlockSize(GEOMETRIES_LIST );
|
SimpleLogger().Write(logDEBUG) << "GRAPH_EDGE_LIST "
|
||||||
SimpleLogger().Write(logDEBUG) << "GEOMETRIES_INDICATORS" << ": " << GetBlockSize(GEOMETRIES_INDICATORS);
|
<< ": " << GetBlockSize(GRAPH_EDGE_LIST);
|
||||||
SimpleLogger().Write(logDEBUG) << "HSGR_CHECKSUM " << ": " << GetBlockSize(HSGR_CHECKSUM );
|
SimpleLogger().Write(logDEBUG) << "COORDINATE_LIST "
|
||||||
SimpleLogger().Write(logDEBUG) << "TIMESTAMP " << ": " << GetBlockSize(TIMESTAMP );
|
<< ": " << GetBlockSize(COORDINATE_LIST);
|
||||||
SimpleLogger().Write(logDEBUG) << "FILE_INDEX_PATH " << ": " << GetBlockSize(FILE_INDEX_PATH );
|
SimpleLogger().Write(logDEBUG) << "TURN_INSTRUCTION "
|
||||||
|
<< ": " << GetBlockSize(TURN_INSTRUCTION);
|
||||||
|
SimpleLogger().Write(logDEBUG) << "TRAVEL_MODE "
|
||||||
|
<< ": " << GetBlockSize(TRAVEL_MODE);
|
||||||
|
SimpleLogger().Write(logDEBUG) << "R_SEARCH_TREE "
|
||||||
|
<< ": " << GetBlockSize(R_SEARCH_TREE);
|
||||||
|
SimpleLogger().Write(logDEBUG) << "GEOMETRIES_INDEX "
|
||||||
|
<< ": " << GetBlockSize(GEOMETRIES_INDEX);
|
||||||
|
SimpleLogger().Write(logDEBUG) << "GEOMETRIES_LIST "
|
||||||
|
<< ": " << GetBlockSize(GEOMETRIES_LIST);
|
||||||
|
SimpleLogger().Write(logDEBUG) << "GEOMETRIES_INDICATORS"
|
||||||
|
<< ": " << GetBlockSize(GEOMETRIES_INDICATORS);
|
||||||
|
SimpleLogger().Write(logDEBUG) << "HSGR_CHECKSUM "
|
||||||
|
<< ": " << GetBlockSize(HSGR_CHECKSUM);
|
||||||
|
SimpleLogger().Write(logDEBUG) << "TIMESTAMP "
|
||||||
|
<< ": " << GetBlockSize(TIMESTAMP);
|
||||||
|
SimpleLogger().Write(logDEBUG) << "FILE_INDEX_PATH "
|
||||||
|
<< ": " << GetBlockSize(FILE_INDEX_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template <typename T> inline void SetBlockSize(BlockID bid, uint64_t entries)
|
||||||
inline void SetBlockSize(BlockID bid, uint64_t entries)
|
|
||||||
{
|
{
|
||||||
num_entries[bid] = entries;
|
num_entries[bid] = entries;
|
||||||
entry_size[bid] = sizeof(T);
|
entry_size[bid] = sizeof(T);
|
||||||
@ -122,7 +153,8 @@ struct SharedDataLayout
|
|||||||
// special encoding
|
// special encoding
|
||||||
if (bid == GEOMETRIES_INDICATORS)
|
if (bid == GEOMETRIES_INDICATORS)
|
||||||
{
|
{
|
||||||
return (num_entries[GEOMETRIES_INDICATORS]/32 + 1) * entry_size[GEOMETRIES_INDICATORS];
|
return (num_entries[GEOMETRIES_INDICATORS] / 32 + 1) *
|
||||||
|
entry_size[GEOMETRIES_INDICATORS];
|
||||||
}
|
}
|
||||||
|
|
||||||
return num_entries[bid] * entry_size[bid];
|
return num_entries[bid] * entry_size[bid];
|
||||||
@ -130,7 +162,7 @@ struct SharedDataLayout
|
|||||||
|
|
||||||
inline uint64_t GetSizeOfLayout() const
|
inline uint64_t GetSizeOfLayout() const
|
||||||
{
|
{
|
||||||
return GetBlockOffset(NUM_BLOCKS) + NUM_BLOCKS*2*sizeof(CANARY);
|
return GetBlockOffset(NUM_BLOCKS) + NUM_BLOCKS * 2 * sizeof(CANARY);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline uint64_t GetBlockOffset(BlockID bid) const
|
inline uint64_t GetBlockOffset(BlockID bid) const
|
||||||
@ -138,26 +170,26 @@ struct SharedDataLayout
|
|||||||
uint64_t result = sizeof(CANARY);
|
uint64_t result = sizeof(CANARY);
|
||||||
for (auto i = 0; i < bid; i++)
|
for (auto i = 0; i < bid; i++)
|
||||||
{
|
{
|
||||||
result += GetBlockSize((BlockID) i) + 2*sizeof(CANARY);
|
result += GetBlockSize((BlockID)i) + 2 * sizeof(CANARY);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, bool WRITE_CANARY=false>
|
template <typename T, bool WRITE_CANARY = false>
|
||||||
inline T* GetBlockPtr(char* shared_memory, BlockID bid)
|
inline T *GetBlockPtr(char *shared_memory, BlockID bid)
|
||||||
{
|
{
|
||||||
T* ptr = (T*)(shared_memory + GetBlockOffset(bid));
|
T *ptr = (T *)(shared_memory + GetBlockOffset(bid));
|
||||||
if (WRITE_CANARY)
|
if (WRITE_CANARY)
|
||||||
{
|
{
|
||||||
char* start_canary_ptr = shared_memory + GetBlockOffset(bid) - sizeof(CANARY);
|
char *start_canary_ptr = shared_memory + GetBlockOffset(bid) - sizeof(CANARY);
|
||||||
char* end_canary_ptr = shared_memory + GetBlockOffset(bid) + GetBlockSize(bid);
|
char *end_canary_ptr = shared_memory + GetBlockOffset(bid) + GetBlockSize(bid);
|
||||||
std::copy(CANARY, CANARY + sizeof(CANARY), start_canary_ptr);
|
std::copy(CANARY, CANARY + sizeof(CANARY), start_canary_ptr);
|
||||||
std::copy(CANARY, CANARY + sizeof(CANARY), end_canary_ptr);
|
std::copy(CANARY, CANARY + sizeof(CANARY), end_canary_ptr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char* start_canary_ptr = shared_memory + GetBlockOffset(bid) - sizeof(CANARY);
|
char *start_canary_ptr = shared_memory + GetBlockOffset(bid) - sizeof(CANARY);
|
||||||
char* end_canary_ptr = shared_memory + GetBlockOffset(bid) + GetBlockSize(bid);
|
char *end_canary_ptr = shared_memory + GetBlockOffset(bid) + GetBlockSize(bid);
|
||||||
bool start_canary_alive = std::equal(CANARY, CANARY + sizeof(CANARY), start_canary_ptr);
|
bool start_canary_alive = std::equal(CANARY, CANARY + sizeof(CANARY), start_canary_ptr);
|
||||||
bool end_canary_alive = std::equal(CANARY, CANARY + sizeof(CANARY), end_canary_ptr);
|
bool end_canary_alive = std::equal(CANARY, CANARY + sizeof(CANARY), end_canary_ptr);
|
||||||
if (!start_canary_alive)
|
if (!start_canary_alive)
|
||||||
@ -175,13 +207,15 @@ struct SharedDataLayout
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum SharedDataType
|
enum SharedDataType
|
||||||
{ CURRENT_REGIONS,
|
{
|
||||||
LAYOUT_1,
|
CURRENT_REGIONS,
|
||||||
DATA_1,
|
LAYOUT_1,
|
||||||
LAYOUT_2,
|
DATA_1,
|
||||||
DATA_2,
|
LAYOUT_2,
|
||||||
LAYOUT_NONE,
|
DATA_2,
|
||||||
DATA_NONE };
|
LAYOUT_NONE,
|
||||||
|
DATA_NONE
|
||||||
|
};
|
||||||
|
|
||||||
struct SharedDataTimestamp
|
struct SharedDataTimestamp
|
||||||
{
|
{
|
||||||
@ -190,4 +224,4 @@ struct SharedDataTimestamp
|
|||||||
unsigned timestamp;
|
unsigned timestamp;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SHARED_DATA_TYPE_H_ */
|
#endif /* SHARED_DATA_TYPE_HPP */
|
@ -5,6 +5,6 @@ endif()
|
|||||||
file(MD5 ${SOURCE_DIR}/prepare.cpp MD5PREPARE)
|
file(MD5 ${SOURCE_DIR}/prepare.cpp MD5PREPARE)
|
||||||
file(MD5 ${SOURCE_DIR}/data_structures/static_rtree.hpp MD5RTREE)
|
file(MD5 ${SOURCE_DIR}/data_structures/static_rtree.hpp MD5RTREE)
|
||||||
file(MD5 ${SOURCE_DIR}/Util/graph_loader.hpp MD5GRAPH)
|
file(MD5 ${SOURCE_DIR}/Util/graph_loader.hpp MD5GRAPH)
|
||||||
file(MD5 ${SOURCE_DIR}/Server/DataStructures/InternalDataFacade.h MD5OBJECTS)
|
file(MD5 ${SOURCE_DIR}/server/data_structures/internal_datafacade.hpp MD5OBJECTS)
|
||||||
|
|
||||||
CONFIGURE_FILE( ${SOURCE_DIR}/Util/fingerprint.cpp.in ${SOURCE_DIR}/Util/fingerprint.cpp )
|
CONFIGURE_FILE( ${SOURCE_DIR}/Util/fingerprint.cpp.in ${SOURCE_DIR}/Util/fingerprint.cpp )
|
||||||
|
@ -33,9 +33,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include "data_structures/static_graph.hpp"
|
#include "data_structures/static_graph.hpp"
|
||||||
#include "data_structures/static_rtree.hpp"
|
#include "data_structures/static_rtree.hpp"
|
||||||
#include "data_structures/turn_instructions.hpp"
|
#include "data_structures/turn_instructions.hpp"
|
||||||
#include "Server/DataStructures/BaseDataFacade.h"
|
#include "Server/data_structures/datafacade_base.hpp"
|
||||||
#include "Server/DataStructures/SharedDataType.h"
|
#include "Server/data_structures/shared_datatype.hpp"
|
||||||
#include "Server/DataStructures/SharedBarriers.h"
|
#include "Server/data_structures/shared_barriers.hpp"
|
||||||
#include "Util/BoostFileSystemFix.h"
|
#include "Util/BoostFileSystemFix.h"
|
||||||
#include "Util/DataStoreOptions.h"
|
#include "Util/DataStoreOptions.h"
|
||||||
#include "Util/simple_logger.hpp"
|
#include "Util/simple_logger.hpp"
|
||||||
|
@ -28,7 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
#include "../data_structures/shared_memory_factory.hpp"
|
#include "../data_structures/shared_memory_factory.hpp"
|
||||||
#include "../Server/DataStructures/SharedDataType.h"
|
#include "../Server/data_structures/shared_datatype.hpp"
|
||||||
#include "../Util/git_sha.hpp"
|
#include "../Util/git_sha.hpp"
|
||||||
#include "../Util/simple_logger.hpp"
|
#include "../Util/simple_logger.hpp"
|
||||||
|
|
||||||
@ -83,8 +83,8 @@ int main()
|
|||||||
SimpleLogger().Write() << "----------------------";
|
SimpleLogger().Write() << "----------------------";
|
||||||
SimpleLogger().Write() << "This tool may put osrm-routed into an undefined state!";
|
SimpleLogger().Write() << "This tool may put osrm-routed into an undefined state!";
|
||||||
SimpleLogger().Write() << "Type 'Y' to acknowledge that you know what your are doing.";
|
SimpleLogger().Write() << "Type 'Y' to acknowledge that you know what your are doing.";
|
||||||
SimpleLogger().Write() << "\n\nDo you want to purge all shared memory allocated " <<
|
SimpleLogger().Write() << "\n\nDo you want to purge all shared memory allocated "
|
||||||
"by osrm-datastore? [type 'Y' to confirm]";
|
<< "by osrm-datastore? [type 'Y' to confirm]";
|
||||||
|
|
||||||
const auto letter = getchar();
|
const auto letter = getchar();
|
||||||
if (letter != 'Y')
|
if (letter != 'Y')
|
||||||
|
@ -27,7 +27,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
#include "../Util/git_sha.hpp"
|
#include "../Util/git_sha.hpp"
|
||||||
#include "../Util/simple_logger.hpp"
|
#include "../Util/simple_logger.hpp"
|
||||||
#include "../Server/DataStructures/SharedBarriers.h"
|
#include "../Server/data_structures/shared_barriers.hpp"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user