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

Method ParseUserTracks

tools/track_analyzing/log_parser.cpp:111–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109}
110
111void LogParser::ParseUserTracks(string const & logFile, UserToTrack & userToTrack) const
112{
113 base::Timer timer;
114
115 std::ifstream stream(logFile);
116 if (!stream)
117 MYTHROW(MessageException, ("Can't open file", logFile, "to parse tracks"));
118
119 std::regex const base_regex(R"(.*(DataV0|CurrentData)\s+aloha_id\s*:\s*(\S+)\s+.*\|(\w+)\|)");
120 ankerl::unordered_dense::set<string> usersWithOldVersion;
121 uint64_t linesCount = 0;
122 size_t pointsCount = 0;
123
124 for (string line; getline(stream, line); ++linesCount)
125 {
126 std::smatch base_match;
127 if (!std::regex_match(line, base_match, base_regex))
128 continue;
129
130 CHECK_EQUAL(base_match.size(), 4, ());
131
132 string const version = base_match[1].str();
133 string const userId = base_match[2].str();
134 string const data = base_match[3].str();
135 if (version != "CurrentData")
136 {
137 CHECK_EQUAL(version, "DataV0", ());
138 usersWithOldVersion.insert(userId);
139 continue;
140 }
141
142 auto const packet = ReadDataPoints(data);
143 if (!packet.empty())
144 {
145 Track & track = userToTrack[userId];
146 track.insert(track.end(), packet.cbegin(), packet.cend());
147 }
148
149 pointsCount += packet.size();
150 };
151
152 LOG(LINFO, ("Tracks parsing finished, elapsed:", timer.ElapsedSeconds(), "seconds, lines:", linesCount, ", points",
153 pointsCount));
154 LOG(LINFO, ("Users with current version:", userToTrack.size(), ", old version:", usersWithOldVersion.size()));
155}
156
157void LogParser::SplitIntoMwms(UserToTrack const & userToTrack, MwmToTracks & mwmToTracks) const
158{

Callers

nothing calls this directly

Calls 8

ReadDataPointsFunction · 0.85
ElapsedSecondsMethod · 0.80
sizeMethod · 0.45
insertMethod · 0.45
emptyMethod · 0.45
endMethod · 0.45
cbeginMethod · 0.45
cendMethod · 0.45

Tested by

no test coverage detected