Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 29 additions & 23 deletions include/extractor/name_table.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef OSRM_EXTRACTOR_NAME_TABLE_HPP
#define OSRM_EXTRACTOR_NAME_TABLE_HPP
#ifndef OSRM_EXTRACTOR_STRING_TABLE_HPP
#define OSRM_EXTRACTOR_STRING_TABLE_HPP

#include "util/indexed_data.hpp"
#include "util/typedefs.hpp"
Expand All @@ -12,20 +12,20 @@ namespace osrm::extractor

namespace detail
{
template <storage::Ownership Ownership> class NameTableImpl;
template <storage::Ownership Ownership> class StringTableImpl;
} // namespace detail

namespace serialization
{
template <storage::Ownership Ownership>
inline void read(storage::tar::FileReader &reader,
const std::string &name,
detail::NameTableImpl<Ownership> &index_data);
detail::StringTableImpl<Ownership> &index_data);

template <storage::Ownership Ownership>
inline void write(storage::tar::FileWriter &writer,
const std::string &name,
const detail::NameTableImpl<Ownership> &index_data);
const detail::StringTableImpl<Ownership> &index_data);
} // namespace serialization

namespace detail
Expand All @@ -44,54 +44,54 @@ namespace detail
//
// Offset 0 is name, 1 is destination, 2 is pronunciation, 3 is ref, 4 is exits
// See datafacades and extractor callbacks for details.
template <storage::Ownership Ownership> class NameTableImpl
template <storage::Ownership Ownership> class StringTableImpl
{
public:
using IndexedData =
util::detail::IndexedDataImpl<util::VariableGroupBlock<16, std::string_view>, Ownership>;
using ResultType = typename IndexedData::ResultType;
using ValueType = typename IndexedData::ValueType;

NameTableImpl() {}
StringTableImpl() {}

NameTableImpl(IndexedData indexed_data_) : indexed_data{std::move(indexed_data_)} {}
StringTableImpl(IndexedData indexed_data_) : indexed_data{std::move(indexed_data_)} {}

std::string_view GetNameForID(const NameID id) const
std::string_view GetNameForID(const StringViewID id) const
{
if (id == INVALID_NAMEID)
if (id == INVALID_STRINGVIEWID)
return {};

return indexed_data.at(id + 0);
}

std::string_view GetDestinationsForID(const NameID id) const
std::string_view GetDestinationsForID(const StringViewID id) const
{
if (id == INVALID_NAMEID)
if (id == INVALID_STRINGVIEWID)
return {};

return indexed_data.at(id + 1);
}

std::string_view GetExitsForID(const NameID id) const
std::string_view GetExitsForID(const StringViewID id) const
{
if (id == INVALID_NAMEID)
if (id == INVALID_STRINGVIEWID)
return {};

return indexed_data.at(id + 4);
}

std::string_view GetRefForID(const NameID id) const
std::string_view GetRefForID(const StringViewID id) const
{
if (id == INVALID_NAMEID)
if (id == INVALID_STRINGVIEWID)
return {};

const constexpr auto OFFSET_REF = 3u;
return indexed_data.at(id + OFFSET_REF);
}

std::string_view GetPronunciationForID(const NameID id) const
std::string_view GetPronunciationForID(const StringViewID id) const
{
if (id == INVALID_NAMEID)
if (id == INVALID_STRINGVIEWID)
return {};

const constexpr auto OFFSET_PRONUNCIATION = 2u;
Expand All @@ -100,19 +100,25 @@ template <storage::Ownership Ownership> class NameTableImpl

friend void serialization::read<Ownership>(storage::tar::FileReader &reader,
const std::string &name,
NameTableImpl &index_data);
StringTableImpl &index_data);

friend void serialization::write<Ownership>(storage::tar::FileWriter &writer,
const std::string &name,
const NameTableImpl &index_data);
const StringTableImpl &index_data);

private:
IndexedData indexed_data;
};
} // namespace detail

using NameTable = detail::NameTableImpl<storage::Ownership::Container>;
using NameTableView = detail::NameTableImpl<storage::Ownership::View>;
using StringTable = detail::StringTableImpl<storage::Ownership::Container>;
using StringTableView = detail::StringTableImpl<storage::Ownership::View>;

