添加数据库搜索单次数量限制。

This commit is contained in:
iaom 2021-11-11 11:44:24 +08:00
parent 83aeea4ad0
commit ba88374273
1 changed files with 22 additions and 5 deletions

View File

@ -133,9 +133,19 @@ void FileSearch::run() {
} }
SearchManager::m_mutexDir.unlock(); SearchManager::m_mutexDir.unlock();
} }
//目前的需求是文件搜索数量无上限。
//但如果不设置单次搜索数量限制在一些性能非常弱的机器上如兆芯某些机器就算我们这里不阻塞UI也会因为搜索本身占用cpu过多可能导致UI卡顿。
//可能会有更好的方法,待优化。
m_begin = 0; m_begin = 0;
m_num = -1; m_num = 100;
keywordSearchfile(); int resultCount = 1;
int totalCount = 0;
while(resultCount > 0) {
resultCount = keywordSearchfile();
m_begin += m_num;
totalCount += resultCount;
}
qDebug() << "Total count:" << m_value << totalCount;
return; return;
} }
@ -223,7 +233,6 @@ int FileSearch::getResult(Xapian::MSet &result) {
break; break;
} }
} }
// searchResult.append(path);
//qDebug() << "doc=" << path << ",weight=" << docScoreWeight << ",percent=" << docScorePercent; //qDebug() << "doc=" << path << ",weight=" << docScoreWeight << ",percent=" << docScorePercent;
} }
// if(!pathTobeDelete->isEmpty()) // if(!pathTobeDelete->isEmpty())
@ -254,9 +263,17 @@ void FileContentSearch::run() {
} }
SearchManager::m_mutexContent.unlock(); SearchManager::m_mutexContent.unlock();
//这里同文件搜索,待优化。
m_begin = 0; m_begin = 0;
m_num = -1; m_num = 100;
keywordSearchContent(); int resultCount = 1;
int totalCount = 0;
while(resultCount > 0) {
resultCount = keywordSearchContent();
m_begin += m_num;
totalCount += resultCount;
}
qDebug() << "Total count:" << totalCount;
return; return;
} }