|
a/src/rcldb/rclquery.cpp |
|
b/src/rcldb/rclquery.cpp |
|
... |
|
... |
240 |
}
|
240 |
}
|
241 |
|
241 |
|
242 |
// Mset size
|
242 |
// Mset size
|
243 |
static const int qquantum = 30;
|
243 |
static const int qquantum = 30;
|
244 |
|
244 |
|
|
|
245 |
// Get estimated result count for query. Xapian actually does most of
|
|
|
246 |
// the search job in there, this can be long
|
245 |
int Query::getResCnt()
|
247 |
int Query::getResCnt()
|
246 |
{
|
248 |
{
|
247 |
if (ISNULL(m_nq) || !m_nq->enquire) {
|
249 |
if (ISNULL(m_nq) || !m_nq->enquire) {
|
248 |
LOGERR(("Query::getResCnt: no query opened\n"));
|
250 |
LOGERR(("Query::getResCnt: no query opened\n"));
|
249 |
return -1;
|
251 |
return -1;
|
250 |
}
|
252 |
}
|
251 |
string ermsg;
|
253 |
string ermsg;
|
|
|
254 |
int ret = -1;
|
252 |
if (m_nq->mset.size() <= 0) {
|
255 |
if (m_nq->mset.size() <= 0) {
|
|
|
256 |
Chrono chron;
|
253 |
try {
|
257 |
try {
|
254 |
m_nq->mset = m_nq->enquire->get_mset(0, qquantum,
|
258 |
m_nq->mset = m_nq->enquire->get_mset(0, qquantum,0, m_nq->decider);
|
255 |
0, m_nq->decider);
|
259 |
ret = m_nq->mset.get_matches_lower_bound();
|
256 |
} catch (const Xapian::DatabaseModifiedError &error) {
|
260 |
} catch (const Xapian::DatabaseModifiedError &error) {
|
257 |
m_db->m_ndb->db.reopen();
|
261 |
m_db->m_ndb->db.reopen();
|
258 |
m_nq->mset = m_nq->enquire->get_mset(0, qquantum,
|
262 |
m_nq->mset = m_nq->enquire->get_mset(0, qquantum,0, m_nq->decider);
|
259 |
0, m_nq->decider);
|
263 |
ret = m_nq->mset.get_matches_lower_bound();
|
260 |
} XCATCHERROR(ermsg);
|
264 |
} XCATCHERROR(ermsg);
|
|
|
265 |
LOGDEB(("Query::getResCnt: %d mS\n", chron.millis()));
|
261 |
if (!ermsg.empty()) {
|
266 |
if (!ermsg.empty())
|
262 |
LOGERR(("enquire->get_mset: exception: %s\n", ermsg.c_str()));
|
267 |
LOGERR(("enquire->get_mset: exception: %s\n", ermsg.c_str()));
|
263 |
return -1;
|
|
|
264 |
}
|
|
|
265 |
}
|
268 |
}
|
266 |
int ret = -1;
|
|
|
267 |
try {
|
|
|
268 |
ret = m_nq->mset.get_matches_lower_bound();
|
|
|
269 |
} catch (...) {}
|
|
|
270 |
return ret;
|
269 |
return ret;
|
271 |
}
|
270 |
}
|
272 |
|
271 |
|
273 |
|
272 |
|
274 |
// Get document at rank i in query (i is the index in the whole result
|
273 |
// Get document at rank i in query (i is the index in the whole result
|
|
... |
|
... |
308 |
m_db->m_ndb->db.reopen();
|
307 |
m_db->m_ndb->db.reopen();
|
309 |
m_nq->mset = m_nq->enquire->get_mset(first, qquantum);
|
308 |
m_nq->mset = m_nq->enquire->get_mset(first, qquantum);
|
310 |
} catch (const Xapian::Error & error) {
|
309 |
} catch (const Xapian::Error & error) {
|
311 |
LOGERR(("enquire->get_mset: exception: %s\n",
|
310 |
LOGERR(("enquire->get_mset: exception: %s\n",
|
312 |
error.get_msg().c_str()));
|
311 |
error.get_msg().c_str()));
|
313 |
abort();
|
312 |
return false;
|
314 |
}
|
313 |
}
|
315 |
|
314 |
|
316 |
if (m_nq->mset.empty()) {
|
315 |
if (m_nq->mset.empty()) {
|
317 |
LOGDEB(("Query::getDoc: got empty mset\n"));
|
316 |
LOGDEB(("Query::getDoc: got empty mset\n"));
|
318 |
return false;
|
317 |
return false;
|
|
... |
|
... |
347 |
m_nq->mset = m_nq->enquire->get_mset(xapi, qquantum,
|
346 |
m_nq->mset = m_nq->enquire->get_mset(xapi, qquantum,
|
348 |
0, m_nq->decider);
|
347 |
0, m_nq->decider);
|
349 |
|
348 |
|
350 |
} catch (const Xapian::Error & error) {
|
349 |
} catch (const Xapian::Error & error) {
|
351 |
LOGERR(("enquire->get_mset: exception: %s\n",
|
350 |
LOGERR(("enquire->get_mset: exception: %s\n",
|
352 |
error.get_msg().c_str()));
|
351 |
error.get_msg().c_str()));
|
353 |
abort();
|
352 |
return false;
|
354 |
}
|
353 |
}
|
355 |
if (m_nq->mset.empty())
|
354 |
if (m_nq->mset.empty())
|
356 |
return false;
|
355 |
return false;
|
357 |
first = m_nq->mset.get_firstitem();
|
356 |
first = m_nq->mset.get_firstitem();
|
358 |
last = first + m_nq->mset.size() -1;
|
357 |
last = first + m_nq->mset.size() -1;
|
359 |
}
|
358 |
}
|
360 |
|
359 |
|
361 |
LOGDEB1(("Query::getDoc: Qry [%s] win [%d-%d] Estimated results: %d",
|
360 |
LOGDEB1(("Query::getDoc: Qry [%s] win [%d-%d] Estimated results: %d",
|
362 |
m_nq->query.get_description().c_str(),
|
361 |
m_nq->query.get_description().c_str(),
|
363 |
first, last,
|
362 |
first, last, m_nq->mset.get_matches_lower_bound()));
|
364 |
m_nq->mset.get_matches_lower_bound()));
|
|
|
365 |
|
363 |
|
366 |
Xapian::Document xdoc = m_nq->mset[xapi-first].get_document();
|
364 |
Xapian::Document xdoc = m_nq->mset[xapi-first].get_document();
|
367 |
Xapian::docid docid = *(m_nq->mset[xapi-first]);
|
365 |
Xapian::docid docid = *(m_nq->mset[xapi-first]);
|
368 |
int pc = m_nq->mset.convert_to_percent(m_nq->mset[xapi-first]);
|
366 |
int pc = m_nq->mset.convert_to_percent(m_nq->mset[xapi-first]);
|
369 |
|
367 |
|