KIO slave: perform incremental updates during listDir. Bump the default maxentries to 10000. use RECOLL_KIO_STEMLANG for defining stemming language. Closes issue #235

This commit is contained in:
Jean-Francois Dockes 2015-04-24 13:07:55 +02:00
parent 7876fba5f7
commit 25cecec484
3 changed files with 134 additions and 118 deletions

View File

@ -277,25 +277,33 @@ void RecollProtocol::listDir(const KUrl& url)
return; return;
} }
static int numentries = -1; static int maxentries = -1;
if (numentries == -1) { if (maxentries == -1) {
if (o_rclconfig) if (o_rclconfig)
o_rclconfig->getConfParam("kio_max_direntries", &numentries); o_rclconfig->getConfParam("kio_max_direntries", &maxentries);
if (numentries == -1) if (maxentries == -1)
numentries = 100; maxentries = 10000;
} }
static const int pagesize = 200;
int pagebase = 0;
while (pagebase < maxentries) {
vector<ResListEntry> page; vector<ResListEntry> page;
int pagelen = m_source->getSeqSlice(0, numentries, page); int pagelen = m_source->getSeqSlice(pagebase, pagesize, page);
UDSEntry entry;
if (pagelen < 0) { if (pagelen < 0) {
error(ERR_SLAVE_DEFINED, "Internal error"); error(ERR_SLAVE_DEFINED, "Internal error");
return; listEntry(entry, true);
break;
} }
UDSEntryList entries;
for (int i = 0; i < pagelen; i++) { for (int i = 0; i < pagelen; i++) {
entries.append(resultToUDSEntry(page[i].doc, i)); listEntry(resultToUDSEntry(page[i].doc, i), false);
}
if (pagelen != pagesize) {
listEntry(entry, true);
break;
}
pagebase += pagelen;
} }
listEntries(entries);
finished(); finished();
} }

View File

@ -87,6 +87,12 @@ RecollProtocol::RecollProtocol(const QByteArray &pool, const QByteArray &app)
o_rclconfig->getConfParam("kio_always_dir", &m_alwaysdir); o_rclconfig->getConfParam("kio_always_dir", &m_alwaysdir);
} }
cp = getenv("RECOLL_KIO_STEMLANG");
if (cp) {
m_stemlang = cp;
} else {
m_stemlang = "english";
}
m_pager.setParent(this); m_pager.setParent(this);
m_initok = true; m_initok = true;
return; return;
@ -314,11 +320,11 @@ bool RecollProtocol::doSearch(const QueryDesc& qd)
clp = new Rcl::SearchDataClauseSimple(opt == 'o' ? Rcl::SCLT_OR : clp = new Rcl::SearchDataClauseSimple(opt == 'o' ? Rcl::SCLT_OR :
Rcl::SCLT_AND, qs); Rcl::SCLT_AND, qs);
} }
sd = new Rcl::SearchData(Rcl::SCLT_OR, "english"); sd = new Rcl::SearchData(Rcl::SCLT_OR, m_stemlang);
if (sd && clp) if (sd && clp)
sd->addClause(clp); sd->addClause(clp);
} else { } else {
sd = wasaStringToRcl(o_rclconfig, "english", qs, m_reason); sd = wasaStringToRcl(o_rclconfig, m_stemlang, qs, m_reason);
} }
if (!sd) { if (!sd) {
m_reason = "Internal Error: cant build search"; m_reason = "Internal Error: cant build search";

View File

@ -171,6 +171,8 @@ class RecollProtocol : public KIO::SlaveBase {
Rcl::Db *m_rcldb; Rcl::Db *m_rcldb;
string m_reason; string m_reason;
bool m_alwaysdir; bool m_alwaysdir;
string m_stemlang; // english by default else env[RECOLL_KIO_STEMLANG]
// Search state: because of how the KIO slaves are used / reused, // Search state: because of how the KIO slaves are used / reused,
// we can't be sure that the next request will be for the same // we can't be sure that the next request will be for the same
// search, and we need to check and restart one if the data // search, and we need to check and restart one if the data