Moved docsToPaths() method from confindexer to function in rcldoc to simplify linking. confindexer.o not in librecoll any more.+small std namespace fixes

This commit is contained in:
Jean-Francois Dockes 2017-04-24 10:15:44 +02:00
parent ecc4db774e
commit 91e66a13f9
10 changed files with 88 additions and 82 deletions

View File

@ -91,8 +91,6 @@ index/fsfetcher.cpp \
index/fsfetcher.h \
index/fsindexer.cpp \
index/fsindexer.h \
index/indexer.cpp \
index/indexer.h \
index/mimetype.cpp \
index/mimetype.h \
index/rclmon.h \
@ -289,6 +287,8 @@ endif
recollindex_SOURCES = \
index/recollindex.cpp \
index/indexer.cpp \
index/indexer.h \
index/rclmonprc.cpp \
index/rclmonrcv.cpp \
utils/x11mon.cpp \

View File

@ -23,7 +23,8 @@
*/
class BGLDocFetcher : public DocFetcher{
virtual bool fetch(RclConfig* cnf, const Rcl::Doc& idoc, RawDoc& out);
virtual bool makesig(RclConfig* cnf, const Rcl::Doc& idoc, string& sig);
virtual bool makesig(RclConfig* cnf, const Rcl::Doc& idoc,
std::string& sig);
virtual ~BGLDocFetcher() {}
};

View File

@ -66,7 +66,8 @@ public:
* @param idoc the data gathered from the index for this doc (udi/ipath)
* @param sig output.
*/
virtual bool makesig(RclConfig* cnf, const Rcl::Doc& idoc, string& sig) = 0;
virtual bool makesig(RclConfig* cnf, const Rcl::Doc& idoc,
std::string& sig) = 0;
virtual ~DocFetcher() {}
};

View File

@ -211,31 +211,6 @@ bool ConfIndexer::indexFiles(list<string>& ifiles, int flag)
return ret;
}
bool ConfIndexer::docsToPaths(vector<Rcl::Doc> &docs, vector<string> &paths)
{
for (vector<Rcl::Doc>::iterator it = docs.begin(); it != docs.end(); it++) {
Rcl::Doc &idoc = *it;
string backend;
idoc.getmeta(Rcl::Doc::keybcknd, &backend);
// This only makes sense for file system files: beagle docs are
// always up to date because they can't be updated in the cache,
// only added/removed. Same remark as made inside internfile, we
// need a generic way to handle backends.
if (!backend.empty() && backend.compare("FS"))
continue;
// Filesystem document. The url has to be like file://
if (idoc.url.find(cstr_fileu) != 0) {
LOGERR("idx::docsToPaths: FS backend and non fs url: [" <<
idoc.url << "]\n");
continue;
}
paths.push_back(idoc.url.substr(7, string::npos));
}
return true;
}
// Update index for specific documents. The docs come from an index
// query, so the udi, backend etc. fields are filled.
bool ConfIndexer::updateDocs(std::vector<Rcl::Doc> &docs, IxFlag flag)

View File

