From b679af02d77d5a94b3540f751c533aea5937dcf6 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 19 Dec 2017 17:03:31 +1300 Subject: [PATCH] Glass cursors for other tables too --- xapian-core/backends/honey/honey_compact.cc | 46 +++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/xapian-core/backends/honey/honey_compact.cc b/xapian-core/backends/honey/honey_compact.cc index 3ea1540c0..110ca1320 100644 --- a/xapian-core/backends/honey/honey_compact.cc +++ b/xapian-core/backends/honey/honey_compact.cc @@ -1098,6 +1098,14 @@ merge_postlists(Xapian::Compactor * compactor, template struct MergeCursor; template<> +struct MergeCursor : public GlassCursor { + explicit MergeCursor(const GlassTable *in) : GlassCursor(in) { + find_entry(string()); + next(); + } +}; + +template<> struct MergeCursor : public HoneyCursor { explicit MergeCursor(const HoneyTable *in) : HoneyCursor(in) { find_entry(string()); @@ -1441,6 +1449,44 @@ multimerge_postlists(Xapian::Compactor * compactor, template class PositionCursor; template<> +class PositionCursor : private GlassCursor { + Xapian::docid offset; + + public: + string key; + Xapian::docid firstdid; + + PositionCursor(const GlassTable *in, Xapian::docid offset_) + : GlassCursor(in), offset(offset_), firstdid(0) { + find_entry(string()); + next(); + } + + bool next() { + if (!GlassCursor::next()) return false; + read_tag(); + const char * d = current_key.data(); + const char * e = d + current_key.size(); + string term; + Xapian::docid did; + if (!unpack_string_preserving_sort(&d, e, term) || + !unpack_uint_preserving_sort(&d, e, &did) || + d != e) { + throw Xapian::DatabaseCorruptError("Bad position key"); + } + + key.resize(0); + pack_string_preserving_sort(key, term); + pack_uint_preserving_sort(key, did + offset); + return true; + } + + const string & get_tag() const { + return current_tag; + } +}; + +template<> class PositionCursor : private HoneyCursor { Xapian::docid offset; -- 2.11.4.GIT