From fc4adfdbaaab89ff4a934f10f392e19504c09835 Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Mon, 22 Apr 2013 17:30:11 +0200 Subject: [PATCH] moved code around --- src/rcldb/rcldb_p.h | 14 ++++++++++++++ src/rcldb/rclquery.cpp | 8 +------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/rcldb/rcldb_p.h b/src/rcldb/rcldb_p.h index b0ee3cd1..acab768a 100644 --- a/src/rcldb/rcldb_p.h +++ b/src/rcldb/rcldb_p.h @@ -107,6 +107,20 @@ class Db::Native { int getPageNumberForPosition(const vector& pbreaks, unsigned int pos); bool dbDataToRclDoc(Xapian::docid docid, std::string &data, Doc &doc); + + bool xdocToUdi(Xapian::Document& xdoc, string &udi) + { + Xapian::TermIterator xit = xdoc.termlist_begin(); + xit.skip_to(wrap_prefix(udi_prefix)); + if (xit != xdoc.termlist_end()) { + udi = *xit; + if (!udi.empty()) { + udi = udi.substr(wrap_prefix(udi_prefix).size()); + return true; + } + } + return false; + } /** Compute list of subdocuments for a given udi. We look for documents * indexed by a parent term matching the udi, the posting list for the diff --git a/src/rcldb/rclquery.cpp b/src/rcldb/rclquery.cpp index 3404c474..cf9b250b 100644 --- a/src/rcldb/rclquery.cpp +++ b/src/rcldb/rclquery.cpp @@ -421,13 +421,7 @@ bool Query::getDoc(int xapi, Doc &doc) data = xdoc.get_data(); m_reason.erase(); Chrono chron; - Xapian::TermIterator it = xdoc.termlist_begin(); - it.skip_to(wrap_prefix(udi_prefix)); - if (it != xdoc.termlist_end()) { - udi = *it; - if (!udi.empty()) - udi = udi.substr(wrap_prefix(udi_prefix).size()); - } + m_db->m_ndb->xdocToUdi(xdoc, udi); LOGDEB2(("Query::getDoc: %d ms for udi [%s], collapse count %d\n", chron.millis(), udi.c_str(), collapsecount)); break;