slightly improve indexing stats by keep a count of file errors and remembering the total files
This commit is contained in:
parent
adacb86605
commit
d0400bdce7
@ -183,7 +183,6 @@ bool FsIndexer::index(int flags)
|
|||||||
#ifdef IDX_THREADS
|
#ifdef IDX_THREADS
|
||||||
PTMutexLocker locker(m_updater->m_mutex);
|
PTMutexLocker locker(m_updater->m_mutex);
|
||||||
#endif
|
#endif
|
||||||
m_updater->status.reset();
|
|
||||||
m_updater->status.dbtotdocs = m_db->docCnt();
|
m_updater->status.dbtotdocs = m_db->docCnt();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -823,8 +822,14 @@ FsIndexer::processonefile(RclConfig *config,
|
|||||||
if (m_updater->status.dbtotdocs < m_updater->status.docsdone)
|
if (m_updater->status.dbtotdocs < m_updater->status.docsdone)
|
||||||
m_updater->status.dbtotdocs = m_updater->status.docsdone;
|
m_updater->status.dbtotdocs = m_updater->status.docsdone;
|
||||||
m_updater->status.fn = fn;
|
m_updater->status.fn = fn;
|
||||||
if (!doc.ipath.empty())
|
if (!doc.ipath.empty()) {
|
||||||
m_updater->status.fn += "|" + doc.ipath;
|
m_updater->status.fn += "|" + doc.ipath;
|
||||||
|
} else {
|
||||||
|
if (fis == FileInterner::FIError) {
|
||||||
|
++(m_updater->status.fileerrors);
|
||||||
|
}
|
||||||
|
++(m_updater->status.filesdone);
|
||||||
|
}
|
||||||
if (!m_updater->update()) {
|
if (!m_updater->update()) {
|
||||||
return FsTreeWalker::FtwStop;
|
return FsTreeWalker::FtwStop;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,12 +47,16 @@ class DbIxStatus {
|
|||||||
string fn; // Last file processed
|
string fn; // Last file processed
|
||||||
int docsdone; // Documents actually updated
|
int docsdone; // Documents actually updated
|
||||||
int filesdone; // Files tested (updated or not)
|
int filesdone; // Files tested (updated or not)
|
||||||
|
int fileerrors; // Failed files (e.g.: missing input handler).
|
||||||
int dbtotdocs; // Doc count in index at start
|
int dbtotdocs; // Doc count in index at start
|
||||||
void reset()
|
// Total files in index.This is actually difficult to compute from
|
||||||
{
|
// the index so it's preserved from last indexing
|
||||||
|
int totfiles;
|
||||||
|
|
||||||
|
void reset() {
|
||||||
phase = DBIXS_FILES;
|
phase = DBIXS_FILES;
|
||||||
fn.erase();
|
fn.erase();
|
||||||
docsdone = filesdone = dbtotdocs = 0;
|
docsdone = filesdone = fileerrors = dbtotdocs = totfiles = 0;
|
||||||
}
|
}
|
||||||
DbIxStatus() {reset();}
|
DbIxStatus() {reset();}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -104,39 +104,38 @@ int stopindexing;
|
|||||||
class MyUpdater : public DbIxStatusUpdater {
|
class MyUpdater : public DbIxStatusUpdater {
|
||||||
public:
|
public:
|
||||||
MyUpdater(const RclConfig *config)
|
MyUpdater(const RclConfig *config)
|
||||||
: m_fd(-1), m_stfilename(config->getIdxStatusFile()),
|
: m_file(config->getIdxStatusFile().c_str()),
|
||||||
m_prevphase(DbIxStatus::DBIXS_NONE) {
|
m_prevphase(DbIxStatus::DBIXS_NONE) {
|
||||||
|
// The total number of files included in the index is actually
|
||||||
|
// difficult to compute from the index itself. For display
|
||||||
|
// purposes, we save it in the status file from indexing to
|
||||||
|
// indexing (mostly...)
|
||||||
|
string stf;
|
||||||
|
if (m_file.get("totfiles", stf)) {
|
||||||
|
status.totfiles = atoi(stf.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool update()
|
virtual bool update()
|
||||||
{
|
{
|
||||||
if (m_fd < 0) {
|
// Update the status file. Avoid doing it too often. Always do
|
||||||
m_fd = open(m_stfilename.c_str(),
|
// it at the end (status DONE)
|
||||||
O_WRONLY|O_CREAT|O_TRUNC, 0600);
|
if (status.phase == DbIxStatus::DBIXS_DONE ||
|
||||||
if (m_fd < 0) {
|
status.phase != m_prevphase || m_chron.millis() > 300) {
|
||||||
LOGERR(("Can't open/create status file: [%s]\n",
|
if (status.totfiles < status.filesdone) {
|
||||||
m_stfilename.c_str()));
|
status.totfiles = status.filesdone;
|
||||||
return stopindexing ? false : true;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
// Update the status file. Avoid doing it too often
|
|
||||||
if (status.phase != m_prevphase || m_chron.millis() > 300) {
|
|
||||||
m_prevphase = status.phase;
|
m_prevphase = status.phase;
|
||||||
m_chron.restart();
|
m_chron.restart();
|
||||||
lseek(m_fd, 0, 0);
|
m_file.holdWrites(true);
|
||||||
int fd1 = dup(m_fd);
|
m_file.set("phase", int(status.phase));
|
||||||
FILE *fp = fdopen(fd1, "w");
|
m_file.set("docsdone", status.docsdone);
|
||||||
fprintf(fp, "phase = %d\n", int(status.phase));
|
m_file.set("filesdone", status.filesdone);
|
||||||
fprintf(fp, "docsdone = %d\n", status.docsdone);
|
m_file.set("fileerrors", status.fileerrors);
|
||||||
fprintf(fp, "filesdone = %d\n", status.filesdone);
|
m_file.set("dbtotdocs", status.dbtotdocs);
|
||||||
fprintf(fp, "dbtotdocs = %d\n", status.dbtotdocs);
|
m_file.set("totfiles", status.totfiles);
|
||||||
fprintf(fp, "fn = %s\n", status.fn.c_str());
|
m_file.set("fn", status.fn);
|
||||||
if (ftruncate(m_fd, off_t(ftell(fp))) < 0) {
|
m_file.holdWrites(false);
|
||||||
// ? kill compiler warning about ignoring ftruncate return
|
|
||||||
LOGDEB(("Status update: ftruncate failed\n"));
|
|
||||||
}
|
|
||||||
// Flush data and closes fd1. m_fd still valid
|
|
||||||
fclose(fp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stopindexing) {
|
if (stopindexing) {
|
||||||
@ -158,8 +157,7 @@ class MyUpdater : public DbIxStatusUpdater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_fd;
|
ConfSimple m_file;
|
||||||
string m_stfilename;
|
|
||||||
Chrono m_chron;
|
Chrono m_chron;
|
||||||
DbIxStatus::Phase m_prevphase;
|
DbIxStatus::Phase m_prevphase;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -39,12 +39,11 @@ void RclMain::idxStatus()
|
|||||||
cs.get("phase", val);
|
cs.get("phase", val);
|
||||||
status.phase = DbIxStatus::Phase(atoi(val.c_str()));
|
status.phase = DbIxStatus::Phase(atoi(val.c_str()));
|
||||||
cs.get("fn", status.fn);
|
cs.get("fn", status.fn);
|
||||||
cs.get("docsdone", val);
|
cs.get("docsdone", &status.docsdone);
|
||||||
status.docsdone = atoi(val.c_str());
|
cs.get("filesdone", &status.filesdone);
|
||||||
cs.get("filesdone", val);
|
cs.get("fileerrors", &status.fileerrors);
|
||||||
status.filesdone = atoi(val.c_str());
|
cs.get("dbtotdocs", &status.dbtotdocs);
|
||||||
cs.get("dbtotdocs", val);
|
cs.get("totfiles", &status.totfiles);
|
||||||
status.dbtotdocs = atoi(val.c_str());
|
|
||||||
|
|
||||||
QString phs;
|
QString phs;
|
||||||
switch (status.phase) {
|
switch (status.phase) {
|
||||||
@ -60,11 +59,14 @@ void RclMain::idxStatus()
|
|||||||
msg += phs + " ";
|
msg += phs + " ";
|
||||||
if (status.phase == DbIxStatus::DBIXS_FILES) {
|
if (status.phase == DbIxStatus::DBIXS_FILES) {
|
||||||
char cnts[100];
|
char cnts[100];
|
||||||
if (status.dbtotdocs > 0)
|
if (status.dbtotdocs > 0) {
|
||||||
sprintf(cnts,"(%d/%d/%d) ", status.docsdone, status.filesdone,
|
sprintf(cnts, "(%d docs/%d files/%d errors/%d tot files) ",
|
||||||
status.dbtotdocs);
|
status.docsdone, status.filesdone, status.fileerrors,
|
||||||
else
|
status.totfiles);
|
||||||
sprintf(cnts, "(%d/%d) ", status.docsdone, status.filesdone);
|
} else {
|
||||||
|
sprintf(cnts, "(%d docs/%d files/%d errors) ",
|
||||||
|
status.docsdone, status.filesdone, status.fileerrors);
|
||||||
|
}
|
||||||
msg += QString::fromUtf8(cnts) + " ";
|
msg += QString::fromUtf8(cnts) + " ";
|
||||||
}
|
}
|
||||||
string mf;int ecnt = 0;
|
string mf;int ecnt = 0;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user