backends/remote/net_postlist.cc

Go to the documentation of this file.
00001 
00004 /* Copyright (C) 2007 Lemur Consulting Ltd
00005  * Copyright (C) 2007 Olly Betts
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License as
00009  * published by the Free Software Foundation; either version 2 of the
00010  * License, or (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
00020  * USA
00021  */
00022 
00023 #include <config.h>
00024 
00025 #include "net_postlist.h"
00026 #include "serialise.h"
00027 #include "serialise-double.h"
00028 
00029 using namespace std;
00030 
00031 Xapian::doccount
00032 NetworkPostList::get_termfreq() const
00033 {
00034     return termfreq;
00035 }
00036 
00037 Xapian::docid
00038 NetworkPostList::get_docid() const
00039 {
00040     return lastdocid;
00041 }
00042 
00043 Xapian::doclength
00044 NetworkPostList::get_doclength() const
00045 {
00046     return lastdoclen;
00047 }
00048 
00049 Xapian::termcount
00050 NetworkPostList::get_wdf() const
00051 {
00052     return lastwdf;
00053 }
00054 
00055 PositionList *
00056 NetworkPostList::read_position_list()
00057 {
00058     lastposlist = db->open_position_list(lastdocid, term);
00059     return lastposlist.get();
00060 }
00061 
00062 PositionList *
00063 NetworkPostList::open_position_list() const
00064 {
00065     return db->open_position_list(lastdocid, term);
00066 }
00067 
00068 PostList *
00069 NetworkPostList::next(Xapian::weight)
00070 {
00071     if (!started) {
00072         started = true;
00073         pos = postings.data();
00074         pos_end = pos + postings.size();
00075         lastdocid = 0;
00076     }
00077 
00078     if (pos == pos_end) {
00079         pos = NULL;
00080     } else {
00081         lastdocid += decode_length(&pos, pos_end, false) + 1;
00082         lastwdf = decode_length(&pos, pos_end, false);
00083         lastdoclen = unserialise_double(&pos, pos_end);
00084     }
00085 
00086     return NULL;
00087 }
00088 
00089 PostList *
00090 NetworkPostList::skip_to(Xapian::docid did, Xapian::weight min_weight)
00091 {
00092     if (!started)
00093         next(min_weight);
00094     while (pos && lastdocid < did)
00095         next(min_weight);
00096     return NULL;
00097 }
00098 
00099 bool
00100 NetworkPostList::at_end() const
00101 {
00102     return (pos == NULL && started);
00103 }
00104 
00105 string
00106 NetworkPostList::get_description() const
00107 {
00108     return "NetworkPostList(" + term + ")";
00109 }

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