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

Method Decode

tools/openlr/openlr_decoder.cpp:453–498  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

451
452template <typename Decoder, typename Stats>
453void OpenLRDecoder::Decode(vector<LinearSegment> const & segments, uint32_t const numThreads,
454 vector<DecodedPath> & paths)
455{
456 auto const worker = [&](size_t threadNum, DataSource & dataSource, Stats & stat)
457 {
458 size_t constexpr kBatchSize = GetOptimalBatchSize();
459 size_t constexpr kProgressFrequency = 100;
460
461 size_t const numSegments = segments.size();
462
463 Decoder decoder(dataSource, make_unique<CarModelFactory>(m_countryParentNameGetter));
464 base::Timer timer;
465 for (size_t i = threadNum * kBatchSize; i < numSegments; i += numThreads * kBatchSize)
466 {
467 for (size_t j = i; j < numSegments && j < i + kBatchSize; ++j)
468 {
469 if (!decoder.DecodeSegment(segments[j], paths[j], stat))
470 ++stat.m_routesFailed;
471 ++stat.m_routesHandled;
472
473 if (stat.m_routesHandled % kProgressFrequency == 0 || i == segments.size() - 1)
474 {
475 LOG(LINFO, ("Thread", threadNum, "processed", stat.m_routesHandled, "failed:", stat.m_routesFailed));
476 timer.Reset();
477 }
478 }
479 }
480 };
481
482 base::Timer timer;
483 vector<Stats> stats(numThreads);
484 vector<thread> workers;
485 for (size_t i = 1; i < numThreads; ++i)
486 workers.emplace_back(worker, i, ref(m_dataSources[i]), ref(stats[i]));
487
488 worker(0 /* threadNum */, m_dataSources[0], stats[0]);
489 for (auto & worker : workers)
490 worker.join();
491
492 Stats allStats;
493 for (auto const & s : stats)
494 allStats.Add(s);
495
496 allStats.Report();
497 LOG(LINFO, ("Matching tool:", timer.ElapsedSeconds(), "seconds."));
498}
499} // namespace openlr

Callers

nothing calls this directly

Calls 9

GetOptimalBatchSizeFunction · 0.85
ElapsedSecondsMethod · 0.80
sizeMethod · 0.45
DecodeSegmentMethod · 0.45
ResetMethod · 0.45
emplace_backMethod · 0.45
joinMethod · 0.45
AddMethod · 0.45
ReportMethod · 0.45

Tested by

no test coverage detected