Get rid of the GUI indexing thread. All indexing now done by recollindex, with start/stop from the GUI

This commit is contained in:
Jean-Francois Dockes
2012-02-07 17:07:07 +01:00
parent f59e2e033a
commit fccc0ac09c
14 changed files with 237 additions and 350 deletions
+1
View File
@@ -349,6 +349,7 @@ FsIndexer::processone(const std::string &fn, const struct stat *stp,
if (m_updater) {
// Status bar update, abort request etc.
m_updater->status.fn = fn;
++(m_updater->status.filesdone);
if (!m_updater->update()) {
return FsTreeWalker::FtwStop;
}
+15 -9
View File
@@ -107,7 +107,7 @@ bool ConfIndexer::index(bool resetbefore, ixType typestorun)
return true;
}
bool ConfIndexer::indexFiles(std::list<string>& ifiles, IxFlag flag)
bool ConfIndexer::indexFiles(list<string>& ifiles, IxFlag flag)
{
list<string> myfiles;
for (list<string>::const_iterator it = ifiles.begin();
@@ -151,11 +151,8 @@ bool ConfIndexer::indexFiles(std::list<string>& ifiles, IxFlag flag)
return ret;
}
// Update index for specific documents. The docs come from an index
// query, so the udi, backend etc. fields are filled.
bool ConfIndexer::updateDocs(std::vector<Rcl::Doc> &docs, IxFlag flag)
bool ConfIndexer::docsToPaths(vector<Rcl::Doc> &docs, vector<string> &paths)
{
list<string> files;
for (vector<Rcl::Doc>::iterator it = docs.begin(); it != docs.end(); it++) {
Rcl::Doc &idoc = *it;
string backend;
@@ -168,15 +165,24 @@ bool ConfIndexer::updateDocs(std::vector<Rcl::Doc> &docs, IxFlag flag)
if (!backend.empty() && backend.compare("FS"))
continue;
// Filesystem document. Intern from file.
// The url has to be like file://
// Filesystem document. The url has to be like file://
if (idoc.url.find(cstr_fileu) != 0) {
LOGERR(("idx::updateDocs: FS backend and non fs url: [%s]\n",
LOGERR(("idx::docsToPaths: FS backend and non fs url: [%s]\n",
idoc.url.c_str()));
continue;
}
files.push_back(idoc.url.substr(7, string::npos));
paths.push_back(idoc.url.substr(7, string::npos));
}
return true;
}
// Update index for specific documents. The docs come from an index
// query, so the udi, backend etc. fields are filled.
bool ConfIndexer::updateDocs(std::vector<Rcl::Doc> &docs, IxFlag flag)
{
vector<string> paths;
docsToPaths(docs, paths);
list<string> files(paths.begin(), paths.end());
if (!files.empty()) {
return indexFiles(files, flag);
}
+15 -6
View File
@@ -20,11 +20,13 @@
#include <string>
#include <list>
#include <map>
#include <vector>
#ifndef NO_NAMESPACES
using std::string;
using std::list;
using std::map;
using std::vector;
#endif
#include "rclconfig.h"
@@ -38,12 +40,19 @@ class DbIxStatus {
public:
enum Phase {DBIXS_NONE,
DBIXS_FILES, DBIXS_PURGE, DBIXS_STEMDB, DBIXS_CLOSING,
DBIXS_MONITOR,
DBIXS_DONE};
Phase phase;
string fn; // Last file processed
int docsdone; // Documents processed
int docsdone; // Documents actually updated
int filesdone; // Files tested (updated or not)
int dbtotdocs; // Doc count in index at start
void reset() {phase = DBIXS_FILES;fn.erase();docsdone=dbtotdocs=0;}
void reset()
{
phase = DBIXS_FILES;
fn.erase();
docsdone = filesdone = dbtotdocs = 0;
}
DbIxStatus() {reset();}
};
@@ -101,14 +110,14 @@ class ConfIndexer {
static list<string> getStemmerNames();
/** Index a list of files. No db cleaning or stemdb updating */
bool indexFiles(std::list<string> &files, IxFlag f = IxFNone);
bool indexFiles(list<string> &files, IxFlag f = IxFNone);
/** Update index for list of documents given as list of docs (out of query)
*/
bool updateDocs(std::vector<Rcl::Doc> &docs, IxFlag f = IxFNone);
bool updateDocs(vector<Rcl::Doc> &docs, IxFlag f = IxFNone);
static bool docsToPaths(vector<Rcl::Doc> &docs, vector<string> &paths);
/** Purge a list of files. */
bool purgeFiles(std::list<string> &files);
bool purgeFiles(list<string> &files);
private:
RclConfig *m_config;
+6
View File
@@ -103,6 +103,7 @@ class MyUpdater : public DbIxStatusUpdater {
FILE *fp = fdopen(fd1, "w");
fprintf(fp, "phase = %d\n", int(status.phase));
fprintf(fp, "docsdone = %d\n", status.docsdone);
fprintf(fp, "filesdone = %d\n", status.filesdone);
fprintf(fp, "dbtotdocs = %d\n", status.dbtotdocs);
fprintf(fp, "fn = %s\n", status.fn.c_str());
ftruncate(m_fd, off_t(ftell(fp)));
@@ -423,6 +424,11 @@ int main(int argc, const char **argv)
LOGERR(("recollindex, initial indexing pass failed, not going into monitor mode\n"));
exit(1);
}
if (updater) {
updater->status.phase = DbIxStatus::DBIXS_MONITOR;
updater->status.fn.clear();
updater->update();
}
deleteZ(confindexer);
int opts = RCLMON_NONE;
if (op_flags & OPT_D)