|
a/src/query/filtseq.cpp |
|
b/src/query/filtseq.cpp |
|
... |
|
... |
13 |
* along with this program; if not, write to the
|
13 |
* along with this program; if not, write to the
|
14 |
* Free Software Foundation, Inc.,
|
14 |
* Free Software Foundation, Inc.,
|
15 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
15 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
16 |
*/
|
16 |
*/
|
17 |
|
17 |
|
18 |
#include "debuglog.h"
|
18 |
#include "log.h"
|
19 |
#include "filtseq.h"
|
19 |
#include "filtseq.h"
|
20 |
#include "rclconfig.h"
|
20 |
#include "rclconfig.h"
|
21 |
|
21 |
|
22 |
using std::string;
|
22 |
using std::string;
|
23 |
|
23 |
|
24 |
static bool filter(const DocSeqFiltSpec& fs, const Rcl::Doc *x)
|
24 |
static bool filter(const DocSeqFiltSpec& fs, const Rcl::Doc *x)
|
25 |
{
|
25 |
{
|
26 |
LOGDEB2((" Filter: ncrits %d\n", fs.crits.size()));
|
26 |
LOGDEB2(" Filter: ncrits " << (fs.crits.size()) << "\n" );
|
27 |
// Compare using each criterion in term. We're doing an or:
|
27 |
// Compare using each criterion in term. We're doing an or:
|
28 |
// 1st ok ends
|
28 |
// 1st ok ends
|
29 |
for (unsigned int i = 0; i < fs.crits.size(); i++) {
|
29 |
for (unsigned int i = 0; i < fs.crits.size(); i++) {
|
30 |
switch (fs.crits[i]) {
|
30 |
switch (fs.crits[i]) {
|
31 |
case DocSeqFiltSpec::DSFS_MIMETYPE:
|
31 |
case DocSeqFiltSpec::DSFS_MIMETYPE:
|
32 |
LOGDEB2((" filter: MIMETYPE: me [%s] doc [%s]\n",
|
32 |
LOGDEB2(" filter: MIMETYPE: me [" << (fs.values[i]) << "] doc [" << (x->mimetype) << "]\n" );
|
33 |
fs.values[i].c_str(), x->mimetype.c_str()));
|
|
|
34 |
if (x->mimetype == fs.values[i])
|
33 |
if (x->mimetype == fs.values[i])
|
35 |
return true;
|
34 |
return true;
|
36 |
break;
|
35 |
break;
|
37 |
case DocSeqFiltSpec::DSFS_QLANG:
|
36 |
case DocSeqFiltSpec::DSFS_QLANG:
|
38 |
{
|
37 |
{
|
39 |
LOGDEB((" filter: QLANG [%s]!!\n", fs.values[i].c_str()));
|
38 |
LOGDEB(" filter: QLANG [" << (fs.values[i]) << "]!!\n" );
|
40 |
}
|
39 |
}
|
41 |
break;
|
40 |
break;
|
42 |
case DocSeqFiltSpec::DSFS_PASSALL:
|
41 |
case DocSeqFiltSpec::DSFS_PASSALL:
|
43 |
return true;
|
42 |
return true;
|
44 |
}
|
43 |
}
|
|
... |
|
... |
54 |
setFiltSpec(filtspec);
|
53 |
setFiltSpec(filtspec);
|
55 |
}
|
54 |
}
|
56 |
|
55 |
|
57 |
bool DocSeqFiltered::setFiltSpec(const DocSeqFiltSpec &filtspec)
|
56 |
bool DocSeqFiltered::setFiltSpec(const DocSeqFiltSpec &filtspec)
|
58 |
{
|
57 |
{
|
59 |
LOGDEB0(("DocSeqFiltered::setFiltSpec\n"));
|
58 |
LOGDEB0("DocSeqFiltered::setFiltSpec\n" );
|
60 |
for (unsigned int i = 0; i < filtspec.crits.size(); i++) {
|
59 |
for (unsigned int i = 0; i < filtspec.crits.size(); i++) {
|
61 |
switch (filtspec.crits[i]) {
|
60 |
switch (filtspec.crits[i]) {
|
62 |
case DocSeqFiltSpec::DSFS_MIMETYPE:
|
61 |
case DocSeqFiltSpec::DSFS_MIMETYPE:
|
63 |
m_spec.orCrit(filtspec.crits[i], filtspec.values[i]);
|
62 |
m_spec.orCrit(filtspec.crits[i], filtspec.values[i]);
|
64 |
break;
|
63 |
break;
|
|
... |
|
... |
72 |
string catg = val.substr(7);
|
71 |
string catg = val.substr(7);
|
73 |
vector<string> tps;
|
72 |
vector<string> tps;
|
74 |
m_config->getMimeCatTypes(catg, tps);
|
73 |
m_config->getMimeCatTypes(catg, tps);
|
75 |
for (vector<string>::const_iterator it = tps.begin();
|
74 |
for (vector<string>::const_iterator it = tps.begin();
|
76 |
it != tps.end(); it++) {
|
75 |
it != tps.end(); it++) {
|
77 |
LOGDEB2(("Adding mime: [%s]\n", it->c_str()));
|
76 |
LOGDEB2("Adding mime: [" << (it) << "]\n" );
|
78 |
m_spec.orCrit(DocSeqFiltSpec::DSFS_MIMETYPE, *it);
|
77 |
m_spec.orCrit(DocSeqFiltSpec::DSFS_MIMETYPE, *it);
|
79 |
}
|
78 |
}
|
80 |
}
|
79 |
}
|
81 |
}
|
80 |
}
|
82 |
break;
|
81 |
break;
|
|
... |
|
... |
92 |
return true;
|
91 |
return true;
|
93 |
}
|
92 |
}
|
94 |
|
93 |
|
95 |
bool DocSeqFiltered::getDoc(int idx, Rcl::Doc &doc, string *)
|
94 |
bool DocSeqFiltered::getDoc(int idx, Rcl::Doc &doc, string *)
|
96 |
{
|
95 |
{
|
97 |
LOGDEB2(("DocSeqFiltered::getDoc() fetching %d\n", idx));
|
96 |
LOGDEB2("DocSeqFiltered::getDoc() fetching " << (idx) << "\n" );
|
98 |
|
97 |
|
99 |
if (idx >= (int)m_dbindices.size()) {
|
98 |
if (idx >= (int)m_dbindices.size()) {
|
100 |
// Have to fetch docs and filter until we get enough or
|
99 |
// Have to fetch docs and filter until we get enough or
|
101 |
// fail
|
100 |
// fail
|
102 |
m_dbindices.reserve(idx+1);
|
101 |
m_dbindices.reserve(idx+1);
|
|
... |
|
... |
120 |
if (!m_seq->getDoc(m_dbindices[idx], doc))
|
119 |
if (!m_seq->getDoc(m_dbindices[idx], doc))
|
121 |
return false;
|
120 |
return false;
|
122 |
}
|
121 |
}
|
123 |
return true;
|
122 |
return true;
|
124 |
}
|
123 |
}
|
|
|
124 |
|