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