logic: improved performance of initializing the fulltext search index

* implemented using multithreaing for building the fulltext search index
* also: decreased ideal thread count by 1 to keep the machine responsive while indexing and building the index
This commit is contained in:
mlangkabel
2018-04-10 12:40:51 +02:00
parent 7dde56ea6a
commit 835aedd669
6 changed files with 74 additions and 45 deletions
+24
View File
@@ -28,6 +28,9 @@ namespace utility
std::string timeToString(const boost::posix_time::ptime time);
std::string timeToString(float seconds);
template<typename T>
std::vector<std::vector<T>> splitToEqualySizedParts(const std::vector<T>& values, const size_t desiredPartCount);
template<typename T>
std::vector<T> concat(const std::vector<T>& a, const std::vector<T>& b);
@@ -128,6 +131,27 @@ namespace utility
int roundToInt(float n);
}
template<typename T>
std::vector<std::vector<T>> utility::splitToEqualySizedParts(const std::vector<T>& values, const size_t desiredPartCount)
{
const size_t partCount = std::max<size_t>(1, std::min(desiredPartCount, values.size()));
std::vector<std::vector<T>> parts;
for (size_t i = 0; i < partCount; i++)
{
parts.push_back(std::vector<T>());
}
int i = 0;
for (const T& value : values)
{
parts[i % partCount].push_back(value);
++i;
}
return parts;
}
template<typename T>
std::vector<T> utility::concat(const std::vector<T>& a, const std::vector<T>& b)
{