Add function of querying current index count.

This commit is contained in:
zhangpengfei 2021-01-15 09:14:25 +08:00
parent 8e0acf3d01
commit 0a1f1f7b69
4 changed files with 11 additions and 7 deletions

View File

@ -33,7 +33,7 @@ public:
static void getDocxTextContent(QString &path, QString &textcontent); static void getDocxTextContent(QString &path, QString &textcontent);
static void getTxtContent(QString &path, QString &textcontent); static void getTxtContent(QString &path, QString &textcontent);
static size_t _max_index_count; static size_t _max_index_count;
static size_t _current_index_count; static size_t _current_index_count; //this one has been Abandoned,do not use it.
static unsigned short _index_status; static unsigned short _index_status;
private: private:

View File

@ -20,6 +20,12 @@ FileSearcher::~FileSearcher()
{ {
} }
int FileSearcher::getCurrentIndexCount()
{
Xapian::Database db(INDEX_PATH);
return db.get_doccount();
}
void FileSearcher::onKeywordSearch(QString keyword,QQueue<QString> *searchResultFile,QQueue<QString> *searchResultDir,QQueue<QPair<QString,QStringList>> *searchResultContent) void FileSearcher::onKeywordSearch(QString keyword,QQueue<QString> *searchResultFile,QQueue<QString> *searchResultDir,QQueue<QPair<QString,QStringList>> *searchResultContent)
{ {
m_mutex1.lock(); m_mutex1.lock();

View File

@ -20,6 +20,8 @@ public:
explicit FileSearcher(QObject *parent = nullptr); explicit FileSearcher(QObject *parent = nullptr);
~FileSearcher(); ~FileSearcher();
int getCurrentIndexCount();
static size_t uniqueSymbol1; static size_t uniqueSymbol1;
static size_t uniqueSymbol2; static size_t uniqueSymbol2;
static size_t uniqueSymbol3; static size_t uniqueSymbol3;

View File

@ -56,7 +56,6 @@ bool IndexGenerator::creatAllIndex(QQueue<QVector<QString> > *messageList)
count = 0; count = 0;
m_datebase_path->commit(); m_datebase_path->commit();
} }
FileUtils::_current_index_count += 1;
} }
m_datebase_path->commit(); m_datebase_path->commit();
} }
@ -65,7 +64,7 @@ bool IndexGenerator::creatAllIndex(QQueue<QVector<QString> > *messageList)
qWarning()<<"creatAllIndex fail!"<<QString::fromStdString(e.get_description()); qWarning()<<"creatAllIndex fail!"<<QString::fromStdString(e.get_description());
//need a record //need a record
GlobalSettings::getInstance()->setValue(INDEX_DATABASE_STATE,"1"); GlobalSettings::getInstance()->setValue(INDEX_DATABASE_STATE,"1");
Q_ASSERT(false); assert(false);
} }
m_doc_list_path->clear(); m_doc_list_path->clear();
Q_EMIT this->transactionFinished(); Q_EMIT this->transactionFinished();
@ -96,7 +95,7 @@ bool IndexGenerator::creatAllIndex(QQueue<QString> *messageList)
{ {
qWarning()<<"creat content Index fail!"<<QString::fromStdString(e.get_description()); qWarning()<<"creat content Index fail!"<<QString::fromStdString(e.get_description());
GlobalSettings::getInstance()->setValue(CONTENT_INDEX_DATABASE_STATE,"1"); GlobalSettings::getInstance()->setValue(CONTENT_INDEX_DATABASE_STATE,"1");
Q_ASSERT(false); assert(false);
} }
m_doc_list_content->clear(); m_doc_list_content->clear();
Q_EMIT this->transactionFinished(); Q_EMIT this->transactionFinished();
@ -361,9 +360,6 @@ bool IndexGenerator::deleteAllIndex(QStringList *pathlist)
qDebug()<<"delete path"<<doc; qDebug()<<"delete path"<<doc;
qDebug()<<"delete md5"<<QString::fromStdString(uniqueterm); qDebug()<<"delete md5"<<QString::fromStdString(uniqueterm);
m_datebase_path->commit(); m_datebase_path->commit();
FileUtils::_current_index_count = m_datebase_path->get_doccount();
qDebug()<< "--delete finish--"; qDebug()<< "--delete finish--";
} }
catch(const Xapian::Error &e) catch(const Xapian::Error &e)