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:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user