From 8e42f281456cd681ed475a09cb3f309e2b88415a Mon Sep 17 00:00:00 2001 From: zhangzihao Date: Wed, 20 Jan 2021 17:14:14 +0800 Subject: [PATCH] change position of index status from index-generator to first-index and inotify-index. --- libchinese-segmentation/chinese-segmentation.cpp | 4 ++++ libsearch/index/first-index.cpp | 2 ++ libsearch/index/index-generator.cpp | 2 -- libsearch/index/inotify-index.cpp | 2 ++ libsearch/index/inotify-index.h | 1 + 5 files changed, 9 insertions(+), 2 deletions(-) diff --git a/libchinese-segmentation/chinese-segmentation.cpp b/libchinese-segmentation/chinese-segmentation.cpp index 60788c4..efbb8c8 100644 --- a/libchinese-segmentation/chinese-segmentation.cpp +++ b/libchinese-segmentation/chinese-segmentation.cpp @@ -46,6 +46,10 @@ QVector ChineseSegmentation::callSegement(QString& str) QVector vecNeeds; convert(keywordres, vecNeeds); + keywordres.clear(); + keywordres.shrink_to_fit(); + + return vecNeeds; } diff --git a/libsearch/index/first-index.cpp b/libsearch/index/first-index.cpp index bac677d..7feb60a 100644 --- a/libsearch/index/first-index.cpp +++ b/libsearch/index/first-index.cpp @@ -107,6 +107,7 @@ void FirstIndex::run(){ // this->p_indexGenerator->creatAllIndex(this->q_content_index); + FileUtils::_index_status = CREATING_INDEX; QSemaphore sem(5); QMutex mutex1, mutex2, mutex3; mutex1.lock(); @@ -168,6 +169,7 @@ void FirstIndex::run(){ + FileUtils::_index_status = FINISH_CREATING_INDEX; qDebug() << "sigset start!"; sigset( SIGTERM, handler); qDebug() << "sigset end!"; diff --git a/libsearch/index/index-generator.cpp b/libsearch/index/index-generator.cpp index 8049e07..96c60a8 100644 --- a/libsearch/index/index-generator.cpp +++ b/libsearch/index/index-generator.cpp @@ -77,7 +77,6 @@ bool IndexGenerator::creatAllIndex(QQueue > *messageList) //文件内容索引 bool IndexGenerator::creatAllIndex(QQueue *messageList) { - FileUtils::_index_status = CREATING_INDEX; HandlePathList(messageList); int size = _doc_list_content->size(); if(!size == 0) @@ -105,7 +104,6 @@ bool IndexGenerator::creatAllIndex(QQueue *messageList) _doc_list_content = nullptr; } Q_EMIT this->transactionFinished(); - FileUtils::_index_status = FINISH_CREATING_INDEX; return true; } diff --git a/libsearch/index/inotify-index.cpp b/libsearch/index/inotify-index.cpp index 45d8aa5..642aa14 100644 --- a/libsearch/index/inotify-index.cpp +++ b/libsearch/index/inotify-index.cpp @@ -121,6 +121,7 @@ void InotifyIndex::run(){ // qDebug() << "Read Event: " << currentPath[event->wd] << QString(event->name) << event->cookie << event->wd << event->mask; if(event->name[0] != '.'){ qDebug() << QString(currentPath[event->wd] + '/' + event->name); + FileUtils::_index_status = CREATING_INDEX; // switch (event->mask) { if (event->mask & IN_CREATE){ @@ -266,6 +267,7 @@ void InotifyIndex::run(){ // } // } /*--------------------------------*/ + FileUtils::_index_status = FINISH_CREATING_INDEX; } next: p += sizeof(struct inotify_event) + event->len; diff --git a/libsearch/index/inotify-index.h b/libsearch/index/inotify-index.h index 32363aa..0ffa24b 100644 --- a/libsearch/index/inotify-index.h +++ b/libsearch/index/inotify-index.h @@ -8,6 +8,7 @@ #include "traverse_bfs.h" #include "ukui-search-qdbus.h" #include "global-settings.h" +#include "file-utils.h" #define BUF_LEN 1024 class InotifyIndex;