|
a/src/rcldb/rcldb.cpp |
|
b/src/rcldb/rcldb.cpp |
|
... |
|
... |
1121 |
}
|
1121 |
}
|
1122 |
|
1122 |
|
1123 |
// Determining what index a doc result comes from is based on the
|
1123 |
// Determining what index a doc result comes from is based on the
|
1124 |
// modulo of the docid against the db count. Ref:
|
1124 |
// modulo of the docid against the db count. Ref:
|
1125 |
// http://trac.xapian.org/wiki/FAQ/MultiDatabaseDocumentID
|
1125 |
// http://trac.xapian.org/wiki/FAQ/MultiDatabaseDocumentID
|
1126 |
size_t Db::whatDbIdx(const Doc& doc)
|
1126 |
bool Db::fromMainIndex(const Doc& doc)
|
1127 |
{
|
1127 |
{
|
1128 |
return m_ndb->whatDbIdx(doc.xdocid);
|
1128 |
return m_ndb->whatDbIdx(doc.xdocid) == 0;
|
|
|
1129 |
}
|
|
|
1130 |
|
|
|
1131 |
std::string Db::whatIndexForResultDoc(const Doc& doc)
|
|
|
1132 |
{
|
|
|
1133 |
size_t idx = m_ndb->whatDbIdx(doc.xdocid);
|
|
|
1134 |
if (idx == (size_t)-1) {
|
|
|
1135 |
LOGERR("whatIndexForResultDoc: whatDbIdx returned -1 for " <<
|
|
|
1136 |
doc.xdocid << endl);
|
|
|
1137 |
return string();
|
|
|
1138 |
}
|
|
|
1139 |
// idx is [0..m_extraDbs.size()] 0 is for the main index, else
|
|
|
1140 |
// idx-1 indexes into m_extraDbs
|
|
|
1141 |
if (idx == 0) {
|
|
|
1142 |
return m_basedir;
|
|
|
1143 |
} else {
|
|
|
1144 |
return m_extraDbs[idx-1];
|
|
|
1145 |
}
|
1129 |
}
|
1146 |
}
|
1130 |
|
1147 |
|
1131 |
size_t Db::Native::whatDbIdx(Xapian::docid id)
|
1148 |
size_t Db::Native::whatDbIdx(Xapian::docid id)
|
1132 |
{
|
1149 |
{
|
1133 |
LOGDEB1("Db::whatDbIdx: xdocid " << id << ", " <<
|
1150 |
LOGDEB1("Db::whatDbIdx: xdocid " << id << ", " <<
|
|
... |
|
... |
2350 |
// by the GUI history feature and by open parent/getenclosing
|
2367 |
// by the GUI history feature and by open parent/getenclosing
|
2351 |
// ! The return value is always true except for fatal errors. Document
|
2368 |
// ! The return value is always true except for fatal errors. Document
|
2352 |
// existence should be tested by looking at doc.pc
|
2369 |
// existence should be tested by looking at doc.pc
|
2353 |
bool Db::getDoc(const string &udi, const Doc& idxdoc, Doc &doc)
|
2370 |
bool Db::getDoc(const string &udi, const Doc& idxdoc, Doc &doc)
|
2354 |
{
|
2371 |
{
|
2355 |
LOGDEB("Db:getDoc: [" << udi << "]\n");
|
2372 |
LOGDEB1("Db:getDoc: [" << udi << "]\n");
|
2356 |
if (m_ndb == 0)
|
2373 |
int idxi = idxdoc.idxi;
|
|
|
2374 |
return getDoc(udi, idxi, doc);
|
|
|
2375 |
}
|
|
|
2376 |
|
|
|
2377 |
bool Db::getDoc(const string &udi, const std::string& dbdir, Doc &doc)
|
|
|
2378 |
{
|
|
|
2379 |
LOGDEB1("Db::getDoc(udi, dbdir): (" << udi << ", " << dbdir << ")\n");
|
|
|
2380 |
int idxi = -1;
|
|
|
2381 |
if (dbdir.empty() || dbdir == m_basedir) {
|
|
|
2382 |
idxi = 0;
|
|
|
2383 |
} else {
|
|
|
2384 |
for (unsigned int i = 0; i < m_extraDbs.size(); i++) {
|
|
|
2385 |
if (dbdir == m_extraDbs[i]) {
|
|
|
2386 |
idxi = int(i + 1);
|
|
|
2387 |
break;
|
|
|
2388 |
}
|
|
|
2389 |
}
|
|
|
2390 |
}
|
|
|
2391 |
LOGDEB1("Db::getDoc(udi, dbdir): idxi: " << idxi << endl);
|
|
|
2392 |
if (idxi < 0) {
|
|
|
2393 |
LOGERR("Db::getDoc(udi, dbdir): dbdir not in current extra dbs\n");
|
2357 |
return false;
|
2394 |
return false;
|
|
|
2395 |
}
|
|
|
2396 |
return getDoc(udi, idxi, doc);
|
|
|
2397 |
}
|
2358 |
|
2398 |
|
|
|
2399 |
bool Db::getDoc(const string& udi, int idxi, Doc& doc)
|
|
|
2400 |
{
|
2359 |
// Initialize what we can in any case. If this is history, caller
|
2401 |
// Initialize what we can in any case. If this is history, caller
|
2360 |
// will make partial display in case of error
|
2402 |
// will make partial display in case of error
|
|
|
2403 |
if (m_ndb == 0)
|
|
|
2404 |
return false;
|
2361 |
doc.meta[Rcl::Doc::keyrr] = "100%";
|
2405 |
doc.meta[Rcl::Doc::keyrr] = "100%";
|
2362 |
doc.pc = 100;
|
2406 |
doc.pc = 100;
|
2363 |
Xapian::Document xdoc;
|
2407 |
Xapian::Document xdoc;
|
2364 |
Xapian::docid docid;
|
2408 |
Xapian::docid docid;
|
2365 |
int idxi = idxdoc.idxi;
|
|
|
2366 |
if ((docid = m_ndb->getDoc(udi, idxi, xdoc))) {
|
2409 |
if (idxi >= 0 && (docid = m_ndb->getDoc(udi, idxi, xdoc))) {
|
2367 |
string data = xdoc.get_data();
|
2410 |
string data = xdoc.get_data();
|
2368 |
doc.meta[Rcl::Doc::keyudi] = udi;
|
2411 |
doc.meta[Rcl::Doc::keyudi] = udi;
|
2369 |
return m_ndb->dbDataToRclDoc(docid, data, doc);
|
2412 |
return m_ndb->dbDataToRclDoc(docid, data, doc);
|
2370 |
} else {
|
2413 |
} else {
|
2371 |
// Document found in history no longer in the
|
2414 |
// Document found in history no longer in the
|
2372 |
// database. We return true (because their might be
|
2415 |
// database. We return true (because their might be
|
2373 |
// other ok docs further) but indicate the error with
|
2416 |
// other ok docs further) but indicate the error with
|
2374 |
// pc = -1
|
2417 |
// pc = -1
|
2375 |
doc.pc = -1;
|
2418 |
doc.pc = -1;
|
2376 |
LOGINFO("Db:getDoc: no such doc in index: [" << udi << "]\n");
|
2419 |
LOGINFO("Db:getDoc: no such doc in current index: [" << udi << "]\n");
|
2377 |
return true;
|
2420 |
return true;
|
2378 |
}
|
2421 |
}
|
2379 |
}
|
2422 |
}
|
2380 |
|
2423 |
|
2381 |
bool Db::hasSubDocs(const Doc &idoc)
|
2424 |
bool Db::hasSubDocs(const Doc &idoc)
|