matcher/valuegepostlist.cc

Go to the documentation of this file.
00001 
00004 /* Copyright 2007,2008 Olly Betts
00005  * Copyright 2008 Lemur Consulting Ltd
00006  *
00007  * This program is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2 of the License, or
00010  * (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00020  */
00021 
00022 #include <config.h>
00023 
00024 #include "valuegepostlist.h"
00025 
00026 #include "autoptr.h"
00027 #include "omassert.h"
00028 #include "document.h"
00029 #include "leafpostlist.h"
00030 #include "utils.h"
00031 
00032 using namespace std;
00033 
00034 PostList *
00035 ValueGePostList::next(Xapian::weight)
00036 {
00037     Assert(db);
00038     if (!alldocs_pl) alldocs_pl = db->open_post_list(string());
00039     alldocs_pl->skip_to(current + 1);
00040     while (!alldocs_pl->at_end()) {
00041         current = alldocs_pl->get_docid();
00042         AutoPtr<Xapian::Document::Internal> doc(db->open_document(current, true));
00043         string v = doc->get_value(valno);
00044         if (v >= begin) return NULL;
00045         alldocs_pl->next();
00046     }
00047     db = NULL;
00048     return NULL;
00049 }
00050 
00051 PostList *
00052 ValueGePostList::skip_to(Xapian::docid did, Xapian::weight w_min)
00053 {
00054     Assert(db);
00055     if (did <= current) return NULL;
00056     current = did - 1;
00057     return ValueGePostList::next(w_min);
00058 }
00059 
00060 PostList *
00061 ValueGePostList::check(Xapian::docid did, Xapian::weight, bool &valid)
00062 {
00063     Assert(db);
00064     if (did <= current) {
00065         valid = true;
00066         return NULL;
00067     }
00068     AssertRelParanoid(did, <=, db->get_lastdocid());
00069     current = did;
00070     AutoPtr<Xapian::Document::Internal> doc(db->open_document(current, true));
00071     string v = doc->get_value(valno);
00072     valid = (v >= begin);
00073     return NULL;
00074 }
00075 
00076 string
00077 ValueGePostList::get_description() const
00078 {
00079     string desc = "ValueGePostList(";
00080     desc += om_tostring(valno);
00081     desc += ", ";
00082     desc += begin;
00083     desc += ")";
00084     return desc;
00085 }

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