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

Method ParseUserTracksFromFile

tools/track_analyzing/track_archive_reader.cpp:285–325  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

283} // namespace details
284
285void TrackArchiveReader::ParseUserTracksFromFile(string const & logFile, UserToTrack & userToTrack) const
286{
287 // Read file content
288 FileReader reader(logFile);
289 string archiveData;
290 reader.ReadAsString(archiveData);
291
292 // Unzip data
293 using Inflate = coding::ZLib::Inflate;
294 Inflate inflate(Inflate::Format::GZip);
295 string logData;
296 inflate(archiveData.data(), archiveData.size(), back_inserter(logData));
297
298 // Parse log
299 TemporaryFile tmpArchiveFile("" /* empty prefix */, kTmpArchiveFileNameTemplate);
300 stringstream logParser;
301 logParser << logData;
302
303 size_t linesCount = 0;
304 size_t errorsCount = 0;
305 for (string line; getline(logParser, line); ++linesCount)
306 {
307 optional<details::UserTrackInfo> data = details::ParseLogRecord(line, tmpArchiveFile);
308
309 if (data)
310 {
311 Track & track = userToTrack[data->m_userId];
312 track.insert(track.end(), data->m_track.cbegin(), data->m_track.cend());
313 }
314 else
315 {
316 ++errorsCount;
317 }
318 }
319
320 LOG(LINFO, ("Process", linesCount, "log records"));
321 if (errorsCount == 0)
322 LOG(LINFO, ("All records are parsed successfully"));
323 else
324 LOG(LERROR, ("Unable to parse", errorsCount, "records"));
325}
326} // namespace track_analyzing

Callers

nothing calls this directly

Calls 8

ParseLogRecordFunction · 0.85
ReadAsStringMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
insertMethod · 0.45
endMethod · 0.45
cbeginMethod · 0.45
cendMethod · 0.45

Tested by

no test coverage detected