doc.pc now only place where relevancy is stored

This commit is contained in:
dockes 2008-09-29 08:59:20 +00:00
parent 0bab0ea553
commit 828dff3bb1
18 changed files with 55 additions and 81 deletions

View File

@ -1,5 +1,5 @@
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: kio_recoll.cpp,v 1.8 2008-06-13 18:22:46 dockes Exp $ (C) 2005 J.F.Dockes"; static char rcsid[] = "@(#$Id: kio_recoll.cpp,v 1.9 2008-09-29 08:59:20 dockes Exp $ (C) 2005 J.F.Dockes";
#endif #endif
#include <stdio.h> #include <stdio.h>
@ -139,8 +139,7 @@ void RecollProtocol::get(const KURL & url)
string sh; string sh;
doc.erase(); doc.erase();
int percent; if (!m_docsource->getDoc(i, doc, &sh)) {
if (!m_docsource->getDoc(i, doc, &percent, &sh)) {
// This may very well happen for history if the doc has // This may very well happen for history if the doc has
// been removed since. So don't treat it as fatal. // been removed since. So don't treat it as fatal.
doc.meta["abstract"] = string("Unavailable document"); doc.meta["abstract"] = string("Unavailable document");
@ -158,7 +157,7 @@ void RecollProtocol::get(const KURL & url)
result = "<p>"; result = "<p>";
char perbuf[10]; char perbuf[10];
sprintf(perbuf, "%3d%%", percent); sprintf(perbuf, "%3d%%", doc.pc);
if (doc.meta["title"].empty()) if (doc.meta["title"].empty())
doc.meta["title"] = path_getsimple(doc.url); doc.meta["title"] = path_getsimple(doc.url);
char datebuf[100]; char datebuf[100];

View File

@ -1,5 +1,5 @@
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: pyrecoll.cpp,v 1.14 2008-09-29 06:58:25 dockes Exp $ (C) 2007 J.F.Dockes"; static char rcsid[] = "@(#$Id: pyrecoll.cpp,v 1.15 2008-09-29 08:59:20 dockes Exp $ (C) 2007 J.F.Dockes";
#endif #endif
@ -618,7 +618,7 @@ Query_execute(recoll_QueryObject* self, PyObject *args, PyObject *kwargs)
return 0; return 0;
} }
RefCntr<Rcl::SearchData> rq(sd); RefCntr<Rcl::SearchData> rq(sd);
rq->setSortBy(self->sortfield, self->ascending); self->query->setSortBy(self->sortfield, self->ascending);
self->query->setQuery(rq, dostem?Rcl::Query::QO_STEM:Rcl::Query::QO_NONE); self->query->setQuery(rq, dostem?Rcl::Query::QO_STEM:Rcl::Query::QO_NONE);
int cnt = self->query->getResCnt(); int cnt = self->query->getResCnt();
self->next = 0; self->next = 0;
@ -647,7 +647,7 @@ Query_executesd(recoll_QueryObject* self, PyObject *args, PyObject *kwargs)
PyErr_SetString(PyExc_AttributeError, "query"); PyErr_SetString(PyExc_AttributeError, "query");
return 0; return 0;
} }
pysd->sd->setSortBy(self->sortfield, self->ascending); self->query->setSortBy(self->sortfield, self->ascending);
self->query->setQuery(pysd->sd, dostem ? Rcl::Query::QO_STEM : self->query->setQuery(pysd->sd, dostem ? Rcl::Query::QO_STEM :
Rcl::Query::QO_NONE); Rcl::Query::QO_NONE);
int cnt = self->query->getResCnt(); int cnt = self->query->getResCnt();
@ -681,8 +681,7 @@ Query_fetchone(recoll_QueryObject* self, PyObject *, PyObject *)
LOGERR(("Query_fetchone: couldn't create doc object for result\n")); LOGERR(("Query_fetchone: couldn't create doc object for result\n"));
return 0; return 0;
} }
int percent; if (!self->query->getDoc(self->next, *result->doc)) {
if (!self->query->getDoc(self->next, *result->doc, &percent)) {
PyErr_SetString(PyExc_EnvironmentError, "query: cant fetch result"); PyErr_SetString(PyExc_EnvironmentError, "query: cant fetch result");
self->next = -1; self->next = -1;
return 0; return 0;
@ -702,7 +701,7 @@ Query_fetchone(recoll_QueryObject* self, PyObject *, PyObject *)
doc->meta[Rcl::Doc::keyfs] = doc->fbytes; doc->meta[Rcl::Doc::keyfs] = doc->fbytes;
doc->meta[Rcl::Doc::keyds] = doc->dbytes; doc->meta[Rcl::Doc::keyds] = doc->dbytes;
char pc[20]; char pc[20];
sprintf(pc, "%02d %%", percent); sprintf(pc, "%02d %%", doc->pc);
doc->meta[Rcl::Doc::keyrr] = pc; doc->meta[Rcl::Doc::keyrr] = pc;
return (PyObject *)result; return (PyObject *)result;

View File

@ -1,5 +1,5 @@
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: reslist.cpp,v 1.45 2008-09-28 14:20:50 dockes Exp $ (C) 2005 J.F.Dockes"; static char rcsid[] = "@(#$Id: reslist.cpp,v 1.46 2008-09-29 08:59:20 dockes Exp $ (C) 2005 J.F.Dockes";
#endif #endif
#include <time.h> #include <time.h>
@ -474,15 +474,19 @@ void ResList::resultPageNext()
// setUpdatesEnabled(false); // setUpdatesEnabled(false);
for (int i = 0; i < pagelen; i++) { for (int i = 0; i < pagelen; i++) {
int &percent(respage[i].percent);
Rcl::Doc &doc(respage[i].doc); Rcl::Doc &doc(respage[i].doc);
string& sh(respage[i].subHeader); string& sh(respage[i].subHeader);
int percent;
if (percent == -1) { if (doc.pc == -1) {
percent = 0; percent = 0;
// Document not available, maybe other further, will go on. // Document not available, maybe other further, will go on.
doc.meta[Rcl::Doc::keyabs] = string(tr("Unavailable document").utf8()); doc.meta[Rcl::Doc::keyabs] = string(tr("Unavailable document").utf8());
} else {
percent = doc.pc;
} }
// Percentage of 'relevance'
char perbuf[10];
sprintf(perbuf, "%3d%% ", percent);
// Determine icon to display if any // Determine icon to display if any
string img_name; string img_name;
@ -496,10 +500,6 @@ void ResList::resultPageNext()
setImage(img_name.c_str(), image); setImage(img_name.c_str(), image);
} }
// Percentage of 'relevance'
char perbuf[10];
sprintf(perbuf, "%3d%% ", percent);
// Printable url: either utf-8 if transcoding succeeds, or url-encoded // Printable url: either utf-8 if transcoding succeeds, or url-encoded
string url; string url;
printableUrl(rclconfig->getDefCharset(), doc.url, url); printableUrl(rclconfig->getDefCharset(), doc.url, url);

View File

@ -1,5 +1,5 @@
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: docseq.cpp,v 1.10 2007-01-19 10:32:39 dockes Exp $ (C) 2005 J.F.Dockes"; static char rcsid[] = "@(#$Id: docseq.cpp,v 1.11 2008-09-29 08:59:20 dockes Exp $ (C) 2005 J.F.Dockes";
#endif #endif
/* /*
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -27,8 +27,7 @@ int DocSequence::getSeqSlice(int offs, int cnt, vector<ResListEntry>& result)
int ret = 0; int ret = 0;
for (int num = offs; num < offs + cnt; num++, ret++) { for (int num = offs; num < offs + cnt; num++, ret++) {
result.push_back(ResListEntry()); result.push_back(ResListEntry());
if (!getDoc(num, result.back().doc, &result.back().percent, if (!getDoc(num, result.back().doc, &result.back().subHeader)) {
&result.back().subHeader)) {
result.pop_back(); result.pop_back();
return ret; return ret;
} }

View File

@ -16,7 +16,7 @@
*/ */
#ifndef _DOCSEQ_H_INCLUDED_ #ifndef _DOCSEQ_H_INCLUDED_
#define _DOCSEQ_H_INCLUDED_ #define _DOCSEQ_H_INCLUDED_
/* @(#$Id: docseq.h,v 1.15 2008-09-28 07:40:56 dockes Exp $ (C) 2004 J.F.Dockes */ /* @(#$Id: docseq.h,v 1.16 2008-09-29 08:59:20 dockes Exp $ (C) 2004 J.F.Dockes */
#include <string> #include <string>
#include <list> #include <list>
#include <vector> #include <vector>
@ -31,9 +31,7 @@ using std::vector;
// A result list entry. // A result list entry.
struct ResListEntry { struct ResListEntry {
Rcl::Doc doc; Rcl::Doc doc;
int percent;
string subHeader; string subHeader;
ResListEntry() : percent(0) {}
}; };
/** Interface for a list of documents coming from some source. /** Interface for a list of documents coming from some source.
@ -50,17 +48,11 @@ class DocSequence {
* *
* @param num document rank in sequence * @param num document rank in sequence
* @param doc return data * @param doc return data
* @param percent this will be updated with the percentage of relevance, if
* available, depending on the type of sequence. Return -1 in there
* to indicate that the specified document data is
* unavailable but that there may be available data further
* in the sequence
* @param sh subheader to display before this result (ie: date change * @param sh subheader to display before this result (ie: date change
* inside history) * inside history)
* @return true if ok, false for error or end of data * @return true if ok, false for error or end of data
*/ */
virtual bool getDoc(int num, Rcl::Doc &doc, int *percent, string *sh = 0) virtual bool getDoc(int num, Rcl::Doc &doc, string *sh = 0) = 0;
= 0;
/** Get next page of documents. This accumulates entries into the result /** Get next page of documents. This accumulates entries into the result
* list (doesn't reset it). */ * list (doesn't reset it). */

View File

@ -1,5 +1,5 @@
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: docseqdb.cpp,v 1.6 2008-09-28 07:40:56 dockes Exp $ (C) 2005 J.F.Dockes"; static char rcsid[] = "@(#$Id: docseqdb.cpp,v 1.7 2008-09-29 08:59:20 dockes Exp $ (C) 2005 J.F.Dockes";
#endif #endif
/* /*
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -45,10 +45,10 @@ string DocSequenceDb::getDescription()
return m_sdata->getDescription(); return m_sdata->getDescription();
} }
bool DocSequenceDb::getDoc(int num, Rcl::Doc &doc, int *percent, string *sh) bool DocSequenceDb::getDoc(int num, Rcl::Doc &doc, string *sh)
{ {
if (sh) sh->erase(); if (sh) sh->erase();
return m_q->getDoc(num, doc, percent); return m_q->getDoc(num, doc);
} }
int DocSequenceDb::getResCnt() int DocSequenceDb::getResCnt()

View File

@ -16,7 +16,7 @@
*/ */
#ifndef _DOCSEQDB_H_INCLUDED_ #ifndef _DOCSEQDB_H_INCLUDED_
#define _DOCSEQDB_H_INCLUDED_ #define _DOCSEQDB_H_INCLUDED_
/* @(#$Id: docseqdb.h,v 1.4 2008-09-28 07:40:56 dockes Exp $ (C) 2004 J.F.Dockes */ /* @(#$Id: docseqdb.h,v 1.5 2008-09-29 08:59:20 dockes Exp $ (C) 2004 J.F.Dockes */
#include "docseq.h" #include "docseq.h"
#include "refcntr.h" #include "refcntr.h"
@ -30,7 +30,7 @@ class DocSequenceDb : public DocSequence {
DocSequenceDb(RefCntr<Rcl::Query> q, const string &t, DocSequenceDb(RefCntr<Rcl::Query> q, const string &t,
RefCntr<Rcl::SearchData> sdata); RefCntr<Rcl::SearchData> sdata);
virtual ~DocSequenceDb(); virtual ~DocSequenceDb();
virtual bool getDoc(int num, Rcl::Doc &doc, int *percent, string * = 0); virtual bool getDoc(int num, Rcl::Doc &doc, string * = 0);
virtual int getResCnt(); virtual int getResCnt();
virtual bool getTerms(vector<string>& terms, virtual bool getTerms(vector<string>& terms,
vector<vector<string> >& groups, vector<vector<string> >& groups,

View File

@ -1,5 +1,5 @@
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: docseqhist.cpp,v 1.3 2008-07-28 12:24:15 dockes Exp $ (C) 2005 J.F.Dockes"; static char rcsid[] = "@(#$Id: docseqhist.cpp,v 1.4 2008-09-29 08:59:20 dockes Exp $ (C) 2005 J.F.Dockes";
#endif #endif
/* /*
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -25,8 +25,7 @@ static char rcsid[] = "@(#$Id: docseqhist.cpp,v 1.3 2008-07-28 12:24:15 dockes E
#include "rcldb.h" #include "rcldb.h"
#include "fileudi.h" #include "fileudi.h"
bool DocSequenceHistory::getDoc(int num, Rcl::Doc &doc, int *percent, bool DocSequenceHistory::getDoc(int num, Rcl::Doc &doc, string *sh)
string *sh)
{ {
// Retrieve history list // Retrieve history list
if (!m_hist) if (!m_hist)
@ -47,8 +46,6 @@ bool DocSequenceHistory::getDoc(int num, Rcl::Doc &doc, int *percent,
m_prevnum = num; m_prevnum = num;
while (skip--) while (skip--)
m_it++; m_it++;
if (percent)
*percent = 100;
if (sh) { if (sh) {
if (m_prevtime < 0 || abs (float(m_prevtime) - float(m_it->unixtime)) > 86400) { if (m_prevtime < 0 || abs (float(m_prevtime) - float(m_it->unixtime)) > 86400) {
m_prevtime = m_it->unixtime; m_prevtime = m_it->unixtime;
@ -61,7 +58,7 @@ bool DocSequenceHistory::getDoc(int num, Rcl::Doc &doc, int *percent,
} }
string udi; string udi;
make_udi(m_it->fn, m_it->ipath, udi); make_udi(m_it->fn, m_it->ipath, udi);
bool ret = m_db->getDoc(udi, doc, percent); bool ret = m_db->getDoc(udi, doc);
if (!ret) { if (!ret) {
doc.url = string("file://") + m_it->fn; doc.url = string("file://") + m_it->fn;
doc.ipath = m_it->ipath; doc.ipath = m_it->ipath;

View File

@ -16,7 +16,7 @@
*/ */
#ifndef _DOCSEQHIST_H_INCLUDED_ #ifndef _DOCSEQHIST_H_INCLUDED_
#define _DOCSEQHIST_H_INCLUDED_ #define _DOCSEQHIST_H_INCLUDED_
/* @(#$Id: docseqhist.h,v 1.2 2007-01-19 15:22:50 dockes Exp $ (C) 2004 J.F.Dockes */ /* @(#$Id: docseqhist.h,v 1.3 2008-09-29 08:59:20 dockes Exp $ (C) 2004 J.F.Dockes */
#include "docseq.h" #include "docseq.h"
#include "history.h" #include "history.h"
@ -34,7 +34,7 @@ class DocSequenceHistory : public DocSequence {
: DocSequence(t), m_db(d), m_hist(h), m_prevnum(-1), m_prevtime(-1) {} : DocSequence(t), m_db(d), m_hist(h), m_prevnum(-1), m_prevtime(-1) {}
virtual ~DocSequenceHistory() {} virtual ~DocSequenceHistory() {}
virtual bool getDoc(int num, Rcl::Doc &doc, int *percent, string *sh = 0); virtual bool getDoc(int num, Rcl::Doc &doc, string *sh = 0);
virtual int getResCnt(); virtual int getResCnt();
virtual string getDescription() {return m_description;} virtual string getDescription() {return m_description;}
void setDescription(const string& desc) {m_description = desc;} void setDescription(const string& desc) {m_description = desc;}

View File

@ -1,5 +1,5 @@
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: filtseq.cpp,v 1.1 2008-09-28 07:40:56 dockes Exp $ (C) 2005 J.F.Dockes"; static char rcsid[] = "@(#$Id: filtseq.cpp,v 1.2 2008-09-29 08:59:20 dockes Exp $ (C) 2005 J.F.Dockes";
#endif #endif
/* /*
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -47,7 +47,7 @@ DocSeqFiltered::DocSeqFiltered(RefCntr<DocSequence> iseq,
{ {
} }
bool DocSeqFiltered::getDoc(int idx, Rcl::Doc &doc, int *percent, string *) bool DocSeqFiltered::getDoc(int idx, Rcl::Doc &doc, string *)
{ {
LOGDEB1(("DocSeqFiltered: fetching %d\n", idx)); LOGDEB1(("DocSeqFiltered: fetching %d\n", idx));
@ -61,23 +61,19 @@ bool DocSeqFiltered::getDoc(int idx, Rcl::Doc &doc, int *percent, string *)
// Loop until we get enough docs // Loop until we get enough docs
Rcl::Doc tdoc; Rcl::Doc tdoc;
int pc;
int i = 0; int i = 0;
while (idx >= (int)m_dbindices.size()) { while (idx >= (int)m_dbindices.size()) {
if (!m_seq->getDoc(backend_idx, tdoc, &pc)) if (!m_seq->getDoc(backend_idx, tdoc))
return false; return false;
if (filter(m_spec, &tdoc)) { if (filter(m_spec, &tdoc)) {
m_dbindices.push_back(backend_idx); m_dbindices.push_back(backend_idx);
} }
backend_idx++; backend_idx++;
} }
if (percent)
*percent = pc;
doc = tdoc; doc = tdoc;
} else { } else {
// The corresponding backend indice is already known // The corresponding backend indice is already known
if (!m_seq->getDoc(m_dbindices[idx], doc, percent)) if (!m_seq->getDoc(m_dbindices[idx], doc))
return false; return false;
} }
return true; return true;

View File

@ -16,7 +16,7 @@
*/ */
#ifndef _FILTSEQ_H_INCLUDED_ #ifndef _FILTSEQ_H_INCLUDED_
#define _FILTSEQ_H_INCLUDED_ #define _FILTSEQ_H_INCLUDED_
/* @(#$Id: filtseq.h,v 1.2 2008-09-28 14:20:50 dockes Exp $ (C) 2004 J.F.Dockes */ /* @(#$Id: filtseq.h,v 1.3 2008-09-29 08:59:20 dockes Exp $ (C) 2004 J.F.Dockes */
#include <vector> #include <vector>
#include <string> #include <string>
@ -47,7 +47,7 @@ class DocSeqFiltered : public DocSequence {
DocSeqFiltered(RefCntr<DocSequence> iseq, DocSeqFiltSpec &filtspec, DocSeqFiltered(RefCntr<DocSequence> iseq, DocSeqFiltSpec &filtspec,
const std::string &t); const std::string &t);
virtual ~DocSeqFiltered() {} virtual ~DocSeqFiltered() {}
virtual bool getDoc(int num, Rcl::Doc &doc, int *percent, string *sh = 0); virtual bool getDoc(int num, Rcl::Doc &doc, string *sh = 0);
virtual int getResCnt() {return m_seq->getResCnt();} virtual int getResCnt() {return m_seq->getResCnt();}
virtual string getAbstract(Rcl::Doc& doc) { virtual string getAbstract(Rcl::Doc& doc) {
return m_seq->getAbstract(doc); return m_seq->getAbstract(doc);

View File

@ -1,5 +1,5 @@
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: recollq.cpp,v 1.17 2008-09-29 06:58:25 dockes Exp $ (C) 2006 J.F.Dockes"; static char rcsid[] = "@(#$Id: recollq.cpp,v 1.18 2008-09-29 08:59:20 dockes Exp $ (C) 2006 J.F.Dockes";
#endif #endif
/* /*
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -239,16 +239,15 @@ int recollq(RclConfig **cfp, int argc, char **argv)
string tmpdir; string tmpdir;
for (int i = 0; i < limit; i++) { for (int i = 0; i < limit; i++) {
int pc;
Rcl::Doc doc; Rcl::Doc doc;
if (!query.getDoc(i, doc, &pc)) if (!query.getDoc(i, doc))
break; break;
if (op_flags & OPT_b) { if (op_flags & OPT_b) {
cout << doc.url.c_str() << endl; cout << doc.url.c_str() << endl;
} else { } else {
char cpc[20]; char cpc[20];
sprintf(cpc, "%d", pc); sprintf(cpc, "%d", doc.pc);
cout cout
<< doc.mimetype.c_str() << "\t" << doc.mimetype.c_str() << "\t"
<< "[" << doc.url.c_str() << "]" << "\t" << "[" << doc.url.c_str() << "]" << "\t"

View File

@ -1,5 +1,5 @@
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: sortseq.cpp,v 1.12 2008-09-28 14:20:50 dockes Exp $ (C) 2005 J.F.Dockes"; static char rcsid[] = "@(#$Id: sortseq.cpp,v 1.13 2008-09-29 08:59:20 dockes Exp $ (C) 2005 J.F.Dockes";
#endif #endif
/* /*
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -91,12 +91,10 @@ DocSeqSorted::DocSeqSorted(RefCntr<DocSequence> iseq, DocSeqSortSpec &sortspec,
m_docs.resize(m_spec.sortdepth); m_docs.resize(m_spec.sortdepth);
int i; int i;
for (i = 0; i < m_spec.sortdepth; i++) { for (i = 0; i < m_spec.sortdepth; i++) {
int percent; if (!iseq->getDoc(i, m_docs[i])) {
if (!iseq->getDoc(i, m_docs[i], &percent)) {
LOGERR(("DocSeqSorted: getDoc failed for doc %d\n", i)); LOGERR(("DocSeqSorted: getDoc failed for doc %d\n", i));
break; break;
} }
m_docs[i].pc = percent;
} }
m_spec.sortdepth = i; m_spec.sortdepth = i;
LOGDEB(("DocSeqSorted:: m_count %d\n", m_spec.sortdepth)); LOGDEB(("DocSeqSorted:: m_count %d\n", m_spec.sortdepth));
@ -109,14 +107,12 @@ DocSeqSorted::DocSeqSorted(RefCntr<DocSequence> iseq, DocSeqSortSpec &sortspec,
sort(m_docsp.begin(), m_docsp.end(), cmp); sort(m_docsp.begin(), m_docsp.end(), cmp);
} }
bool DocSeqSorted::getDoc(int num, Rcl::Doc &doc, int *percent, string *) bool DocSeqSorted::getDoc(int num, Rcl::Doc &doc, string *)
{ {
LOGDEB1(("DocSeqSorted: fetching %d\n", num)); LOGDEB1(("DocSeqSorted: fetching %d\n", num));
if (num >= m_spec.sortdepth) if (num >= m_spec.sortdepth)
return false; return false;
if (percent)
*percent = (*m_docsp[num]).pc;
doc = *m_docsp[num]; doc = *m_docsp[num];
return true; return true;
} }

View File

@ -16,7 +16,7 @@
*/ */
#ifndef _SORTSEQ_H_INCLUDED_ #ifndef _SORTSEQ_H_INCLUDED_
#define _SORTSEQ_H_INCLUDED_ #define _SORTSEQ_H_INCLUDED_
/* @(#$Id: sortseq.h,v 1.11 2008-09-28 14:20:50 dockes Exp $ (C) 2004 J.F.Dockes */ /* @(#$Id: sortseq.h,v 1.12 2008-09-29 08:59:20 dockes Exp $ (C) 2004 J.F.Dockes */
#include <vector> #include <vector>
#include <string> #include <string>
@ -48,7 +48,7 @@ class DocSeqSorted : public DocSequence {
DocSeqSorted(RefCntr<DocSequence> iseq, DocSeqSortSpec &sortspec, DocSeqSorted(RefCntr<DocSequence> iseq, DocSeqSortSpec &sortspec,
const std::string &t); const std::string &t);
virtual ~DocSeqSorted() {} virtual ~DocSeqSorted() {}
virtual bool getDoc(int num, Rcl::Doc &doc, int *percent, string *sh = 0); virtual bool getDoc(int num, Rcl::Doc &doc, string *sh = 0);
virtual int getResCnt() {return m_spec.sortdepth;} virtual int getResCnt() {return m_spec.sortdepth;}
virtual string getAbstract(Rcl::Doc& doc) { virtual string getAbstract(Rcl::Doc& doc) {
return m_seq->getAbstract(doc); return m_seq->getAbstract(doc);

View File

@ -1,5 +1,5 @@
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: rcldb.cpp,v 1.145 2008-09-16 08:18:30 dockes Exp $ (C) 2004 J.F.Dockes"; static char rcsid[] = "@(#$Id: rcldb.cpp,v 1.146 2008-09-29 08:59:20 dockes Exp $ (C) 2004 J.F.Dockes";
#endif #endif
/* /*
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -159,6 +159,7 @@ bool Db::Native::dbDataToRclDoc(Xapian::docid docid, std::string &data,
} }
char buf[20]; char buf[20];
sprintf(buf,"%.2f", float(percent) / 100.0); sprintf(buf,"%.2f", float(percent) / 100.0);
doc.pc = percent;
doc.meta[Doc::keyrr] = buf; doc.meta[Doc::keyrr] = buf;
parms.get(Doc::keyipt, doc.ipath); parms.get(Doc::keyipt, doc.ipath);
parms.get(Doc::keyfs, doc.fbytes); parms.get(Doc::keyfs, doc.fbytes);
@ -1554,7 +1555,7 @@ bool Db::makeDocAbstract(Doc &doc, Query *query, string& abstract)
} }
// Retrieve document defined by file name and internal path. // Retrieve document defined by file name and internal path.
bool Db::getDoc(const string &udi, Doc &doc, int *pc) bool Db::getDoc(const string &udi, Doc &doc)
{ {
LOGDEB(("Db:getDoc: [%s]\n", udi.c_str())); LOGDEB(("Db:getDoc: [%s]\n", udi.c_str()));
if (m_ndb == 0) if (m_ndb == 0)
@ -1562,8 +1563,7 @@ bool Db::getDoc(const string &udi, Doc &doc, int *pc)
// Initialize what we can in any case. If this is history, caller // Initialize what we can in any case. If this is history, caller
// will make partial display in case of error // will make partial display in case of error
if (*pc) doc.pc = 100;
*pc = 100;
string uniterm = make_uniterm(udi); string uniterm = make_uniterm(udi);
string ermsg; string ermsg;
@ -1572,8 +1572,7 @@ bool Db::getDoc(const string &udi, Doc &doc, int *pc)
// Document found in history no longer in the database. // Document found in history no longer in the database.
// We return true (because their might be other ok docs further) // We return true (because their might be other ok docs further)
// but indicate the error with pc = -1 // but indicate the error with pc = -1
if (*pc) doc.pc = -1;
*pc = -1;
LOGINFO(("Db:getDoc: no such doc in index: [%s] (len %d)\n", LOGINFO(("Db:getDoc: no such doc in index: [%s] (len %d)\n",
uniterm.c_str(), uniterm.length())); uniterm.c_str(), uniterm.length()));
return true; return true;

View File

@ -16,7 +16,7 @@
*/ */
#ifndef _DB_H_INCLUDED_ #ifndef _DB_H_INCLUDED_
#define _DB_H_INCLUDED_ #define _DB_H_INCLUDED_
/* @(#$Id: rcldb.h,v 1.62 2008-09-16 08:18:30 dockes Exp $ (C) 2004 J.F.Dockes */ /* @(#$Id: rcldb.h,v 1.63 2008-09-29 08:59:20 dockes Exp $ (C) 2004 J.F.Dockes */
#include <string> #include <string>
#include <list> #include <list>
@ -174,7 +174,7 @@ class Db {
* *
* Used by the 'history' feature (and nothing else?) * Used by the 'history' feature (and nothing else?)
*/ */
bool getDoc(const string &udi, Doc &doc, int *percent); bool getDoc(const string &udi, Doc &doc);
/* The following are mainly for the aspell module */ /* The following are mainly for the aspell module */
/** Whole term list walking. */ /** Whole term list walking. */

View File

@ -1,5 +1,5 @@
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: rclquery.cpp,v 1.7 2008-09-29 06:58:25 dockes Exp $ (C) 2008 J.F.Dockes"; static char rcsid[] = "@(#$Id: rclquery.cpp,v 1.8 2008-09-29 08:59:20 dockes Exp $ (C) 2008 J.F.Dockes";
#endif #endif
#include <stdlib.h> #include <stdlib.h>
@ -278,7 +278,7 @@ int Query::getResCnt()
// maintain a correspondance from the sequential external index // maintain a correspondance from the sequential external index
// sequence to the internal Xapian hole-y one (the holes being the documents // sequence to the internal Xapian hole-y one (the holes being the documents
// that dont match the filter). // that dont match the filter).
bool Query::getDoc(int exti, Doc &doc, int *percent) bool Query::getDoc(int exti, Doc &doc)
{ {
LOGDEB1(("Query::getDoc: exti %d\n", exti)); LOGDEB1(("Query::getDoc: exti %d\n", exti));
if (ISNULL(m_nq) || !m_nq->enquire) { if (ISNULL(m_nq) || !m_nq->enquire) {
@ -364,8 +364,6 @@ bool Query::getDoc(int exti, Doc &doc, int *percent)
Xapian::Document xdoc = m_nq->mset[xapi-first].get_document(); Xapian::Document xdoc = m_nq->mset[xapi-first].get_document();
Xapian::docid docid = *(m_nq->mset[xapi-first]); Xapian::docid docid = *(m_nq->mset[xapi-first]);
int pc = m_nq->mset.convert_to_percent(m_nq->mset[xapi-first]); int pc = m_nq->mset.convert_to_percent(m_nq->mset[xapi-first]);
if (percent)
*percent = pc;
// Parse xapian document's data and populate doc fields // Parse xapian document's data and populate doc fields
string data = xdoc.get_data(); string data = xdoc.get_data();

View File

@ -1,6 +1,6 @@
#ifndef _rclquery_h_included_ #ifndef _rclquery_h_included_
#define _rclquery_h_included_ #define _rclquery_h_included_
/* @(#$Id: rclquery.h,v 1.4 2008-09-29 06:58:25 dockes Exp $ (C) 2008 J.F.Dockes */ /* @(#$Id: rclquery.h,v 1.5 2008-09-29 08:59:20 dockes Exp $ (C) 2008 J.F.Dockes */
/* /*
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -70,7 +70,7 @@ class Query {
int getResCnt(); int getResCnt();
/** Get document at rank i in current query results. */ /** Get document at rank i in current query results. */
bool getDoc(int i, Doc &doc, int *percent = 0); bool getDoc(int i, Doc &doc);
/** Get possibly expanded list of query terms */ /** Get possibly expanded list of query terms */
bool getQueryTerms(list<string>& terms); bool getQueryTerms(list<string>& terms);