1st impl of catg filtering in reslist

This commit is contained in:
dockes
2008-09-28 14:20:50 +00:00
parent 66ffcc2b0b
commit 5d29d7504e
12 changed files with 169 additions and 67 deletions
+3 -1
View File
@@ -16,7 +16,7 @@
*/
#ifndef _FILTSEQ_H_INCLUDED_
#define _FILTSEQ_H_INCLUDED_
/* @(#$Id: filtseq.h,v 1.1 2008-09-28 07:40:56 dockes Exp $ (C) 2004 J.F.Dockes */
/* @(#$Id: filtseq.h,v 1.2 2008-09-28 14:20:50 dockes Exp $ (C) 2004 J.F.Dockes */
#include <vector>
#include <string>
@@ -34,6 +34,8 @@ class DocSeqFiltSpec {
}
std::vector<Crit> crits;
std::vector<string> values;
void reset() {crits.clear(); values.clear();}
bool isNotNull() {return crits.size() != 0;}
};
/**
+10 -10
View File
@@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: sortseq.cpp,v 1.11 2007-01-19 15:22:50 dockes Exp $ (C) 2005 J.F.Dockes";
static char rcsid[] = "@(#$Id: sortseq.cpp,v 1.12 2008-09-28 14:20:50 dockes Exp $ (C) 2005 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@@ -87,10 +87,10 @@ DocSeqSorted::DocSeqSorted(RefCntr<DocSequence> iseq, DocSeqSortSpec &sortspec,
: DocSequence(t), m_seq(iseq)
{
m_spec = sortspec;
LOGDEB(("DocSeqSorted:: count %d\n", m_spec.sortwidth));
m_docs.resize(m_spec.sortwidth);
LOGDEB(("DocSeqSorted:: count %d\n", m_spec.sortdepth));
m_docs.resize(m_spec.sortdepth);
int i;
for (i = 0; i < m_spec.sortwidth; i++) {
for (i = 0; i < m_spec.sortdepth; i++) {
int percent;
if (!iseq->getDoc(i, m_docs[i], &percent)) {
LOGERR(("DocSeqSorted: getDoc failed for doc %d\n", i));
@@ -98,11 +98,11 @@ DocSeqSorted::DocSeqSorted(RefCntr<DocSequence> iseq, DocSeqSortSpec &sortspec,
}
m_docs[i].pc = percent;
}
m_spec.sortwidth = i;
LOGDEB(("DocSeqSorted:: m_count %d\n", m_spec.sortwidth));
m_docs.resize(m_spec.sortwidth);
m_docsp.resize(m_spec.sortwidth);
for (i = 0; i < m_spec.sortwidth; i++)
m_spec.sortdepth = i;
LOGDEB(("DocSeqSorted:: m_count %d\n", m_spec.sortdepth));
m_docs.resize(m_spec.sortdepth);
m_docsp.resize(m_spec.sortdepth);
for (i = 0; i < m_spec.sortdepth; i++)
m_docsp[i] = &m_docs[i];
CompareDocs cmp(sortspec);
@@ -113,7 +113,7 @@ bool DocSeqSorted::getDoc(int num, Rcl::Doc &doc, int *percent, string *)
{
LOGDEB1(("DocSeqSorted: fetching %d\n", num));
if (num >= m_spec.sortwidth)
if (num >= m_spec.sortdepth)
return false;
if (percent)
*percent = (*m_docsp[num]).pc;
+6 -4
View File
@@ -16,7 +16,7 @@
*/
#ifndef _SORTSEQ_H_INCLUDED_
#define _SORTSEQ_H_INCLUDED_
/* @(#$Id: sortseq.h,v 1.10 2007-01-19 15:22:50 dockes Exp $ (C) 2004 J.F.Dockes */
/* @(#$Id: sortseq.h,v 1.11 2008-09-28 14:20:50 dockes Exp $ (C) 2004 J.F.Dockes */
#include <vector>
#include <string>
@@ -26,13 +26,15 @@
class DocSeqSortSpec {
public:
DocSeqSortSpec() : sortwidth(0) {}
int sortwidth; // We only re-sort the first sortwidth most relevant docs
DocSeqSortSpec() : sortdepth(0) {}
enum Field {RCLFLD_URL, RCLFLD_IPATH, RCLFLD_MIMETYPE, RCLFLD_MTIME};
void addCrit(Field fld, bool desc = false) {
crits.push_back(fld);
dirs.push_back(desc);
}
bool isNotNull() {return sortdepth > 0;}
int sortdepth; // We only re-sort the first sortdepth most relevant docs
std::vector<Field> crits;
std::vector<bool> dirs;
};
@@ -47,7 +49,7 @@ class DocSeqSorted : public DocSequence {
const std::string &t);
virtual ~DocSeqSorted() {}
virtual bool getDoc(int num, Rcl::Doc &doc, int *percent, string *sh = 0);
virtual int getResCnt() {return m_spec.sortwidth;}
virtual int getResCnt() {return m_spec.sortdepth;}
virtual string getAbstract(Rcl::Doc& doc) {
return m_seq->getAbstract(doc);
}