commit
16bc944406
|
@ -26,6 +26,8 @@
|
|||
//#define DELETE_QUEUE(a )
|
||||
using namespace Zeeker;
|
||||
FirstIndex::FirstIndex() {
|
||||
m_pool.setMaxThreadCount(2);
|
||||
m_pool.setExpiryTimeout(100);
|
||||
}
|
||||
|
||||
FirstIndex::~FirstIndex() {
|
||||
|
@ -177,6 +179,7 @@ void FirstIndex::run() {
|
|||
p_indexGenerator = IndexGenerator::getInstance(true, this);
|
||||
|
||||
}
|
||||
//TODO Fix these weird code.
|
||||
QSemaphore sem(5);
|
||||
QMutex mutex1, mutex2, mutex3;
|
||||
mutex1.lock();
|
||||
|
@ -192,42 +195,41 @@ void FirstIndex::run() {
|
|||
qDebug() << "max_index_count:" << FileUtils::_max_index_count;
|
||||
sem.release(5);
|
||||
// });
|
||||
QtConcurrent::run([&]() {
|
||||
QtConcurrent::run(&m_pool, [&]() {
|
||||
sem.acquire(2);
|
||||
mutex2.unlock();
|
||||
qDebug() << "index start;";
|
||||
QQueue<QVector<QString>>* tmp = new QQueue<QVector<QString>>();
|
||||
QQueue<QVector<QString>>* tmp1 = new QQueue<QVector<QString>>();
|
||||
while(!this->q_index->empty()) {
|
||||
for(size_t i = 0; (i < 8192) && (!this->q_index->empty()); ++i) {
|
||||
tmp->enqueue(this->q_index->dequeue());
|
||||
tmp1->enqueue(this->q_index->dequeue());
|
||||
}
|
||||
this->p_indexGenerator->creatAllIndex(tmp);
|
||||
tmp->clear();
|
||||
this->p_indexGenerator->creatAllIndex(tmp1);
|
||||
tmp1->clear();
|
||||
}
|
||||
// this->p_indexGenerator->setSynonym();
|
||||
delete tmp;
|
||||
delete tmp1;
|
||||
qDebug() << "index end;";
|
||||
sem.release(2);
|
||||
});
|
||||
QtConcurrent::run([&]() {
|
||||
QtConcurrent::run(&m_pool,[&]() {
|
||||
sem.acquire(2);
|
||||
mutex3.unlock();
|
||||
QQueue<QString>* tmp = new QQueue<QString>();
|
||||
QQueue<QString>* tmp2 = new QQueue<QString>();
|
||||
qDebug() << "q_content_index:" << q_content_index->size();
|
||||
while(!this->q_content_index->empty()) {
|
||||
// for (size_t i = 0; (i < this->u_send_length) && (!this->q_content_index->empty()); ++i){
|
||||
// for (size_t i = 0; (i < this->u_send_length) && (!this->q_content_index->empty()); ++i){
|
||||
qint64 fileSize = 0;
|
||||
//修改一次处理的数据量,从30个文件改为文件总大小为50M以下,50M为暂定值--jxx20210519
|
||||
for(size_t i = 0;/* (i < 30) && */(fileSize < 50*1024*1024) && (!this->q_content_index->empty()); ++i) {
|
||||
QPair<QString,qint64> tempPair = this->q_content_index->dequeue();
|
||||
fileSize += tempPair.second;
|
||||
tmp->enqueue(tempPair.first);
|
||||
tmp2->enqueue(tempPair.first);
|
||||
}
|
||||
// qDebug() << ">>>>>>>>all fileSize:" << fileSize << "file num:" << tmp->size() << "<<<<<<<<<<<<<<<<<<<";
|
||||
this->p_indexGenerator->creatAllIndex(tmp);
|
||||
tmp->clear();
|
||||
// qDebug() << ">>>>>>>>all fileSize:" << fileSize << "file num:" << tmp->size() << "<<<<<<<<<<<<<<<<<<<";
|
||||
this->p_indexGenerator->creatAllIndex(tmp2);
|
||||
tmp2->clear();
|
||||
}
|
||||
delete tmp;
|
||||
delete tmp2;
|
||||
qDebug() << "content index end;";
|
||||
sem.release(2);
|
||||
});
|
||||
|
|
|
@ -56,6 +56,7 @@ private:
|
|||
bool bool_dataBaseStatusOK = false;
|
||||
bool bool_dataBaseExist = false;
|
||||
IndexGenerator* p_indexGenerator = nullptr;
|
||||
QThreadPool m_pool;
|
||||
|
||||
//here should be refact
|
||||
// MessageListManager* mlm;
|
||||
|
|
|
@ -314,7 +314,7 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
// TODO
|
||||
// Set threads which in global thread pool expiry time in 5ms, some prolems here
|
||||
QThreadPool::globalInstance()->setExpiryTimeout(5);
|
||||
// QThreadPool::globalInstance()->setExpiryTimeout(5);
|
||||
|
||||
// TODO
|
||||
// First insdex start, the parameter us useless, should remove the parameter
|
||||
|
|
|
@ -271,16 +271,7 @@ void MainWindow::initUi() {
|
|||
} else {
|
||||
m_contentFrame->setCurrentIndex(1);
|
||||
QTimer::singleShot(10, this, [ = ]() {
|
||||
m_search_result_file->clear();
|
||||
m_search_result_dir->clear();
|
||||
m_search_result_content->clear();
|
||||
if(! m_search_result_thread->isRunning()) {
|
||||
m_search_result_thread->start();
|
||||
}
|
||||
startSearch(text);
|
||||
//允许弹窗且当前次搜索(为关闭主界面,算一次搜索过程)未询问且当前为暴力搜索
|
||||
if(GlobalSettings::getInstance()->getValue(ENABLE_CREATE_INDEX_ASK_DIALOG).toString() != "false" && !m_currentSearchAsked && FileUtils::searchMethod == FileUtils::SearchMethod::DIRECTSEARCH)
|
||||
m_askTimer->start();
|
||||
});
|
||||
}
|
||||
m_researchTimer->stop(); //如果搜索内容发生改变,则停止建索引后重新搜索的倒计时
|
||||
|
@ -383,8 +374,21 @@ void MainWindow::primaryScreenChangedSlot(QScreen *screen) {
|
|||
* @param keyword
|
||||
*/
|
||||
void MainWindow::startSearch(QString keyword) {
|
||||
m_search_result_file->clear();
|
||||
m_search_result_dir->clear();
|
||||
m_search_result_content->clear();
|
||||
if(! m_search_result_thread->isRunning()) {
|
||||
m_search_result_thread->start();
|
||||
}
|
||||
//允许弹窗且当前次搜索(为关闭主界面,算一次搜索过程)未询问且当前为暴力搜索
|
||||
if(GlobalSettings::getInstance()->getValue(ENABLE_CREATE_INDEX_ASK_DIALOG).toString() != "false" && !m_currentSearchAsked && FileUtils::searchMethod == FileUtils::SearchMethod::DIRECTSEARCH)
|
||||
m_askTimer->start();
|
||||
|
||||
m_contentFrame->setKeyword(keyword);
|
||||
|
||||
//文件、文件夹、内容搜索
|
||||
this->m_searcher->onKeywordSearch(keyword, m_search_result_file, m_search_result_dir, m_search_result_content);
|
||||
|
||||
//设置搜索
|
||||
QStringList settingList;
|
||||
settingList = m_settingsMatch->startMatchApp(keyword);
|
||||
|
@ -394,9 +398,6 @@ void MainWindow::startSearch(QString keyword) {
|
|||
//应用搜索
|
||||
// m_seach_app_thread->stop();
|
||||
m_seach_app_thread->startSearch(keyword);
|
||||
|
||||
//文件、文件夹、内容搜索
|
||||
this->m_searcher->onKeywordSearch(keyword, m_search_result_file, m_search_result_dir, m_search_result_content);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue