00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <config.h>
00024
00025 #include "andmaybepostlist.h"
00026 #include "andpostlist.h"
00027 #include "omassert.h"
00028 #include "omdebug.h"
00029
00030 PostList *
00031 AndMaybePostList::process_next_or_skip_to(Xapian::weight w_min, PostList *ret)
00032 {
00033 DEBUGCALL(MATCH, PostList *, "AndMaybePostList::process_next_or_skip_to", w_min << ", " << ret);
00034 handle_prune(l, ret);
00035 if (l->at_end()) {
00036
00037 lhead = 0;
00038 RETURN(NULL);
00039 }
00040
00041 lhead = l->get_docid();
00042 if (lhead <= rhead) RETURN(NULL);
00043
00044 skip_to_handling_prune(r, lhead, w_min - lmax, matcher);
00045 if (r->at_end()) {
00046 PostList *tmp = l;
00047 l = NULL;
00048 RETURN(tmp);
00049 }
00050 rhead = r->get_docid();
00051 RETURN(NULL);
00052 }
00053
00054 PostList *
00055 AndMaybePostList::next(Xapian::weight w_min)
00056 {
00057 DEBUGCALL(MATCH, PostList *, "AndMaybePostList::next", w_min);
00058 if (w_min > lmax) {
00059
00060 PostList *ret;
00061 DEBUGLINE(MATCH, "AND MAYBE -> AND");
00062 ret = new AndPostList(l, r, matcher, dbsize, true);
00063 l = r = NULL;
00064 skip_to_handling_prune(ret, std::max(lhead, rhead) + 1, w_min, matcher);
00065 RETURN(ret);
00066 }
00067 RETURN(process_next_or_skip_to(w_min, l->next(w_min - rmax)));
00068 }
00069
00070 PostList *
00071 AndMaybePostList::skip_to(Xapian::docid did, Xapian::weight w_min)
00072 {
00073 DEBUGCALL(MATCH, PostList *, "AndMaybePostList::skip_to", did << ", " << w_min);
00074 if (w_min > lmax) {
00075
00076 PostList *ret;
00077 DEBUGLINE(MATCH, "AND MAYBE -> AND (in skip_to)");
00078 ret = new AndPostList(l, r, matcher, dbsize, true);
00079 did = std::max(did, std::max(lhead, rhead));
00080 l = r = NULL;
00081 skip_to_handling_prune(ret, did, w_min, matcher);
00082 RETURN(ret);
00083 }
00084
00085
00086 if (did <= lhead) RETURN(NULL);
00087
00088 RETURN(process_next_or_skip_to(w_min, l->skip_to(did, w_min - rmax)));
00089 }
00090
00091 Xapian::doccount
00092 AndMaybePostList::get_termfreq_max() const
00093 {
00094 DEBUGCALL(MATCH, Xapian::doccount, "AndMaybePostList::get_termfreq_max", "");
00095
00096 RETURN(l->get_termfreq_max());
00097 }
00098
00099 Xapian::doccount
00100 AndMaybePostList::get_termfreq_min() const
00101 {
00102 DEBUGCALL(MATCH, Xapian::doccount, "AndMaybePostList::get_termfreq_min", "");
00103
00104 RETURN(l->get_termfreq_min());
00105 }
00106
00107 Xapian::doccount
00108 AndMaybePostList::get_termfreq_est() const
00109 {
00110 DEBUGCALL(MATCH, Xapian::doccount, "AndMaybePostList::get_termfreq_est", "");
00111
00112 RETURN(l->get_termfreq_est());
00113 }
00114
00115 Xapian::docid
00116 AndMaybePostList::get_docid() const
00117 {
00118 DEBUGCALL(MATCH, Xapian::docid, "AndMaybePostList::get_docid", "");
00119 Assert(lhead != 0 && rhead != 0);
00120 RETURN(lhead);
00121 }
00122
00123
00124 Xapian::weight
00125 AndMaybePostList::get_weight() const
00126 {
00127 DEBUGCALL(MATCH, Xapian::weight, "AndMaybePostList::get_weight", "");
00128 Assert(lhead != 0 && rhead != 0);
00129 if (lhead == rhead) RETURN(l->get_weight() + r->get_weight());
00130 RETURN(l->get_weight());
00131 }
00132
00133
00134 Xapian::weight
00135 AndMaybePostList::get_maxweight() const
00136 {
00137 DEBUGCALL(MATCH, Xapian::weight, "AndMaybePostList::get_maxweight", "");
00138 RETURN(lmax + rmax);
00139 }
00140
00141 Xapian::weight
00142 AndMaybePostList::recalc_maxweight()
00143 {
00144 DEBUGCALL(MATCH, Xapian::weight, "AndMaybePostList::recalc_maxweight", "");
00145 lmax = l->recalc_maxweight();
00146 rmax = r->recalc_maxweight();
00147 RETURN(AndMaybePostList::get_maxweight());
00148 }
00149
00150 bool
00151 AndMaybePostList::at_end() const
00152 {
00153 DEBUGCALL(MATCH, bool, "AndMaybePostList::at_end", "");
00154 RETURN(lhead == 0);
00155 }
00156
00157 std::string
00158 AndMaybePostList::get_description() const
00159 {
00160 return "(" + l->get_description() + " AndMaybe " + r->get_description() +
00161 ")";
00162 }
00163
00164 Xapian::doclength
00165 AndMaybePostList::get_doclength() const
00166 {
00167 DEBUGCALL(MATCH, Xapian::doclength, "AndMaybePostList::get_doclength", "");
00168 Assert(lhead != 0 && rhead != 0);
00169 if (lhead == rhead) AssertEqDouble(l->get_doclength(), r->get_doclength());
00170 RETURN(l->get_doclength());
00171 }