xapian-core  1.4.25
selectpostlist.cc
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,2010,2011,2012,2013,2019 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 #include <config.h>
25 #include "selectpostlist.h"
26 
27 #include "debuglog.h"
28 
29 PostList *
30 SelectPostList::next(double w_min)
31 {
32  LOGCALL(MATCH, PostList *, "SelectPostList::next", w_min);
33  do {
34  PostList *p = source->next(w_min);
35  if (p) {
36  delete source;
37  source = p;
38  }
39  wt = -1;
40  } while (!source->at_end() && (!check_weight(w_min) || !test_doc()));
41  RETURN(NULL);
42 }
43 
44 PostList *
46 {
47  LOGCALL(MATCH, PostList *, "SelectPostList::skip_to", did | w_min);
48  if (did > get_docid()) {
49  PostList *p = source->skip_to(did, w_min);
50  if (p) {
51  delete source;
52  source = p;
53  }
54  wt = -1;
55  if (!source->at_end() && (!check_weight(w_min) || !test_doc()))
57  }
58  RETURN(NULL);
59 }
60 
61 PostList *
62 SelectPostList::check(Xapian::docid did, double w_min, bool &valid)
63 {
64  LOGCALL(MATCH, PostList *, "SelectPostList::check", did | w_min | valid);
65  PostList *p = source->check(did, w_min, valid);
66  if (p) {
67  delete source;
68  source = p;
69  }
70  wt = -1;
71  if (valid && !source->at_end() && (!check_weight(w_min) || !test_doc()))
72  valid = false;
73  RETURN(NULL);
74 }
#define RETURN(A)
Definition: debuglog.h:493
PostList * source
Abstract base class for postlists.
Definition: postlist.h:37
virtual Internal * skip_to(Xapian::docid did, double w_min)=0
Skip forward to the specified docid.
Xapian::docid get_docid() const
Return the current docid.
Parent class for classes which only return selected docs.
virtual Internal * check(Xapian::docid did, double w_min, bool &valid)
Check if the specified docid occurs in this postlist.
virtual bool test_doc()=0
Subclasses should override test_doc() with a method which returns true if a document meets the approp...
Internal * next()
Advance the current position to the next document in the postlist.
Definition: postlist.h:194
PostList * check(Xapian::docid did, double w_min, bool &valid)
Check if the specified docid occurs in this postlist.
PostList * skip_to(Xapian::docid did, double w_min)
Skip forward to the specified docid.
virtual Internal * next(double w_min)=0
Advance the current position to the next document in the postlist.
bool check_weight(double w_min)
virtual bool at_end() const =0
Return true if the current position is past the last entry in this list.
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
Definition: types.h:52
Debug logging macros.
#define LOGCALL(CATEGORY, TYPE, FUNC, PARAMS)
Definition: debuglog.h:487