cleaning up static variables
This commit is contained in:
parent
b28eaf23fb
commit
01f24fa5fd
@ -506,7 +506,7 @@ string Db::Native::makeAbstract(Xapian::docid docid, Query *query)
|
|||||||
Db::Db(RclConfig *cfp)
|
Db::Db(RclConfig *cfp)
|
||||||
: m_ndb(0), m_config(cfp), m_idxAbsTruncLen(250), m_synthAbsLen(250),
|
: m_ndb(0), m_config(cfp), m_idxAbsTruncLen(250), m_synthAbsLen(250),
|
||||||
m_synthAbsWordCtxLen(4), m_flushMb(-1),
|
m_synthAbsWordCtxLen(4), m_flushMb(-1),
|
||||||
m_curtxtsz(0), m_flushtxtsz(0), m_occtxtsz(0),
|
m_curtxtsz(0), m_flushtxtsz(0), m_occtxtsz(0), m_occFirstCheck(1),
|
||||||
m_maxFsOccupPc(0), m_mode(Db::DbRO)
|
m_maxFsOccupPc(0), m_mode(Db::DbRO)
|
||||||
{
|
{
|
||||||
m_ndb = new Native(this);
|
m_ndb = new Native(this);
|
||||||
@ -748,12 +748,15 @@ bool Db::isopen()
|
|||||||
// reason (old config not updated ?). We use it only if the config
|
// reason (old config not updated ?). We use it only if the config
|
||||||
// translation fails. Also we add in there fields which should be
|
// translation fails. Also we add in there fields which should be
|
||||||
// indexed with no prefix (ie: abstract)
|
// indexed with no prefix (ie: abstract)
|
||||||
bool Db::fieldToPrefix(const string& fld, string &pfx)
|
|
||||||
{
|
// Default table. We prefer the data from rclconfig if available. Note
|
||||||
// This is the default table. We prefer the data from rclconfig if
|
// that it is logically const after initialization. This would be
|
||||||
// available
|
// simpler with c0xx initializer lists.
|
||||||
static map<string, string> fldToPrefs;
|
static map<string, string> fldToPrefs;
|
||||||
if (fldToPrefs.empty()) {
|
class InitFldToPrefs {
|
||||||
|
public:
|
||||||
|
InitFldToPrefs()
|
||||||
|
{
|
||||||
fldToPrefs[Doc::keyabs] = string();
|
fldToPrefs[Doc::keyabs] = string();
|
||||||
fldToPrefs["ext"] = "XE";
|
fldToPrefs["ext"] = "XE";
|
||||||
fldToPrefs[Doc::keyfn] = "XSFN";
|
fldToPrefs[Doc::keyfn] = "XSFN";
|
||||||
@ -775,7 +778,11 @@ bool Db::fieldToPrefix(const string& fld, string &pfx)
|
|||||||
fldToPrefs["xapyearmon"] = "M";
|
fldToPrefs["xapyearmon"] = "M";
|
||||||
fldToPrefs["xapdate"] = "D";
|
fldToPrefs["xapdate"] = "D";
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
static InitFldToPrefs IFTP;
|
||||||
|
|
||||||
|
bool Db::fieldToPrefix(const string& fld, string &pfx)
|
||||||
|
{
|
||||||
if (m_config && m_config->getFieldPrefix(fld, pfx))
|
if (m_config && m_config->getFieldPrefix(fld, pfx))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -876,12 +883,12 @@ bool Db::addOrUpdate(const string &udi, const string &parent_udi,
|
|||||||
udi.c_str(), parent_udi.c_str()));
|
udi.c_str(), parent_udi.c_str()));
|
||||||
if (m_ndb == 0)
|
if (m_ndb == 0)
|
||||||
return false;
|
return false;
|
||||||
static int first = 1;
|
|
||||||
// Check file system full every mbyte of indexed text.
|
// Check file system full every mbyte of indexed text.
|
||||||
if (m_maxFsOccupPc > 0 && (first || (m_curtxtsz - m_occtxtsz) / MB >= 1)) {
|
if (m_maxFsOccupPc > 0 &&
|
||||||
|
(m_occFirstCheck || (m_curtxtsz - m_occtxtsz) / MB >= 1)) {
|
||||||
LOGDEB(("Db::add: checking file system usage\n"));
|
LOGDEB(("Db::add: checking file system usage\n"));
|
||||||
int pc;
|
int pc;
|
||||||
first = 0;
|
m_occFirstCheck = 0;
|
||||||
if (fsocc(m_basedir, &pc) && pc >= m_maxFsOccupPc) {
|
if (fsocc(m_basedir, &pc) && pc >= m_maxFsOccupPc) {
|
||||||
LOGERR(("Db::add: stop indexing: file system "
|
LOGERR(("Db::add: stop indexing: file system "
|
||||||
"%d%% full > max %d%%\n", pc, m_maxFsOccupPc));
|
"%d%% full > max %d%%\n", pc, m_maxFsOccupPc));
|
||||||
|
|||||||
@ -232,6 +232,8 @@ private:
|
|||||||
long long m_flushtxtsz;
|
long long m_flushtxtsz;
|
||||||
// Text bytes at last fsoccup check
|
// Text bytes at last fsoccup check
|
||||||
long long m_occtxtsz;
|
long long m_occtxtsz;
|
||||||
|
// First fs occup check ?
|
||||||
|
int m_occFirstCheck;
|
||||||
// Maximum file system occupation percentage
|
// Maximum file system occupation percentage
|
||||||
int m_maxFsOccupPc;
|
int m_maxFsOccupPc;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user