MCPcopy Create free account
hub / github.com/comaps/comaps / Serialize

Method Serialize

libs/routing/city_roads_serialization.hpp:52–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50
51 template <typename Sink>
52 static void Serialize(Sink & sink, std::vector<uint32_t> && cityRoadFeatureIds)
53 {
54 CityRoadsHeader header;
55 auto const startOffset = sink.Pos();
56 header.Serialize(sink);
57
58 std::sort(cityRoadFeatureIds.begin(), cityRoadFeatureIds.end());
59 CHECK(adjacent_find(cityRoadFeatureIds.cbegin(), cityRoadFeatureIds.cend()) == cityRoadFeatureIds.cend(),
60 ("City road feature ids should be unique."));
61 succinct::elias_fano::elias_fano_builder builder(cityRoadFeatureIds.back() + 1, cityRoadFeatureIds.size());
62 for (auto fid : cityRoadFeatureIds)
63 builder.push_back(fid);
64
65 coding::FreezeVisitor<Writer> visitor(sink);
66 succinct::elias_fano(&builder).map(visitor);
67
68 auto const endOffset = sink.Pos();
69 header.m_dataSize = static_cast<uint32_t>(endOffset - startOffset - sizeof(CityRoadsHeader));
70
71 sink.Seek(startOffset);
72 header.Serialize(sink);
73 sink.Seek(endOffset);
74
75 LOG(LINFO, ("Serialized", cityRoadFeatureIds.size(), "road feature ids in cities. Size:", endOffset - startOffset,
76 "bytes."));
77 }
78
79 template <typename Source>
80 static void Deserialize(Source & src, std::unique_ptr<CopiedMemoryRegion> & cityRoadsRegion,

Callers

nothing calls this directly

Calls 12

elias_fanoClass · 0.85
backMethod · 0.80
PosMethod · 0.45
SerializeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
cbeginMethod · 0.45
cendMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45
mapMethod · 0.45
SeekMethod · 0.45

Tested by

no test coverage detected