Make DataFacade local to every request

This is the first step to having fine grained locking on data updates,
see issue #2570.
This commit is contained in:
Patrick Niklaus
2016-10-06 01:05:03 +02:00
committed by Patrick Niklaus
parent 66f2cc5184
commit 1c2ead8fb8
21 changed files with 361 additions and 291 deletions
+9 -7
View File
@@ -114,7 +114,8 @@ SCC_Component SplitUnaccessibleLocations(const std::size_t number_of_locations,
return SCC_Component(std::move(components), std::move(range));
}
InternalRouteResult TripPlugin::ComputeRoute(const std::vector<PhantomNode> &snapped_phantoms,
InternalRouteResult TripPlugin::ComputeRoute(const datafacade::BaseDataFacade& facade,
const std::vector<PhantomNode> &snapped_phantoms,
const std::vector<NodeID> &trip)
{
InternalRouteResult min_route;
@@ -134,13 +135,14 @@ InternalRouteResult TripPlugin::ComputeRoute(const std::vector<PhantomNode> &sna
}
BOOST_ASSERT(min_route.segment_end_coordinates.size() == trip.size());
shortest_path(min_route.segment_end_coordinates, {false}, min_route);
shortest_path(facade, min_route.segment_end_coordinates, {false}, min_route);
BOOST_ASSERT_MSG(min_route.shortest_path_length < INVALID_EDGE_WEIGHT, "unroutable route");
return min_route;
}
Status TripPlugin::HandleRequest(const api::TripParameters &parameters,
Status TripPlugin::HandleRequest(const std::shared_ptr<datafacade::BaseDataFacade> facade,
const api::TripParameters &parameters,
util::json::Object &json_result)
{
BOOST_ASSERT(parameters.IsValid());
@@ -157,7 +159,7 @@ Status TripPlugin::HandleRequest(const api::TripParameters &parameters,
return Error("InvalidValue", "Invalid coordinate value.", json_result);
}
auto phantom_node_pairs = GetPhantomNodes(parameters);
auto phantom_node_pairs = GetPhantomNodes(*facade, parameters);
if (phantom_node_pairs.size() != parameters.coordinates.size())
{
return Error("NoSegment",
@@ -173,7 +175,7 @@ Status TripPlugin::HandleRequest(const api::TripParameters &parameters,
// compute the duration table of all phantom nodes
const auto result_table = util::DistTableWrapper<EdgeWeight>(
duration_table(snapped_phantoms, {}, {}), number_of_locations);
duration_table(*facade, snapped_phantoms, {}, {}), number_of_locations);
if (result_table.size() == 0)
{
@@ -231,10 +233,10 @@ Status TripPlugin::HandleRequest(const api::TripParameters &parameters,
routes.reserve(trips.size());
for (const auto &trip : trips)
{
routes.push_back(ComputeRoute(snapped_phantoms, trip));
routes.push_back(ComputeRoute(*facade, snapped_phantoms, trip));
}
api::TripAPI trip_api{BasePlugin::facade, parameters};
api::TripAPI trip_api{*facade, parameters};
trip_api.MakeResponse(trips, routes, snapped_phantoms, json_result);
return Status::Ok;