indents etc.
This commit is contained in:
parent
d207d4f1c5
commit
9abaf84be6
@ -81,8 +81,7 @@ bool DocSource::buildStack()
|
||||
}
|
||||
} else {
|
||||
if (m_fspec.isNotNull()) {
|
||||
m_seq =
|
||||
std::shared_ptr<DocSequence>(new DocSeqFiltered(m_config, m_seq, m_fspec));
|
||||
m_seq = std::shared_ptr<DocSequence>(new DocSeqFiltered(m_config, m_seq, m_fspec));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -31,14 +31,7 @@ using std::list;
|
||||
DocSequenceDb::DocSequenceDb(std::shared_ptr<Rcl::Db> db,
|
||||
std::shared_ptr<Rcl::Query> q, const string &t,
|
||||
std::shared_ptr<Rcl::SearchData> sdata)
|
||||
: DocSequence(t), m_db(db), m_q(q), m_sdata(sdata), m_fsdata(sdata),
|
||||
m_rescnt(-1),
|
||||
m_queryBuildAbstract(true),
|
||||
m_queryReplaceAbstract(false),
|
||||
m_isFiltered(false),
|
||||
m_isSorted(false),
|
||||
m_needSetQuery(false),
|
||||
m_lastSQStatus(true)
|
||||
: DocSequence(t), m_db(db), m_q(q), m_sdata(sdata), m_fsdata(sdata)
|
||||
{
|
||||
}
|
||||
|
||||
@ -161,8 +154,7 @@ bool DocSequenceDb::setFiltSpec(const DocSeqFiltSpec &fs)
|
||||
std::unique_lock<std::mutex> locker(o_dblock);
|
||||
if (fs.isNotNull()) {
|
||||
// We build a search spec by adding a filtering layer to the base one.
|
||||
m_fsdata = std::make_shared<Rcl::SearchData>(
|
||||
Rcl::SCLT_AND, m_sdata->getStemLang());
|
||||
m_fsdata = std::make_shared<Rcl::SearchData>(Rcl::SCLT_AND, m_sdata->getStemLang());
|
||||
Rcl::SearchDataClauseSub *cl = new Rcl::SearchDataClauseSub(m_sdata);
|
||||
m_fsdata->addClause(cl);
|
||||
|
||||
@ -171,22 +163,19 @@ bool DocSequenceDb::setFiltSpec(const DocSeqFiltSpec &fs)
|
||||
case DocSeqFiltSpec::DSFS_MIMETYPE:
|
||||
m_fsdata->addFiletype(fs.values[i]);
|
||||
break;
|
||||
case DocSeqFiltSpec::DSFS_QLANG:
|
||||
{
|
||||
case DocSeqFiltSpec::DSFS_QLANG: {
|
||||
if (!m_q)
|
||||
break;
|
||||
|
||||
string reason;
|
||||
auto sd = wasaStringToRcl(m_q->whatDb()->getConf(),
|
||||
m_sdata->getStemLang(),
|
||||
fs.values[i], reason);
|
||||
auto sd = wasaStringToRcl(
|
||||
m_q->whatDb()->getConf(), m_sdata->getStemLang(), fs.values[i], reason);
|
||||
if (sd) {
|
||||
Rcl::SearchDataClauseSub *cl1 =
|
||||
new Rcl::SearchDataClauseSub(sd);
|
||||
Rcl::SearchDataClauseSub *cl1 = new Rcl::SearchDataClauseSub(sd);
|
||||
m_fsdata->addClause(cl1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -226,8 +215,7 @@ bool DocSequenceDb::setQuery()
|
||||
m_lastSQStatus = m_q->setQuery(m_fsdata);
|
||||
if (!m_lastSQStatus) {
|
||||
m_reason = m_q->getReason();
|
||||
LOGERR("DocSequenceDb::setQuery: rclquery::setQuery failed: " <<
|
||||
m_reason << "\n");
|
||||
LOGERR("DocSequenceDb::setQuery: rclquery::setQuery failed: " << m_reason << "\n");
|
||||
}
|
||||
return m_lastSQStatus;
|
||||
}
|
||||
@ -241,4 +229,3 @@ bool DocSequenceDb::docDups(const Rcl::Doc& doc, std::vector<Rcl::Doc>& dups)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2004 J.F.Dockes
|
||||
/* Copyright (C) 2004-2021 J.F.Dockes
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
@ -25,10 +25,10 @@
|
||||
|
||||
/** A DocSequence from a Db query */
|
||||
class DocSequenceDb : public DocSequence {
|
||||
public:
|
||||
public:
|
||||
DocSequenceDb(std::shared_ptr<Rcl::Db> db,
|
||||
std::shared_ptr<Rcl::Query> q, const std::string &t,
|
||||
std::shared_ptr<Rcl::SearchData> sdata);
|
||||
std::shared_ptr<Rcl::SearchData> sdata);
|
||||
virtual ~DocSequenceDb() {}
|
||||
virtual bool getDoc(int num, Rcl::Doc &doc, std::string * = 0) override;
|
||||
virtual int getResCnt() override;
|
||||
@ -55,7 +55,7 @@ class DocSequenceDb : public DocSequence {
|
||||
}
|
||||
|
||||
virtual bool snippetsCapable() override {
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
virtual std::string title() override;
|
||||
|
||||
@ -68,13 +68,13 @@ private:
|
||||
std::shared_ptr<Rcl::Query> m_q;
|
||||
std::shared_ptr<Rcl::SearchData> m_sdata;
|
||||
std::shared_ptr<Rcl::SearchData> m_fsdata; // Filtered
|
||||
int m_rescnt;
|
||||
bool m_queryBuildAbstract;
|
||||
bool m_queryReplaceAbstract;
|
||||
bool m_isFiltered;
|
||||
bool m_isSorted;
|
||||
bool m_needSetQuery; // search data changed, need to reapply before fetch
|
||||
bool m_lastSQStatus;
|
||||
int m_rescnt{-1};
|
||||
bool m_queryBuildAbstract{true};
|
||||
bool m_queryReplaceAbstract{false};
|
||||
bool m_isFiltered{false};
|
||||
bool m_isSorted{false};
|
||||
bool m_needSetQuery{false}; // search data changed, need to reapply before fetch
|
||||
bool m_lastSQStatus{true};
|
||||
bool setQuery();
|
||||
};
|
||||
|
||||
|
||||
@ -125,31 +125,31 @@ bool DocSequenceHistory::getDoc(int num, Rcl::Doc &doc, string *sh)
|
||||
{
|
||||
// Retrieve history list
|
||||
if (!m_hist)
|
||||
return false;
|
||||
return false;
|
||||
if (m_history.empty())
|
||||
m_history = getDocHistory(m_hist);
|
||||
m_history = getDocHistory(m_hist);
|
||||
|
||||
if (num < 0 || num >= (int)m_history.size())
|
||||
return false;
|
||||
return false;
|
||||
|
||||
// We get the history oldest first, but our users expect newest first
|
||||
RclDHistoryEntry& hentry = m_history[m_history.size() - 1 - num];
|
||||
|
||||
if (sh) {
|
||||
if (m_prevtime < 0 || abs(m_prevtime - hentry.unixtime) > 86400) {
|
||||
m_prevtime = hentry.unixtime;
|
||||
time_t t = (time_t)(hentry.unixtime);
|
||||
*sh = string(ctime(&t));
|
||||
// Get rid of the final \n in ctime
|
||||
sh->erase(sh->length()-1);
|
||||
} else {
|
||||
sh->erase();
|
||||
if (m_prevtime < 0 || abs(m_prevtime - hentry.unixtime) > 86400) {
|
||||
m_prevtime = hentry.unixtime;
|
||||
time_t t = (time_t)(hentry.unixtime);
|
||||
*sh = string(ctime(&t));
|
||||
// Get rid of the final \n in ctime
|
||||
sh->erase(sh->length()-1);
|
||||
} else {
|
||||
sh->erase();
|
||||
}
|
||||
}
|
||||
|
||||
bool ret = m_db->getDoc(hentry.udi, hentry.dbdir, doc);
|
||||
if (!ret || doc.pc == -1) {
|
||||
doc.url = "UNKNOWN";
|
||||
doc.url = "UNKNOWN";
|
||||
doc.ipath = "";
|
||||
}
|
||||
|
||||
@ -163,7 +163,7 @@ bool DocSequenceHistory::getDoc(int num, Rcl::Doc &doc, string *sh)
|
||||
int DocSequenceHistory::getResCnt()
|
||||
{
|
||||
if (m_history.empty())
|
||||
m_history = getDocHistory(m_hist);
|
||||
m_history = getDocHistory(m_hist);
|
||||
return int(m_history.size());
|
||||
}
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@ static bool filter(const DocSeqFiltSpec& fs, const Rcl::Doc *x)
|
||||
case DocSeqFiltSpec::DSFS_QLANG: {
|
||||
LOGDEB(" filter: QLANG [" << fs.values[i] << "]!!\n");
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case DocSeqFiltSpec::DSFS_PASSALL:
|
||||
return true;
|
||||
}
|
||||
@ -74,7 +74,7 @@ bool DocSeqFiltered::setFiltSpec(const DocSeqFiltSpec &filtspec)
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@ -29,20 +29,22 @@ class RclConfig;
|
||||
/**
|
||||
* A filtered sequence is created from another one by selecting entries
|
||||
* according to the given criteria.
|
||||
* Note that this class can only filter on mime type (or rclcatg) at the moment,
|
||||
* and is only used for history. Normal query filtering is performed by adding a
|
||||
* clause to the Xapian query.
|
||||
*/
|
||||
class DocSeqFiltered : public DocSeqModifier {
|
||||
public:
|
||||
DocSeqFiltered(RclConfig *conf, std::shared_ptr<DocSequence> iseq,
|
||||
DocSeqFiltSpec &filtspec);
|
||||
DocSeqFiltered(RclConfig *conf, std::shared_ptr<DocSequence> iseq, DocSeqFiltSpec &filtspec);
|
||||
virtual ~DocSeqFiltered() {}
|
||||
virtual bool canFilter() {return true;}
|
||||
virtual bool setFiltSpec(const DocSeqFiltSpec &filtspec);
|
||||
virtual bool getDoc(int num, Rcl::Doc &doc, std::string *sh = 0);
|
||||
virtual int getResCnt() {return m_seq->getResCnt();}
|
||||
private:
|
||||
private:
|
||||
RclConfig *m_config;
|
||||
DocSeqFiltSpec m_spec;
|
||||
std::vector<int> m_dbindices;
|
||||
std::vector<int> m_dbindices;
|
||||
};
|
||||
|
||||
#endif /* _FILTSEQ_H_INCLUDED_ */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user