backends/remote/net_postlist.h

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 #ifndef XAPIAN_INCLUDED_NET_POSTLIST_H
00024 #define XAPIAN_INCLUDED_NET_POSTLIST_H
00025 
00026 #include <string>
00027 
00028 #include "leafpostlist.h"
00029 #include "omassert.h"
00030 #include "remote-database.h"
00031 
00032 using namespace std;
00033 
00036 class NetworkPostList : public LeafPostList {
00037     friend class RemoteDatabase;
00038 
00039     Xapian::Internal::RefCntPtr<const RemoteDatabase> db;
00040     string term;
00041 
00042     string postings;
00043     bool started;
00044     const char * pos;
00045     const char * pos_end;
00046 
00047     Xapian::docid lastdocid;
00048     Xapian::termcount lastwdf;
00049     Xapian::doclength lastdoclen;
00050     Xapian::Internal::RefCntPtr<PositionList> lastposlist;
00051 
00052     Xapian::doccount termfreq;
00053 
00055     void append_posting(const string & serialised) {
00056         Assert(pos == NULL);
00057         Assert(!started);
00058         postings.append(serialised);
00059     }
00060 
00061   public:
00063     NetworkPostList(Xapian::Internal::RefCntPtr<const RemoteDatabase> db_,
00064                     const string & term_)
00065         : db(db_), term(term_), started(false), pos(NULL), pos_end(NULL),
00066           lastdocid(0), lastwdf(0), lastdoclen(0), termfreq(0)
00067     {
00068         termfreq = db->read_post_list(term, *this);
00069     }
00070 
00072     Xapian::doccount get_termfreq() const;
00073 
00075     Xapian::docid get_docid() const;
00076 
00078     Xapian::doclength get_doclength() const;
00079 
00081     Xapian::termcount get_wdf() const;
00082 
00085     PositionList * read_position_list();
00086 
00089     PositionList * open_position_list() const;
00090 
00093     PostList * next(Xapian::weight);
00094 
00097     PostList * skip_to(Xapian::docid did, Xapian::weight weight);
00098 
00100     bool at_end() const;
00101 
00103     string get_description() const;
00104 };
00105 
00106 #endif /* XAPIAN_INCLUDED_NET_POSTLIST_H */

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