@ -132,7 +132,7 @@ class ConfIndexer {
/** Update index for list of documents given as list of docs (out of query)
*/
bool updateDocs(vector<Rcl::Doc> &docs, IxFlag f = IxFNone);
static bool docsToPaths(vector<Rcl::Doc> &docs, vector<string> &paths);
/** Purge a list of files. */
bool purgeFiles(list<string> &files, int f = IxFNone);

View File

@ -428,7 +428,7 @@ void RclMain::updateIdxForDocs(vector<Rcl::Doc>& docs)
}
vector<string> paths;
if (ConfIndexer::docsToPaths(docs, paths)) {
if (Rcl::docsToPaths(docs, paths)) {
vector<string> args{"-c", theconfig->getConfDir(), "-e", "-i"};
args.insert(args.end(), paths.begin(), paths.end());
m_idxproc = new ExecCmd;

View File

@ -236,7 +236,7 @@ string QtGuiResListPager::iconUrl(RclConfig *config, Rcl::Doc& doc)
vector<Rcl::Doc> docs;
docs.push_back(doc);
vector<string> paths;
ConfIndexer::docsToPaths(docs, paths);
Rcl::docsToPaths(docs, paths);
if (!paths.empty()) {
string path;
LOGDEB2("ResList::iconUrl: source path [" << paths[0] << "]\n");

View File

@ -117,7 +117,7 @@ string ResTablePager::iconUrl(RclConfig *config, Rcl::Doc& doc)
vector<Rcl::Doc> docs;
docs.push_back(doc);
vector<string> paths;
ConfIndexer::docsToPaths(docs, paths);
Rcl::docsToPaths(docs, paths);
if (!paths.empty()) {
string path;
if (thumbPathForUrl(cstr_fileu + paths[0], 128, path)) {

View File

@ -20,6 +20,8 @@
#include "log.h"
#include "rclutil.h"
using namespace std;
namespace Rcl {
const string Doc::keyabs("abstract");
const string Doc::keyapptg("rclaptg");
@ -97,6 +99,33 @@ namespace Rcl {
d->haschildren = haschildren;
d->onlyxattr = onlyxattr;
}
static const string cstr_fileu("file://");
bool docsToPaths(vector<Rcl::Doc> &docs, vector<string> &paths)
{
for (vector<Rcl::Doc>::iterator it = docs.begin(); it != docs.end(); it++) {
Rcl::Doc &idoc = *it;
string backend;
idoc.getmeta(Rcl::Doc::keybcknd, &backend);
// This only makes sense for file system files: beagle docs are
// always up to date because they can't be updated in the cache,
// only added/removed. Same remark as made inside internfile, we
// need a generic way to handle backends.
if (!backend.empty() && backend.compare("FS"))
continue;
// Filesystem document. The url has to be like file://
if (idoc.url.find(cstr_fileu) != 0) {
LOGERR("idx::docsToPaths: FS backend and non fs url: [" <<
idoc.url << "]\n");
continue;
}
paths.push_back(idoc.url.substr(7, string::npos));
}
return true;
}
}

View File

@ -19,8 +19,7 @@
#include <string>
#include <map>
using std::string;
using std::map;
#include <vector>
#include "smallut.h"
@ -46,33 +45,33 @@ class Doc {
// Binary or url-encoded url. No transcoding: this is used to access files
// Index: computed by Db::add caller.
// Query: from doc data.
string url;
std::string url;
// When we do path translation for documents from external indexes, we
// save the original path:
string idxurl;
std::string idxurl;
// And the originating db. 0 is base, 1 first external etc.
int idxi;
// Internal path for multi-doc files. Ascii
// Set by FsIndexer::processone
string ipath;
std::string ipath;
// Mime type. Set by FileInterner::internfile
string mimetype;
std::string mimetype;
// File modification time as decimal ascii unix time
// Set by FsIndexer::processone
string fmtime;
std::string fmtime;
// Data reference date (same format). Ie: mail date
// Possibly set by mimetype-specific handler
// Filter::metaData["modificationdate"]
string dmtime;
std::string dmtime;
// Charset we transcoded the 'text' field from (in case we want back)
// Possibly set by handler
string origcharset;
std::string origcharset;
// A map for textual metadata like, author, keywords, abstract,
// title. The entries are possibly set by the mimetype-specific
@ -81,7 +80,7 @@ class Doc {
// Only some predefined fields are stored in the data record:
// "title", "keywords", "abstract", "author", but if a field name is
// in the "stored" configuration list, it will be stored too.
map<string, string> meta;
std::map<std::string, std::string> meta;
// Attribute for the "abstract" entry. true if it is just the top
// of doc, not a native document attribute. Not stored directly, but
@ -92,23 +91,23 @@ class Doc {
// external containing archive.
// Index: Set by caller prior to Db::Add.
// Query: Set from data record
string pcbytes;
std::string pcbytes;
// Document size, ie, size of the .odt or .xls.
// Index: Set in internfile from the filter stack
// Query: set from data record
string fbytes;
std::string fbytes;
// Doc text size.
// Index: from text.length().
// Query: set by rcldb from index data record
string dbytes;
std::string dbytes;
// Doc signature. Used for up to date checks.
// Index: set by Db::Add caller. Query: set from doc data.
// This is opaque to rcldb, and could just as well be ctime, size,
// ctime+size, md5, whatever.
string sig;
std::string sig;
/////////////////////////////////////////////////
// The following fields don't go to the db record, so they can't
@ -116,7 +115,7 @@ class Doc {
// Main document text. This is plaintext utf-8 text to be split
// and indexed
string text;
std::string text;
/////////////////////////////////////////////////
// Misc stuff
@ -170,9 +169,9 @@ class Doc {
haspages(false), haschildren(false), onlyxattr(false) {
}
/** Get value for named field. If value pointer is 0, just test existence */
bool getmeta(const string& nm, string *value = 0) const
bool getmeta(const std::string& nm, std::string *value = 0) const
{
map<string,string>::const_iterator it = meta.find(nm);
const auto it = meta.find(nm);
if (it != meta.end()) {
if (value)
*value = it->second;
@ -182,9 +181,9 @@ class Doc {
}
}
/** Nocopy getvalue. sets pointer to entry value if exists */
bool peekmeta(const string& nm, const string **value = 0) const
bool peekmeta(const std::string& nm, const std::string **value = 0) const
{
map<string,string>::const_iterator it = meta.find(nm);
const auto it = meta.find(nm);
if (it != meta.end()) {
if (value)
*value = &(it->second);
@ -195,9 +194,9 @@ class Doc {
}
// Create entry or append text to existing entry.
bool addmeta(const string& nm, const string& value)
bool addmeta(const std::string& nm, const std::string& value)
{
map<string,string>::iterator mit = meta.find(nm);
auto mit = meta.find(nm);
if (mit == meta.end()) {
meta[nm] = value;
} else if (mit->second.empty()) {
@ -206,7 +205,7 @@ class Doc {
// It may happen that the same attr exists several times
// in the internfile stack. Avoid duplicating values.
if (mit->second != value)
mit->second += string(" - ") + value;
mit->second += std::string(" - ") + value;
}
return true;
}
@ -215,7 +214,7 @@ class Doc {
* (as opposed to e.g. a webcache file), not a subdoc,
*/
bool isFsFile() {
string backend;
std::string backend;
getmeta(keybcknd, &backend);
if (!backend.empty() && backend.compare("FS"))
return false;
@ -232,10 +231,10 @@ class Doc {
// author), _must_ use these canonical values, not aliases. This is
// enforced in internfile.cpp and misc other bits of metadata-gathering
// code
static const string keyurl; // url
static const std::string keyurl; // url
// childurl. This is set when working with the parent of the result, to hold
// the child of interest url, typically to highlight a directory entry
static const string keychildurl;
static const std::string keychildurl;
// file name. This is set for filesystem-level containers or
// documents, and not inherited by subdocuments (which can get a
// keyfn anyway from, e.g, an attachment filename value). Subdocs
@ -243,37 +242,38 @@ class Doc {
// usually don't want to see all subdocs when searching for the
// file name). Instead the container file name is now set in the
// document record but not indexed (see next entry).
static const string keyfn;
static const std::string keyfn;
// Container file name. This is set for all subdocuments of a
// given top level container. It is not indexed by default but
// stored in the document record keyfn field if this is still
// empty when we create it, for display purposes.
static const string keytcfn;
static const string keyipt; // ipath
static const string keytp; // mime type
static const string keyfmt; // file mtime
static const string keydmt; // document mtime
static const string keymt; // mtime dmtime if set else fmtime
static const string keyoc; // original charset
static const string keypcs; // document outer container size
static const string keyfs; // document size
static const string keyds; // document text size
static const string keysz; // dbytes if set else fbytes else pcbytes
static const string keysig; // sig
static const string keyrr; // relevancy rating
static const string keycc; // Collapse count
static const string keyabs; // abstract
static const string keyau; // author
static const string keytt; // title
static const string keykw; // keywords
static const string keymd5; // file md5 checksum
static const string keybcknd; // backend type for data not from the filesys
static const std::string keytcfn;
static const std::string keyipt; // ipath
static const std::string keytp; // mime type
static const std::string keyfmt; // file mtime
static const std::string keydmt; // document mtime
static const std::string keymt; // mtime dmtime if set else fmtime
static const std::string keyoc; // original charset
static const std::string keypcs; // document outer container size
static const std::string keyfs; // document size
static const std::string keyds; // document text size
static const std::string keysz; // dbytes if set else fbytes else pcbytes
static const std::string keysig; // sig
static const std::string keyrr; // relevancy rating
static const std::string keycc; // Collapse count
static const std::string keyabs; // abstract
static const std::string keyau; // author
static const std::string keytt; // title
static const std::string keykw; // keywords
static const std::string keymd5; // file md5 checksum
static const std::string keybcknd; // backend type for data not from the filesys
// udi back from index. Only set by Rcl::Query::getdoc().
static const string keyudi;
static const string keyapptg; // apptag. Set from localfields (fsindexer)
static const string keybght; // beagle hit type ("beagleHitType")
static const std::string keyudi;
static const std::string keyapptg; // apptag. Set from localfields (fsindexer)
static const std::string keybght; // beagle hit type ("beagleHitType")
};
extern bool docsToPaths(std::vector<Doc> &docs,std::vector<std::string> &paths);
}