Use TBB parallel sort of CSV entries, #4418

This commit is contained in:
Michael Krasnyk 2017-08-17 20:02:13 +02:00
parent f4dc93ae66
commit b1358de9bb
2 changed files with 4 additions and 4 deletions

View File

@ -167,4 +167,3 @@ Feature: Traffic - speeds
And the data has been extracted And the data has been extracted
When I try to run "osrm-contract --segment-speed-file {speeds_file} {processed_file}" When I try to run "osrm-contract --segment-speed-file {speeds_file} {processed_file}"
And it should exit successfully And it should exit successfully

View File

@ -8,6 +8,7 @@
#include "util/log.hpp" #include "util/log.hpp"
#include <tbb/parallel_for.h> #include <tbb/parallel_for.h>
#include <tbb/parallel_sort.h>
#include <tbb/spin_mutex.h> #include <tbb/spin_mutex.h>
#include <boost/exception/diagnostic_information.hpp> #include <boost/exception/diagnostic_information.hpp>
@ -62,9 +63,9 @@ template <typename Key, typename Value> struct CSVFilesParser
// and unique them on key to keep only the value with the largest file index // and unique them on key to keep only the value with the largest file index
// and the largest line number in a file. // and the largest line number in a file.
// The operands order is swapped to make descending ordering on (key, source) // The operands order is swapped to make descending ordering on (key, source)
std::stable_sort(begin(lookup), end(lookup), [](const auto &lhs, const auto &rhs) { tbb::parallel_sort(begin(lookup), end(lookup), [](const auto &lhs, const auto &rhs) {
return rhs.first < lhs.first || return std::tie(rhs.first, rhs.second.source) <
(rhs.first == lhs.first && rhs.second.source < lhs.second.source); std::tie(lhs.first, lhs.second.source);
}); });
// Unique only on key to take the source precedence into account and remove duplicates. // Unique only on key to take the source precedence into account and remove duplicates.