feat(index-monitor)增加查询索引是否正在执行增量更新的接口

This commit is contained in:
iaom 2024-04-15 15:51:47 +08:00
parent 166218115a
commit 7434d31d7b
6 changed files with 115 additions and 7 deletions

View File

@ -88,6 +88,9 @@ IndexMonitor::IndexMonitor(QObject *parent) : QObject(parent), d(new IndexMonito
connect(d->m_monitorReplica, &MonitorReplica::basicIndexDone, this, &IndexMonitor::basicIndexDone);
connect(d->m_monitorReplica, &MonitorReplica::contentIndexDone, this, &IndexMonitor::contentIndexDone);
connect(d->m_monitorReplica, &MonitorReplica::ocrContentIndexDone, this, &IndexMonitor::ocrContentIndexDone);
connect(d->m_monitorReplica, &MonitorReplica::basicIndexUpdatingChanged, this, &IndexMonitor::basicIndexUpdatingChanged);
connect(d->m_monitorReplica, &MonitorReplica::contentIndexUpdatingChanged, this, &IndexMonitor::contentIndexUpdatingChanged);
connect(d->m_monitorReplica, &MonitorReplica::ocrContentIndexUpdatingChanged, this, &IndexMonitor::ocrContentIndexUpdatingChanged);
connect(d->m_monitorReplica, &QRemoteObjectReplica::initialized, this, &IndexMonitor::serviceReady);
connect(d->m_monitorReplica, &QRemoteObjectReplica::stateChanged, this, [&](QRemoteObjectReplica::State state, QRemoteObjectReplica::State oldState){
@ -159,4 +162,19 @@ uint IndexMonitor::ocrContentIndexDocNum() const
{
return d->m_monitorReplica->ocrContentIndexDocNum();
}
bool IndexMonitor::basicIndexUpdating() const
{
return d->m_monitorReplica->basicIndexUpdating();
}
bool IndexMonitor::contentIndexUpdating() const
{
return d->m_monitorReplica->contentIndexUpdating();
}
bool IndexMonitor::ocrContentIndexUpdating() const
{
return d->m_monitorReplica->ocrContentIndexUpdating();
}
} // UkuiSearch

View File

@ -101,6 +101,21 @@ public:
* @return ocr内容索引完成的总文档数
*/
uint ocrContentIndexDocNum() const;
/**
* basicIndexUpdating
* @return
*/
virtual bool basicIndexUpdating() const;
/**
* basicIndexUpdating
* @return
*/
virtual bool contentIndexUpdating() const;
/**
* basicIndexUpdating
* @return ocr索引是否正在执行增量更新
*/
virtual bool ocrContentIndexUpdating() const;
Q_SIGNALS:
void currentIndexPathsChanged(QStringList currentIndexPaths);
@ -120,6 +135,9 @@ Q_SIGNALS:
void basicIndexDone(bool success);
void contentIndexDone(bool success);
void ocrContentIndexDone(bool success);
void basicIndexUpdatingChanged(bool basicIndexUpdating);
void contentIndexUpdatingChanged(bool contentIndexUpdating);
void ocrContentIndexUpdatingChanged(bool ocrContentIndexUpdating);
void serviceReady();
void serviceOffline();

View File

@ -12,6 +12,9 @@ class Monitor
PROP(uint basicIndexDocNum READONLY);
PROP(uint contentIndexDocNum READONLY);
PROP(uint ocrContentIndexDocNum READONLY);
PROP(bool basicIndexUpdating READONLY);
PROP(bool contentIndexUpdating READONLY);
PROP(bool ocrContentIndexUpdating READONLY);
SIGNAL(basicIndexStart());
SIGNAL(contentIndexStart());
SIGNAL(ocrContentIndexStart());

View File

@ -37,6 +37,9 @@ IndexMonitorTest::IndexMonitorTest(QObject *parent) : QObject(parent)
qDebug() << "==basicIndexDocNum==" << m_monitor->basicIndexDocNum();
qDebug() << "==contentIndexDocNum==" << m_monitor->contentIndexDocNum();
qDebug() << "==ocrContentIndexDocNum==" << m_monitor->ocrContentIndexDocNum();
qDebug() << "==basicIndexUpdating==" << m_monitor->basicIndexUpdating();
qDebug() << "==contentIndexUpdating==" << m_monitor->contentIndexUpdating();
qDebug() << "==ocrContentIndexUpdating==" << m_monitor->ocrContentIndexUpdating();
});
connect(m_monitor, &UkuiSearch::IndexMonitor::serviceOffline, this, [&](){
qDebug() << "==serviceReady==";
@ -92,6 +95,15 @@ IndexMonitorTest::IndexMonitorTest(QObject *parent) : QObject(parent)
connect(m_monitor, &UkuiSearch::IndexMonitor::ocrContentIndexDone, this, [&](bool success){
qDebug() << "==ocrContentIndexDone==" << success;
});
connect(m_monitor, &UkuiSearch::IndexMonitor::basicIndexUpdatingChanged, this, [&](bool updating){
qDebug() << "==basicIndexUpdatingChanged==" << updating;
});
connect(m_monitor, &UkuiSearch::IndexMonitor::contentIndexUpdatingChanged, this, [&](bool updating){
qDebug() << "==contentIndexUpdatingChanged==" << updating;
});
connect(m_monitor, &UkuiSearch::IndexMonitor::ocrContentIndexUpdatingChanged, this, [&](bool updating){
qDebug() << "==ocrContentIndexUpdatingChanged==" << updating;
});
}
IndexMonitorTest::~IndexMonitorTest()

View File

@ -29,12 +29,36 @@ Monitor::Monitor(IndexScheduler *scheduler, QObject *parent) : MonitorSource(par
{
connect(scheduler, &IndexScheduler::stateChange, this, &Monitor::onIndexStateChanged);
connect(scheduler, &IndexScheduler::process, this, &Monitor::processUpdate);
connect(scheduler, &IndexScheduler::basicIndexDone, this, &Monitor::basicIndexDone);
connect(scheduler, &IndexScheduler::contentIndexDone, this, &Monitor::contentIndexDone);
connect(scheduler, &IndexScheduler::ocrContentIndexDone, this, &Monitor::ocrContentIndexDone);
connect(scheduler, &IndexScheduler::basicIndexStart, this, &Monitor::basicIndexStart);
connect(scheduler, &IndexScheduler::contentIndexStart, this, &Monitor::contentIndexStart);
connect(scheduler, &IndexScheduler::ocrContentIndexStart, this, &Monitor::ocrContentIndexStart);
connect(scheduler, &IndexScheduler::basicIndexDone, this, [&](bool success){
Q_EMIT basicIndexDone(success);
m_basicIndexUpdating = false;
Q_EMIT basicIndexUpdatingChanged(m_basicIndexUpdating);
});
connect(scheduler, &IndexScheduler::contentIndexDone, this, [&](bool success){
Q_EMIT contentIndexDone(success);
m_contentIndexUpdating = false;
Q_EMIT contentIndexUpdatingChanged(m_contentIndexUpdating);
});
connect(scheduler, &IndexScheduler::ocrContentIndexDone, this, [&](bool success){
Q_EMIT ocrContentIndexDone(success);
m_ocrContentIndexUpdating = false;
Q_EMIT ocrContentIndexUpdatingChanged(m_ocrContentIndexUpdating);
});
connect(scheduler, &IndexScheduler::basicIndexStart, this, [&](){
Q_EMIT basicIndexStart();
m_basicIndexUpdating = true;
Q_EMIT basicIndexUpdatingChanged(m_basicIndexUpdating);
});
connect(scheduler, &IndexScheduler::contentIndexStart, this, [&](){
Q_EMIT contentIndexStart();
m_contentIndexUpdating = true;
Q_EMIT contentIndexUpdatingChanged(m_contentIndexUpdating);
});
connect(scheduler, &IndexScheduler::ocrContentIndexStart, this, [&](){
Q_EMIT ocrContentIndexStart();
m_ocrContentIndexUpdating = true;
Q_EMIT ocrContentIndexUpdatingChanged(m_ocrContentIndexUpdating);
});
connect(FileIndexerConfig::getInstance(), &FileIndexerConfig::appendIndexDir, this, [&](){
m_currentIndexPaths = FileIndexerConfig::getInstance()->currentIndexableDir();
Q_EMIT currentIndexPathsChanged(m_currentIndexPaths);
@ -170,3 +194,18 @@ void Monitor::processUpdate(IndexType type, uint all, uint finished)
break;
}
}
bool Monitor::basicIndexUpdating() const
{
return m_basicIndexUpdating;
}
bool Monitor::contentIndexUpdating() const
{
return m_contentIndexUpdating;
}
bool Monitor::ocrContentIndexUpdating() const
{
return m_ocrContentIndexUpdating;
}

View File

@ -90,6 +90,21 @@ public:
* @return ocr容索引完成的总文档数
*/
uint ocrContentIndexDocNum() const override;
/**
* basicIndexUpdating
* @return
*/
virtual bool basicIndexUpdating() const override;
/**
* basicIndexUpdating
* @return
*/
virtual bool contentIndexUpdating() const override;
/**
* basicIndexUpdating
* @return ocr索引是否正在执行增量更新
*/
virtual bool ocrContentIndexUpdating() const override;
private Q_SLOTS:
void onIndexStateChanged(IndexScheduler::IndexerState);
@ -110,6 +125,9 @@ private:
uint m_basicIndexDocNum = 0;
uint m_contentIndexDocNum = 0;
uint m_ocrContentIndexDocNum = 0;
bool m_basicIndexUpdating = false;
bool m_contentIndexUpdating = false;
bool m_ocrContentIndexUpdating = false;
};
}
#endif // MONITOR_H