fix loading in storage
This commit is contained in:
parent
44b841a25d
commit
98fe0badbe
@ -56,7 +56,10 @@ void print(const std::vector<RouteStep> &steps)
|
|||||||
{
|
{
|
||||||
std::cout << "(" << intersection.duration << " " << intersection.distance << " "
|
std::cout << "(" << intersection.duration << " " << intersection.distance << " "
|
||||||
<< " Bearings: " << intersection.bearing_before << " "
|
<< " Bearings: " << intersection.bearing_before << " "
|
||||||
<< intersection.bearing_after << ")";
|
<< intersection.bearing_after << " -- ";
|
||||||
|
for( auto bearing : intersection.bearing_class.getAvailableBearings() )
|
||||||
|
std:: cout << " " << bearing;
|
||||||
|
std::cout << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "] name[" << step.name_id << "]: " << step.name << std::endl;
|
std::cout << "] name[" << step.name_id << "]: " << step.name << std::endl;
|
||||||
@ -430,7 +433,6 @@ std::vector<RouteStep> removeNoTurnInstructions(std::vector<RouteStep> steps)
|
|||||||
};
|
};
|
||||||
|
|
||||||
boost::remove_erase_if(steps, not_is_valid);
|
boost::remove_erase_if(steps, not_is_valid);
|
||||||
|
|
||||||
return steps;
|
return steps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,7 +324,8 @@ int Storage::Run()
|
|||||||
|
|
||||||
std::vector<BearingClassID> bearing_class_id_table;
|
std::vector<BearingClassID> bearing_class_id_table;
|
||||||
if (!util::deserializeVector(intersection_stream, bearing_class_id_table))
|
if (!util::deserializeVector(intersection_stream, bearing_class_id_table))
|
||||||
throw util::exception("Failed to read from " + config.names_data_path.string());
|
throw util::exception("Failed to bearing class ids read from " +
|
||||||
|
config.names_data_path.string());
|
||||||
|
|
||||||
shared_layout_ptr->SetBlockSize<BearingClassID>(SharedDataLayout::BEARING_CLASSID,
|
shared_layout_ptr->SetBlockSize<BearingClassID>(SharedDataLayout::BEARING_CLASSID,
|
||||||
bearing_class_id_table.size());
|
bearing_class_id_table.size());
|
||||||
@ -338,19 +339,18 @@ int Storage::Run()
|
|||||||
SharedDataLayout::BEARING_BLOCKS, bearing_blocks);
|
SharedDataLayout::BEARING_BLOCKS, bearing_blocks);
|
||||||
|
|
||||||
std::vector<unsigned> bearing_offsets_data(bearing_blocks);
|
std::vector<unsigned> bearing_offsets_data(bearing_blocks);
|
||||||
std::vector<unsigned> bearing_blocks_data(bearing_blocks);
|
std::vector<typename util::RangeTable<16, true>::BlockT> bearing_blocks_data(bearing_blocks);
|
||||||
|
|
||||||
if (bearing_blocks)
|
if (bearing_blocks)
|
||||||
{
|
{
|
||||||
intersection_stream.read(
|
intersection_stream.read(reinterpret_cast<char *>(&bearing_offsets_data[0]),
|
||||||
reinterpret_cast<char *>(&bearing_offsets_data[0]),
|
bearing_blocks * sizeof(bearing_offsets_data[0]));
|
||||||
shared_layout_ptr->GetBlockSize(SharedDataLayout::BEARING_OFFSETS));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bearing_blocks)
|
if (bearing_blocks)
|
||||||
{
|
{
|
||||||
intersection_stream.read(reinterpret_cast<char *>(&bearing_blocks_data[0]),
|
intersection_stream.read(reinterpret_cast<char *>(&bearing_blocks_data[0]),
|
||||||
shared_layout_ptr->GetBlockSize(SharedDataLayout::BEARING_BLOCKS));
|
bearing_blocks * sizeof(bearing_blocks_data[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uint64_t num_bearings;
|
std::uint64_t num_bearings;
|
||||||
@ -362,11 +362,13 @@ int Storage::Run()
|
|||||||
shared_layout_ptr->SetBlockSize<DiscreteBearing>(SharedDataLayout::BEARING_VALUES,
|
shared_layout_ptr->SetBlockSize<DiscreteBearing>(SharedDataLayout::BEARING_VALUES,
|
||||||
num_bearings);
|
num_bearings);
|
||||||
if (!static_cast<bool>(intersection_stream))
|
if (!static_cast<bool>(intersection_stream))
|
||||||
throw util::exception("Failed to read from " + config.names_data_path.string());
|
throw util::exception("Failed to read bearing values from " +
|
||||||
|
config.intersection_class_path.string());
|
||||||
|
|
||||||
std::vector<util::guidance::EntryClass> entry_class_table;
|
std::vector<util::guidance::EntryClass> entry_class_table;
|
||||||
if (!util::deserializeVector(intersection_stream, entry_class_table))
|
if (!util::deserializeVector(intersection_stream, entry_class_table))
|
||||||
throw util::exception("Failed to read from " + config.names_data_path.string());
|
throw util::exception("Failed to read entry classes from " +
|
||||||
|
config.intersection_class_path.string());
|
||||||
|
|
||||||
shared_layout_ptr->SetBlockSize<util::guidance::EntryClass>(SharedDataLayout::ENTRY_CLASS,
|
shared_layout_ptr->SetBlockSize<util::guidance::EntryClass>(SharedDataLayout::ENTRY_CLASS,
|
||||||
entry_class_table.size());
|
entry_class_table.size());
|
||||||
@ -615,21 +617,6 @@ int Storage::Run()
|
|||||||
profile_properties_stream.read(reinterpret_cast<char *>(profile_properties_ptr),
|
profile_properties_stream.read(reinterpret_cast<char *>(profile_properties_ptr),
|
||||||
sizeof(extractor::ProfileProperties));
|
sizeof(extractor::ProfileProperties));
|
||||||
|
|
||||||
// acquire lock
|
|
||||||
SharedMemory *data_type_memory =
|
|
||||||
makeSharedMemory(CURRENT_REGIONS, sizeof(SharedDataTimestamp), true, false);
|
|
||||||
SharedDataTimestamp *data_timestamp_ptr =
|
|
||||||
static_cast<SharedDataTimestamp *>(data_type_memory->Ptr());
|
|
||||||
|
|
||||||
boost::interprocess::scoped_lock<boost::interprocess::named_mutex> query_lock(
|
|
||||||
barrier.query_mutex);
|
|
||||||
|
|
||||||
// notify all processes that were waiting for this condition
|
|
||||||
if (0 < barrier.number_of_queries)
|
|
||||||
{
|
|
||||||
barrier.no_running_queries_condition.wait(query_lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
// load intersection classes
|
// load intersection classes
|
||||||
if (!bearing_class_id_table.empty())
|
if (!bearing_class_id_table.empty())
|
||||||
{
|
{
|
||||||
@ -640,15 +627,15 @@ int Storage::Run()
|
|||||||
|
|
||||||
if (shared_layout_ptr->GetBlockSize(SharedDataLayout::BEARING_OFFSETS) > 0)
|
if (shared_layout_ptr->GetBlockSize(SharedDataLayout::BEARING_OFFSETS) > 0)
|
||||||
{
|
{
|
||||||
unsigned *bearing_offsets_ptr = shared_layout_ptr->GetBlockPtr<unsigned, true>(
|
auto *bearing_offsets_ptr = shared_layout_ptr->GetBlockPtr<unsigned, true>(
|
||||||
shared_memory_ptr, SharedDataLayout::BEARING_OFFSETS);
|
shared_memory_ptr, SharedDataLayout::BEARING_OFFSETS);
|
||||||
std::copy(bearing_offsets_data.begin(), bearing_offsets_data.end(),
|
std::copy(bearing_offsets_data.begin(), bearing_offsets_data.end(), bearing_offsets_ptr);
|
||||||
bearing_offsets_ptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shared_layout_ptr->GetBlockSize(SharedDataLayout::BEARING_BLOCKS) > 0)
|
if (shared_layout_ptr->GetBlockSize(SharedDataLayout::BEARING_BLOCKS) > 0)
|
||||||
{
|
{
|
||||||
unsigned *bearing_blocks_ptr = shared_layout_ptr->GetBlockPtr<unsigned, true>(
|
auto *bearing_blocks_ptr =
|
||||||
|
shared_layout_ptr->GetBlockPtr<typename util::RangeTable<16, true>::BlockT, true>(
|
||||||
shared_memory_ptr, SharedDataLayout::BEARING_BLOCKS);
|
shared_memory_ptr, SharedDataLayout::BEARING_BLOCKS);
|
||||||
std::copy(bearing_blocks_data.begin(), bearing_blocks_data.end(), bearing_blocks_ptr);
|
std::copy(bearing_blocks_data.begin(), bearing_blocks_data.end(), bearing_blocks_ptr);
|
||||||
}
|
}
|
||||||
@ -667,6 +654,21 @@ int Storage::Run()
|
|||||||
std::copy(entry_class_table.begin(), entry_class_table.end(), entry_class_ptr);
|
std::copy(entry_class_table.begin(), entry_class_table.end(), entry_class_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// acquire lock
|
||||||
|
SharedMemory *data_type_memory =
|
||||||
|
makeSharedMemory(CURRENT_REGIONS, sizeof(SharedDataTimestamp), true, false);
|
||||||
|
SharedDataTimestamp *data_timestamp_ptr =
|
||||||
|
static_cast<SharedDataTimestamp *>(data_type_memory->Ptr());
|
||||||
|
|
||||||
|
boost::interprocess::scoped_lock<boost::interprocess::named_mutex> query_lock(
|
||||||
|
barrier.query_mutex);
|
||||||
|
|
||||||
|
// notify all processes that were waiting for this condition
|
||||||
|
if (0 < barrier.number_of_queries)
|
||||||
|
{
|
||||||
|
barrier.no_running_queries_condition.wait(query_lock);
|
||||||
|
}
|
||||||
|
|
||||||
data_timestamp_ptr->layout = layout_region;
|
data_timestamp_ptr->layout = layout_region;
|
||||||
data_timestamp_ptr->data = data_region;
|
data_timestamp_ptr->data = data_region;
|
||||||
data_timestamp_ptr->timestamp += 1;
|
data_timestamp_ptr->timestamp += 1;
|
||||||
|
@ -65,6 +65,7 @@ DiscreteBearing BearingClass::getDiscreteBearing(const double bearing)
|
|||||||
|
|
||||||
std::size_t BearingClass::findMatchingBearing(const double bearing) const
|
std::size_t BearingClass::findMatchingBearing(const double bearing) const
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(!available_bearings.empty());
|
||||||
// the small size of the intersections allows a linear compare
|
// the small size of the intersections allows a linear compare
|
||||||
auto discrete_bearing = static_cast<DiscreteBearing>(bearing);
|
auto discrete_bearing = static_cast<DiscreteBearing>(bearing);
|
||||||
auto max_element =
|
auto max_element =
|
||||||
|
Loading…
Reference in New Issue
Block a user