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
+2 -3
View File
@@ -1,5 +1,5 @@
#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
/*
* 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;
for (int num = offs; num < offs + cnt; num++, ret++) {
result.push_back(ResListEntry());
if (!getDoc(num, result.back().doc, &result.back().percent,
&result.back().subHeader)) {
if (!getDoc(num, result.back().doc, &result.back().subHeader)) {
result.pop_back();
return ret;
}
+2 -10
View File
@@ -16,7 +16,7 @@
*/
#ifndef _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 <list>
#include <vector>
@@ -31,9 +31,7 @@ using std::vector;
// A result list entry.
struct ResListEntry {
Rcl::Doc doc;
int percent;
string subHeader;
ResListEntry() : percent(0) {}
};
/** Interface for a list of documents coming from some source.
@@ -50,17 +48,11 @@ class DocSequence {
*
* @param num document rank in sequence
* @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
* inside history)
* @return true if ok, false for error or end of data
*/
virtual bool getDoc(int num, Rcl::Doc &doc, int *percent, string *sh = 0)
= 0;
virtual bool getDoc(int num, Rcl::Doc &doc, string *sh = 0) = 0;
/** Get next page of documents. This accumulates entries into the result
* list (doesn't reset it). */
+3 -3
View File
@@ -1,5 +1,5 @@
#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
/*
* This program is free software; you can redistribute it and/or modify
@@ -45,10 +45,10 @@ string DocSequenceDb::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();
return m_q->getDoc(num, doc, percent);
return m_q->getDoc(num, doc);
}
int DocSequenceDb::getResCnt()
+2 -2
View File
@@ -16,7 +16,7 @@
*/
#ifndef _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 "refcntr.h"
@@ -30,7 +30,7 @@ class DocSequenceDb : public DocSequence {
DocSequenceDb(RefCntr<Rcl::Query> q, const string &t,
RefCntr<Rcl::SearchData> sdata);
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 bool getTerms(vector<string>& terms,
vector<vector<string> >& groups,
+3 -6
View File
@@ -1,5 +1,5 @@
#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
/*
* 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 "fileudi.h"
bool DocSequenceHistory::getDoc(int num, Rcl::Doc &doc, int *percent,
string *sh)
bool DocSequenceHistory::getDoc(int num, Rcl::Doc &doc, string *sh)
{
// Retrieve history list
if (!m_hist)
@@ -47,8 +46,6 @@ bool DocSequenceHistory::getDoc(int num, Rcl::Doc &doc, int *percent,
m_prevnum = num;
while (skip--)
m_it++;
if (percent)
*percent = 100;
if (sh) {
if (m_prevtime < 0 || abs (float(m_prevtime) - float(m_it->unixtime)) > 86400) {
m_prevtime = m_it->unixtime;
@@ -61,7 +58,7 @@ bool DocSequenceHistory::getDoc(int num, Rcl::Doc &doc, int *percent,
}
string 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) {
doc.url = string("file://") + m_it->fn;
doc.ipath = m_it->ipath;
+2 -2
View File
@@ -16,7 +16,7 @@
*/
#ifndef _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 "history.h"
@@ -34,7 +34,7 @@ class DocSequenceHistory : public DocSequence {
: DocSequence(t), m_db(d), m_hist(h), m_prevnum(-1), m_prevtime(-1) {}
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 string getDescription() {return m_description;}
void setDescription(const string& desc) {m_description = desc;}
+4 -8
View File
@@ -1,5 +1,5 @@
#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
/*
* 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));
@@ -61,23 +61,19 @@ bool DocSeqFiltered::getDoc(int idx, Rcl::Doc &doc, int *percent, string *)
// Loop until we get enough docs
Rcl::Doc tdoc;
int pc;
int i = 0;
while (idx >= (int)m_dbindices.size()) {
if (!m_seq->getDoc(backend_idx, tdoc, &pc))
if (!m_seq->getDoc(backend_idx, tdoc))
return false;
if (filter(m_spec, &tdoc)) {
m_dbindices.push_back(backend_idx);
}
backend_idx++;
}
if (percent)
*percent = pc;
doc = tdoc;
} else {
// 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 true;
+2 -2
View File
@@ -16,7 +16,7 @@
*/
#ifndef _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 <string>
@@ -47,7 +47,7 @@ class DocSeqFiltered : public DocSequence {
DocSeqFiltered(RefCntr<DocSequence> iseq, DocSeqFiltSpec &filtspec,
const std::string &t);
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 string getAbstract(Rcl::Doc& doc) {
return m_seq->getAbstract(doc);
+3 -4
View File
@@ -1,5 +1,5 @@
#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
/*
* 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;
for (int i = 0; i < limit; i++) {
int pc;
Rcl::Doc doc;
if (!query.getDoc(i, doc, &pc))
if (!query.getDoc(i, doc))
break;
if (op_flags & OPT_b) {
cout << doc.url.c_str() << endl;
} else {
char cpc[20];
sprintf(cpc, "%d", pc);
sprintf(cpc, "%d", doc.pc);
cout
<< doc.mimetype.c_str() << "\t"
<< "[" << doc.url.c_str() << "]" << "\t"
+3 -7
View File
@@ -1,5 +1,5 @@
#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
/*
* 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);
int i;
for (i = 0; i < m_spec.sortdepth; i++) {
int percent;
if (!iseq->getDoc(i, m_docs[i], &percent)) {
if (!iseq->getDoc(i, m_docs[i])) {
LOGERR(("DocSeqSorted: getDoc failed for doc %d\n", i));
break;
}
m_docs[i].pc = percent;
}
m_spec.sortdepth = i;
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);
}
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));
if (num >= m_spec.sortdepth)
return false;
if (percent)
*percent = (*m_docsp[num]).pc;
doc = *m_docsp[num];
return true;
}
+2 -2
View File
@@ -16,7 +16,7 @@
*/
#ifndef _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 <string>
@@ -48,7 +48,7 @@ class DocSeqSorted : public DocSequence {
DocSeqSorted(RefCntr<DocSequence> iseq, DocSeqSortSpec &sortspec,
const std::string &t);
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 string getAbstract(Rcl::Doc& doc) {
return m_seq->getAbstract(doc);