xapian-core  1.4.26
branchpostlist.h
Go to the documentation of this file.
1 
4 /* Copyright 1999,2000,2001 BrightStation PLC
5  * Copyright 2002 Ananova Ltd
6  * Copyright 2003,2004,2007,2011 Olly Betts
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License as
10  * published by the Free Software Foundation; either version 2 of the
11  * License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
21  * USA
22  */
23 
24 #ifndef OM_HGUARD_BRANCHPOSTLIST_H
25 #define OM_HGUARD_BRANCHPOSTLIST_H
26 
27 #include "multimatch.h"
28 #include "api/postlist.h"
29 
37 class BranchPostList : public PostList {
38  private:
39  // Prevent copying
42 
43  protected:
46 
49 
56 
60  void handle_prune(PostList *&kid, PostList *ret) {
61  if (ret) {
62  delete kid;
63  kid = ret;
64 
65  // now tell matcher that maximum weights need recalculation.
66  matcher->recalc_maxweight();
67  }
68  }
69 
70  public:
72  : l(l_), r(r_), matcher(matcher_) {}
73 
74  virtual ~BranchPostList();
75 };
76 
77 // Helper functions - call next/skip_to on a postlist and handle any
78 // resulting prune
79 //
80 // Returns true iff a prune was handled, so the caller can recalculate
81 // weights etc if necessary
82 inline bool
84 {
85  PostList *p = pl->next(w_min);
86  if (!p) return false;
87  delete pl;
88  pl = p;
89  // now tell matcher that maximum weights need recalculation.
90  if (matcher) matcher->recalc_maxweight();
91  return true;
92 }
93 
94 inline bool
95 skip_to_handling_prune(PostList * & pl, Xapian::docid did, double w_min,
97 {
98  PostList *p = pl->skip_to(did, w_min);
99  if (!p) return false;
100  delete pl;
101  pl = p;
102  // now tell matcher that maximum weights need recalculation.
103  if (matcher) matcher->recalc_maxweight();
104  return true;
105 }
106 
107 inline bool
108 check_handling_prune(PostList * & pl, Xapian::docid did, double w_min,
109  MultiMatch *matcher, bool & valid)
110 {
111  PostList *p = pl->check(did, w_min, valid);
112  if (!p) return false;
113  delete pl;
114  pl = p;
115  // now tell matcher that maximum weights need recalculation.
116  if (matcher) matcher->recalc_maxweight();
117  return true;
118 }
119 
120 #endif /* OM_HGUARD_BRANCHPOSTLIST_H */
MultiMatch * matcher
The object which is using this postlist to perform a match.
Abstract base class for postlists.
Definition: postlist.h:37
class for performing a match
PostList * l
Left sub-postlist.
virtual Internal * skip_to(Xapian::docid did, double w_min)=0
Skip forward to the specified docid.
Base class for postlists which are generated by merging two sub-postlists.
Abstract base class for postlists.
bool skip_to_handling_prune(PostList *&pl, Xapian::docid did, double w_min, MultiMatch *matcher)
void handle_prune(PostList *&kid, PostList *ret)
Utility method, to call recalc_maxweight() and do the pruning if a next() or skip_to() returns non-NU...
virtual Internal * check(Xapian::docid did, double w_min, bool &valid)
Check if the specified docid occurs in this postlist.
BranchPostList(PostList *l_, PostList *r_, MultiMatch *matcher_)
BranchPostList(const BranchPostList &)
void recalc_maxweight()
Called by postlists to indicate that they've rearranged themselves and the maxweight now possible is ...
Definition: multimatch.h:136
bool check_handling_prune(PostList *&pl, Xapian::docid did, double w_min, MultiMatch *matcher, bool &valid)
BranchPostList & operator=(const BranchPostList &)
bool next_handling_prune(PostList *&pl, double w_min, MultiMatch *matcher)
virtual Internal * next(double w_min)=0
Advance the current position to the next document in the postlist.
PostList * r
Right sub-postlist.
virtual ~BranchPostList()
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
Definition: types.h:52