2023-10-07 15:44:59 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2022, KylinSoft Co., Ltd.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* Authors: iaom <zhangpengfei@kylinos.cn>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#ifndef MONITOR_H
|
|
|
|
#define MONITOR_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include "index-scheduler.h"
|
|
|
|
#include "database.h"
|
|
|
|
#include "rep_monitor_source.h"
|
|
|
|
namespace UkuiSearch {
|
|
|
|
/**
|
|
|
|
* @brief The Monitor class
|
|
|
|
* 用于监控索引状态
|
|
|
|
*/
|
|
|
|
class Monitor : public MonitorSource
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2024-04-15 15:51:47 +08:00
|
|
|
explicit Monitor(IndexScheduler* scheduler, QObject *parent = nullptr);
|
2023-10-07 15:44:59 +08:00
|
|
|
/**
|
|
|
|
* @brief currentIndexPaths
|
|
|
|
* @return 当前索引的所有目录
|
|
|
|
*/
|
|
|
|
QStringList currentIndexPaths() const override;
|
|
|
|
/**
|
|
|
|
* @brief indexState
|
|
|
|
* @return 当前索引调度器的状态
|
|
|
|
*/
|
|
|
|
QString indexState() const override;
|
|
|
|
/**
|
|
|
|
* @brief basicIndexSize
|
|
|
|
* @return 当前需要处理的基础索引数量
|
|
|
|
*/
|
|
|
|
uint basicIndexSize() const override;
|
|
|
|
/**
|
|
|
|
* @brief contentIndexSize
|
|
|
|
* @return 当前需要处理的内容索引数量
|
|
|
|
*/
|
|
|
|
uint contentIndexSize() const override;
|
|
|
|
/**
|
2024-04-15 09:52:06 +08:00
|
|
|
* @brief ocrContentIndexSize
|
2023-10-07 15:44:59 +08:00
|
|
|
* @return 当前需要处理的OCR索引数量
|
|
|
|
*/
|
2024-04-15 09:52:06 +08:00
|
|
|
uint ocrContentIndexSize() const override;
|
2024-04-17 17:43:50 +08:00
|
|
|
/**
|
|
|
|
* @brief aiIndexSize
|
|
|
|
* @return 当前需要处理的AI索引数量
|
|
|
|
*/
|
|
|
|
uint aiIndexSize() const override;
|
2023-10-07 15:44:59 +08:00
|
|
|
/**
|
|
|
|
* @brief basicIndexProgress
|
|
|
|
* @return 基础索引进度
|
|
|
|
*/
|
|
|
|
uint basicIndexProgress() const override;
|
|
|
|
/**
|
|
|
|
* @brief contentIndexProgress
|
|
|
|
* @return 内容索引进度
|
|
|
|
*/
|
|
|
|
uint contentIndexProgress() const override;
|
|
|
|
/**
|
2024-04-15 09:52:06 +08:00
|
|
|
* @brief ocrContentIndexProgress
|
2023-10-07 15:44:59 +08:00
|
|
|
* @return ocr索引进度
|
|
|
|
*/
|
2024-04-15 09:52:06 +08:00
|
|
|
uint ocrContentIndexProgress() const override;
|
2024-04-17 17:43:50 +08:00
|
|
|
/**
|
|
|
|
* @brief aiIndexProgress
|
|
|
|
* @return ai索引进度
|
|
|
|
*/
|
|
|
|
uint aiIndexProgress() const override;
|
2023-10-07 15:44:59 +08:00
|
|
|
/**
|
|
|
|
* @brief basicIndexDocNum
|
|
|
|
* @return 基础索引完成的总文档数
|
|
|
|
*/
|
|
|
|
uint basicIndexDocNum() const override;
|
|
|
|
/**
|
|
|
|
* @brief contentIndexDocNum
|
|
|
|
* @return 内容索引完成的总文档数
|
|
|
|
*/
|
|
|
|
uint contentIndexDocNum() const override;
|
|
|
|
/**
|
|
|
|
* @brief contentIndexDocNum
|
|
|
|
* @return ocr容索引完成的总文档数
|
|
|
|
*/
|
|
|
|
uint ocrContentIndexDocNum() const override;
|
2024-04-17 17:43:50 +08:00
|
|
|
/**
|
|
|
|
* @brief aiIndexDocNum
|
|
|
|
* @return ai索引完成的总文档数
|
|
|
|
*/
|
|
|
|
uint aiIndexDocNum() const override;
|
2024-04-15 15:51:47 +08:00
|
|
|
/**
|
|
|
|
* basicIndexUpdating
|
|
|
|
* @return 基础索引是否正在执行增量更新
|
|
|
|
*/
|
2024-04-17 17:43:50 +08:00
|
|
|
bool basicIndexUpdating() const override;
|
2024-04-15 15:51:47 +08:00
|
|
|
/**
|
|
|
|
* basicIndexUpdating
|
|
|
|
* @return 文本内容索引是否正在执行增量更新
|
|
|
|
*/
|
2024-04-17 17:43:50 +08:00
|
|
|
bool contentIndexUpdating() const override;
|
2024-04-15 15:51:47 +08:00
|
|
|
/**
|
|
|
|
* basicIndexUpdating
|
|
|
|
* @return ocr索引是否正在执行增量更新
|
|
|
|
*/
|
2024-04-17 17:43:50 +08:00
|
|
|
bool ocrContentIndexUpdating() const override;
|
|
|
|
/**
|
|
|
|
* aiIndexUpdating
|
|
|
|
* @return ai索引是否正在执行增量更新
|
|
|
|
*/
|
|
|
|
bool aiIndexUpdating() const override;
|
2023-10-07 15:44:59 +08:00
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void onIndexStateChanged(IndexScheduler::IndexerState);
|
|
|
|
void processUpdate(UkuiSearch::IndexType type, uint all, uint finished);
|
|
|
|
|
|
|
|
private:
|
|
|
|
IndexScheduler *m_scheduler = nullptr;
|
2023-10-09 10:27:29 +08:00
|
|
|
QStringList m_currentIndexPaths;
|
2023-10-07 15:44:59 +08:00
|
|
|
Database m_basicDatabase;
|
|
|
|
Database m_contentDatabase;
|
|
|
|
Database m_ocrContentDatabase;
|
|
|
|
uint m_basicIndexSize = 0;
|
|
|
|
uint m_contentIndexSize = 0;
|
2024-04-17 17:43:50 +08:00
|
|
|
uint m_ocrContentIndexSize = 0;
|
|
|
|
uint m_aiIndexSize = 0;
|
2023-10-07 15:44:59 +08:00
|
|
|
uint m_basicIndexProgress = 0;
|
|
|
|
uint m_contentIndexProgress = 0;
|
2024-04-17 17:43:50 +08:00
|
|
|
uint m_ocrContentIndexProgress = 0;
|
|
|
|
uint m_aiIndexProgress = 0;
|
2023-10-09 10:27:29 +08:00
|
|
|
uint m_basicIndexDocNum = 0;
|
|
|
|
uint m_contentIndexDocNum = 0;
|
|
|
|
uint m_ocrContentIndexDocNum = 0;
|
2024-04-17 17:43:50 +08:00
|
|
|
uint m_aiIndexDocNum = 0;
|
2024-04-15 15:51:47 +08:00
|
|
|
bool m_basicIndexUpdating = false;
|
|
|
|
bool m_contentIndexUpdating = false;
|
|
|
|
bool m_ocrContentIndexUpdating = false;
|
2024-04-17 17:43:50 +08:00
|
|
|
bool m_aiIndexUpdating = false;
|
|
|
|
|
2023-10-07 15:44:59 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif // MONITOR_H
|