separated rcldb and rclquery
This commit is contained in:
+2
-2
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
#ifndef _DOCSEQ_H_INCLUDED_
|
||||
#define _DOCSEQ_H_INCLUDED_
|
||||
/* @(#$Id: docseq.h,v 1.12 2007-06-19 08:36:24 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
/* @(#$Id: docseq.h,v 1.13 2008-06-13 18:22:46 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
@@ -89,7 +89,7 @@ class DocSequence {
|
||||
vector<int>& gslks) const {
|
||||
terms.clear(); groups.clear(); gslks.clear(); return true;
|
||||
}
|
||||
|
||||
virtual list<string> expand(Rcl::Doc &) {list<string> e; return e;}
|
||||
private:
|
||||
string m_title;
|
||||
};
|
||||
|
||||
+32
-7
@@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: docseqdb.cpp,v 1.3 2007-06-19 08:36:24 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: docseqdb.cpp,v 1.4 2008-06-13 18:22:46 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -23,28 +23,53 @@ static char rcsid[] = "@(#$Id: docseqdb.cpp,v 1.3 2007-06-19 08:36:24 dockes Exp
|
||||
#include "docseqdb.h"
|
||||
#include "rcldb.h"
|
||||
|
||||
DocSequenceDb::DocSequenceDb(RefCntr<Rcl::Query> q, const string &t,
|
||||
RefCntr<Rcl::SearchData> sdata)
|
||||
: DocSequence(t), m_q(q), m_sdata(sdata), m_rescnt(-1)
|
||||
{
|
||||
}
|
||||
|
||||
DocSequenceDb::~DocSequenceDb()
|
||||
{
|
||||
}
|
||||
|
||||
bool DocSequenceDb::getTerms(vector<string>& terms,
|
||||
vector<vector<string> >& groups,
|
||||
vector<int>& gslks) const
|
||||
{
|
||||
return m_sdata.getptr()->getTerms(terms, groups, gslks);
|
||||
}
|
||||
|
||||
string DocSequenceDb::getDescription()
|
||||
{
|
||||
return m_sdata->getDescription();
|
||||
}
|
||||
|
||||
bool DocSequenceDb::getDoc(int num, Rcl::Doc &doc, int *percent, string *sh)
|
||||
{
|
||||
if (sh) sh->erase();
|
||||
return m_db ? m_db->getDoc(num, doc, percent) : false;
|
||||
return m_q->getDoc(num, doc, percent);
|
||||
}
|
||||
|
||||
int DocSequenceDb::getResCnt()
|
||||
{
|
||||
if (!m_db)
|
||||
return -1;
|
||||
if (m_rescnt < 0) {
|
||||
m_rescnt= m_db->getResCnt();
|
||||
m_rescnt= m_q->getResCnt();
|
||||
}
|
||||
return m_rescnt;
|
||||
}
|
||||
|
||||
string DocSequenceDb::getAbstract(Rcl::Doc &doc)
|
||||
{
|
||||
if (!m_db)
|
||||
if (!m_q->whatDb())
|
||||
return doc.meta["abstract"];
|
||||
string abstract;
|
||||
m_db->makeDocAbstract(doc, abstract);
|
||||
m_q->whatDb()->makeDocAbstract(doc, m_q.getptr(), abstract);
|
||||
return abstract.empty() ? doc.meta["abstract"] : abstract;
|
||||
}
|
||||
|
||||
list<string> DocSequenceDb::expand(Rcl::Doc &doc)
|
||||
{
|
||||
return m_q->expand(doc);
|
||||
}
|
||||
|
||||
|
||||
+9
-12
@@ -16,33 +16,30 @@
|
||||
*/
|
||||
#ifndef _DOCSEQDB_H_INCLUDED_
|
||||
#define _DOCSEQDB_H_INCLUDED_
|
||||
/* @(#$Id: docseqdb.h,v 1.2 2007-01-19 15:22:50 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
/* @(#$Id: docseqdb.h,v 1.3 2008-06-13 18:22:46 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
#include "docseq.h"
|
||||
#include "refcntr.h"
|
||||
|
||||
#include "searchdata.h"
|
||||
#include "rclquery.h"
|
||||
|
||||
/** A DocSequence from a Db query (there should be one active for this
|
||||
to make sense) */
|
||||
class DocSequenceDb : public DocSequence {
|
||||
public:
|
||||
DocSequenceDb(Rcl::Db *d, const string &t, RefCntr<Rcl::SearchData> sdata)
|
||||
: DocSequence(t), m_db(d), m_sdata(sdata), m_rescnt(-1)
|
||||
{}
|
||||
virtual ~DocSequenceDb() {}
|
||||
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 int getResCnt();
|
||||
virtual bool getTerms(vector<string>& terms,
|
||||
vector<vector<string> >& groups,
|
||||
vector<int>& gslks) const {
|
||||
return m_sdata.getptr()->getTerms(terms, groups, gslks);
|
||||
}
|
||||
|
||||
vector<int>& gslks) const;
|
||||
virtual string getAbstract(Rcl::Doc &doc);
|
||||
virtual string getDescription() {return m_sdata->getDescription();}
|
||||
|
||||
virtual string getDescription();
|
||||
virtual list<string> expand(Rcl::Doc &doc);
|
||||
private:
|
||||
Rcl::Db *m_db;
|
||||
RefCntr<Rcl::Query> m_q;
|
||||
RefCntr<Rcl::SearchData> m_sdata;
|
||||
int m_rescnt;
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: recollq.cpp,v 1.12 2007-12-13 06:58:21 dockes Exp $ (C) 2006 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: recollq.cpp,v 1.13 2008-06-13 18:22:46 dockes Exp $ (C) 2006 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -32,6 +32,7 @@ static char rcsid[] = "@(#$Id: recollq.cpp,v 1.12 2007-12-13 06:58:21 dockes Exp
|
||||
using namespace std;
|
||||
|
||||
#include "rcldb.h"
|
||||
#include "rclquery.h"
|
||||
#include "rclconfig.h"
|
||||
#include "pathut.h"
|
||||
#include "rclinit.h"
|
||||
@@ -132,8 +133,7 @@ int recollq(RclConfig **cfp, int argc, char **argv)
|
||||
exit(1);
|
||||
}
|
||||
dbdir = rclconfig->getDbDir();
|
||||
rcldb.open(dbdir, rclconfig->getStopfile(),
|
||||
Rcl::Db::DbRO, Rcl::Db::QO_STEM);
|
||||
rcldb.open(dbdir, rclconfig->getStopfile(), Rcl::Db::DbRO);
|
||||
|
||||
Rcl::SearchData *sd = 0;
|
||||
|
||||
@@ -166,8 +166,9 @@ int recollq(RclConfig **cfp, int argc, char **argv)
|
||||
}
|
||||
|
||||
RefCntr<Rcl::SearchData> rq(sd);
|
||||
rcldb.setQuery(rq, Rcl::Db::QO_STEM);
|
||||
int cnt = rcldb.getResCnt();
|
||||
Rcl::Query query(&rcldb);
|
||||
query.setQuery(rq, Rcl::Query::QO_STEM);
|
||||
int cnt = query.getResCnt();
|
||||
if (!(op_flags & OPT_b)) {
|
||||
cout << "Recoll query: " << rq->getDescription() << endl;
|
||||
if (cnt <= limit)
|
||||
@@ -180,7 +181,7 @@ int recollq(RclConfig **cfp, int argc, char **argv)
|
||||
for (int i = 0; i < limit; i++) {
|
||||
int pc;
|
||||
Rcl::Doc doc;
|
||||
if (!rcldb.getDoc(i, doc, &pc))
|
||||
if (!query.getDoc(i, doc, &pc))
|
||||
break;
|
||||
|
||||
if (op_flags & OPT_b) {
|
||||
|
||||
Reference in New Issue
Block a user