matcher/andmaybepostlist.h

Go to the documentation of this file.
00001 /* andmaybepostlist.h: Merged postlist: items from one list, weights from both
00002  *
00003  * AND MAYBE of two posting lists
00004  * A AND MAYBE B is logically just A, but we keep B around for weight purposes
00005  *
00006  * ----START-LICENCE----
00007  * Copyright 1999,2000,2001 BrightStation PLC
00008  * Copyright 2002 Ananova Ltd
00009  * Copyright 2003,2004 Olly Betts
00010  *
00011  * This program is free software; you can redistribute it and/or
00012  * modify it under the terms of the GNU General Public License as
00013  * published by the Free Software Foundation; either version 2 of the
00014  * License, or (at your option) any later version.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00024  * USA
00025  * -----END-LICENCE-----
00026  */
00027 
00028 
00029 #ifndef OM_HGUARD_ANDMAYBEPOSTLIST_H
00030 #define OM_HGUARD_ANDMAYBEPOSTLIST_H
00031 
00032 #include "branchpostlist.h"
00033 
00054 class AndMaybePostList : public BranchPostList {
00055     private:
00056         Xapian::doccount dbsize; // only need in case we decay to an AndPostList
00057         Xapian::docid lhead, rhead;
00058         Xapian::weight lmax, rmax;
00059 
00060         PostList * process_next_or_skip_to(Xapian::weight w_min, PostList *ret);
00061     public:
00062         Xapian::doccount get_termfreq_max() const;
00063         Xapian::doccount get_termfreq_min() const;
00064         Xapian::doccount get_termfreq_est() const;
00065 
00066         Xapian::docid  get_docid() const;
00067         Xapian::weight get_weight() const;
00068         Xapian::weight get_maxweight() const;
00069 
00070         Xapian::weight recalc_maxweight();
00071 
00072         PostList *next(Xapian::weight w_min);
00073         PostList *skip_to(Xapian::docid did, Xapian::weight w_min);
00074         bool   at_end() const;
00075 
00076         std::string get_description() const;
00077 
00081         virtual Xapian::doclength get_doclength() const;
00082 
00083         AndMaybePostList(PostList *left_,
00084                          PostList *right_,
00085                          MultiMatch *matcher_,
00086                          Xapian::doccount dbsize_)
00087                 : BranchPostList(left_, right_, matcher_),
00088                   dbsize(dbsize_), lhead(0), rhead(0)
00089         {
00090             // lmax and rmax will get initialised by a recalc_maxweight
00091         }
00092 
00094         AndMaybePostList(PostList *left_,
00095                          PostList *right_,
00096                          MultiMatch *matcher_,
00097                          Xapian::doccount dbsize_,
00098                          Xapian::docid lhead_,
00099                          Xapian::docid rhead_)
00100                 : BranchPostList(left_, right_, matcher_),
00101                   dbsize(dbsize_), lhead(lhead_), rhead(rhead_)
00102         {
00103             // Initialise the maxweights from the kids so we can avoid forcing
00104             // a full maxweight recalc
00105             lmax = l->get_maxweight();
00106             rmax = r->get_maxweight();
00107         }
00108 };
00109 
00110 #endif /* OM_HGUARD_ANDMAYBEPOSTLIST_H */

Documentation for Xapian (version 1.0.10).
Generated on 24 Dec 2008 by Doxygen 1.5.2.