matcher/msetpostlist.cc

Go to the documentation of this file.
00001 
00004 /* Copyright (C) 2006,2007 Olly Betts
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00019  */
00020 
00021 #include <config.h>
00022 
00023 #include "msetpostlist.h"
00024 #include "omassert.h"
00025 #include "omdebug.h"
00026 
00027 Xapian::doccount
00028 MSetPostList::get_termfreq_min() const
00029 {
00030     DEBUGCALL(MATCH, Xapian::doccount, "MSetPostList::get_termfreq_min", "");
00031     RETURN(mset_internal->matches_lower_bound);
00032 }
00033 
00034 Xapian::doccount
00035 MSetPostList::get_termfreq_est() const
00036 {
00037     DEBUGCALL(MATCH, Xapian::doccount, "MSetPostList::get_termfreq_est", "");
00038     RETURN(mset_internal->matches_estimated);
00039 }
00040 
00041 Xapian::doccount
00042 MSetPostList::get_termfreq_max() const
00043 {
00044     DEBUGCALL(MATCH, Xapian::doccount, "MSetPostList::get_termfreq_max", "");
00045     RETURN(mset_internal->matches_upper_bound);
00046 }
00047 
00048 Xapian::weight
00049 MSetPostList::get_maxweight() const
00050 {
00051     DEBUGCALL(MATCH, Xapian::weight, "MSetPostList::get_maxweight", "");
00052     // If we've not started, return max_possible from our MSet so that this
00053     // value gets used to set max_possible in the combined MSet.
00054     if (cursor == -1) RETURN(mset_internal->max_possible);
00055 
00056     // If the MSet is sorted in descending weight order, then the maxweight we
00057     // can return from now on is the weight of the current item.
00058     if (decreasing_relevance) RETURN(mset_internal->items[cursor].did);
00059 
00060     // Otherwise max_attained is the best answer we can give.
00061     RETURN(mset_internal->max_attained);
00062 }
00063 
00064 Xapian::docid
00065 MSetPostList::get_docid() const
00066 {
00067     DEBUGCALL(MATCH, Xapian::docid, "MSetPostList::get_docid", "");
00068     Assert(cursor != -1);
00069     RETURN(mset_internal->items[cursor].did);
00070 }
00071 
00072 Xapian::weight
00073 MSetPostList::get_weight() const
00074 {
00075     DEBUGCALL(MATCH, Xapian::weight, "MSetPostList::get_weight", "");
00076     Assert(cursor != -1);
00077     RETURN(mset_internal->items[cursor].wt);
00078 }
00079 
00080 const string *
00081 MSetPostList::get_collapse_key() const
00082 {
00083     DEBUGCALL(MATCH, string *, "MSetPostList::get_collapse_key", "");
00084     Assert(cursor != -1);
00085     RETURN(&mset_internal->items[cursor].collapse_key);
00086 }
00087 
00088 Xapian::doclength
00089 MSetPostList::get_doclength() const
00090 {
00091     throw Xapian::UnimplementedError("MSetPostList::get_doclength() unimplemented");
00092 }
00093 
00094 Xapian::weight
00095 MSetPostList::recalc_maxweight()
00096 {
00097     DEBUGCALL(MATCH, Xapian::weight, "MSetPostList::recalc_maxweight", "");
00098     RETURN(MSetPostList::get_maxweight());
00099 }
00100 
00101 PostList *
00102 MSetPostList::next(Xapian::weight w_min)
00103 {
00104     DEBUGCALL(MATCH, PostList *, "MSetPostList::next", w_min);
00105     Assert(cursor == -1 || !at_end());
00106     ++cursor;
00107     if (decreasing_relevance) {
00108         // MSet items are in decreasing weight order, so if the current item
00109         // doesn't have enough weight, none of the remaining items will, so
00110         // skip straight to the end.
00111         if (!at_end() && mset_internal->items[cursor].wt < w_min)
00112             cursor = mset_internal->items.size();
00113     } else {
00114         // Otherwise, skip to the next entry with enough weight.
00115         while (!at_end() && mset_internal->items[cursor].wt < w_min)
00116             ++cursor;
00117     }
00118     RETURN(NULL);
00119 }
00120 
00121 PostList *
00122 MSetPostList::skip_to(Xapian::docid, Xapian::weight)
00123 {
00124     // The usual semantics of skip_to don't make sense since MSetPostList
00125     // returns documents in MSet order rather than docid order like other
00126     // PostLists do.
00127     throw Xapian::InvalidOperationError("MSetPostList::skip_to not meaningful");
00128 }
00129 
00130 bool
00131 MSetPostList::at_end() const
00132 {
00133     DEBUGCALL(MATCH, bool, "MSetPostList::at_end", "");
00134     Assert(cursor != -1);
00135     RETURN(size_t(cursor) >= mset_internal->items.size());
00136 }
00137 
00138 string
00139 MSetPostList::get_description() const
00140 {
00141     string desc("(MSet ");
00142     desc += mset_internal->get_description();
00143     desc += ')';
00144     return desc;
00145 }

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