// Backwards compatibility aliases (deprecated)
using NameTable = StringTable;
using NameTableView = StringTableView;
using PreDatafacadeStringViewer = StringTable;
using PreDatafacadeStringViewerView = StringTableView;
} // namespace osrm::extractor

#endif // OSRM_EXTRACTOR_NAME_TABLE_HPP
#endif // OSRM_EXTRACTOR_STRING_TABLE_HPP
24 changes: 14 additions & 10 deletions include/extractor/node_based_edge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,27 +65,31 @@ struct NodeBasedEdgeClassification
// see as part of the API output but that does not influence navigation
struct NodeBasedEdgeAnnotation
{
NameID name_id; // 32 4
StringViewID string_view_id; // 32 4
LaneDescriptionID lane_description_id; // 16 2
ClassData classes; // 8 1
TravelMode travel_mode : 4; // 4
bool is_left_hand_driving : 1; // 1

bool CanCombineWith(const NodeBasedEdgeAnnotation &other) const
{
return (
std::tie(name_id, classes, travel_mode, is_left_hand_driving) ==
std::tie(other.name_id, other.classes, other.travel_mode, other.is_left_hand_driving));
return (std::tie(string_view_id, classes, travel_mode, is_left_hand_driving) ==
std::tie(other.string_view_id,
other.classes,
other.travel_mode,
other.is_left_hand_driving));
}

bool operator<(const NodeBasedEdgeAnnotation &other) const
{
return (std::tie(name_id, lane_description_id, classes, travel_mode, is_left_hand_driving) <
std::tie(other.name_id,
other.lane_description_id,
other.classes,
other.travel_mode,
other.is_left_hand_driving));
return (
std::tie(
string_view_id, lane_description_id, classes, travel_mode, is_left_hand_driving) <
std::tie(other.string_view_id,
other.lane_description_id,
other.classes,
other.travel_mode,
other.is_left_hand_driving));
}
};

Expand Down
13 changes: 10 additions & 3 deletions include/util/typedefs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,13 @@ static const OSMWayID MIN_OSM_WAYID = OSMWayID{std::numeric_limits<OSMWayID::val

using NodeID = std::uint32_t;
using EdgeID = std::uint32_t;
using NameID = std::uint32_t;
using StringViewID = std::uint32_t;
using AnnotationID = std::uint32_t;
using PackedGeometryID = std::uint32_t;

// Backwards compatibility aliases (deprecated)
using NameID = StringViewID;

using EdgeWeight = osrm::Alias<std::int32_t, tag::edge_weight>;
using EdgeDuration = osrm::Alias<std::int32_t, tag::edge_duration>;
using EdgeDistance = osrm::Alias<float, tag::edge_distance>;
Expand Down Expand Up @@ -128,9 +131,13 @@ static const PackedGeometryID SPECIAL_GEOMETRYID =
std::numeric_limits<PackedGeometryID>::max() >> 1;
static const EdgeID SPECIAL_EDGEID = std::numeric_limits<EdgeID>::max();
static const RestrictionID SPECIAL_RESTRICTIONID = std::numeric_limits<RestrictionID>::max();
static const NameID INVALID_NAMEID = std::numeric_limits<NameID>::max();
static const NameID EMPTY_NAMEID = 0;
static const StringViewID INVALID_STRINGVIEWID = std::numeric_limits<StringViewID>::max();
static const StringViewID EMPTY_STRINGVIEWID = 0;
static const unsigned INVALID_COMPONENTID = 0;

// Backwards compatibility aliases (deprecated)
static const auto INVALID_NAMEID = INVALID_STRINGVIEWID;
static const auto EMPTY_NAMEID = EMPTY_STRINGVIEWID;
static const std::size_t SEGMENT_WEIGHT_BITS = 22;
static const std::size_t SEGMENT_DURATION_BITS = 22;
static const SegmentWeight INVALID_SEGMENT_WEIGHT = SegmentWeight{(1u << SEGMENT_WEIGHT_BITS) - 1};
Expand Down
Loading