backends/remote/net_termlist.cc

Go to the documentation of this file.
00001 /* net_termlist.cc
00002  *
00003  * Copyright 1999,2000,2001 BrightStation PLC
00004  * Copyright 2002,2003,2006,2007 Olly Betts
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License as
00008  * published by the Free Software Foundation; either version 2 of the
00009  * License, or (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
00019  * USA
00020  */
00021 
00022 #include <config.h>
00023 #include <stdio.h>
00024 
00025 #include "omassert.h"
00026 #include "omdebug.h"
00027 #include "net_termlist.h"
00028 
00029 #include <vector>
00030 
00031 #include <xapian/error.h>
00032 
00033 NetworkTermList::NetworkTermList(Xapian::doclength document_length_,
00034                                  Xapian::doccount database_size_,
00035                                  Xapian::Internal::RefCntPtr<const RemoteDatabase> this_db_,
00036                                  Xapian::docid did_)
00037         : items(),
00038           current_position(items.begin()),
00039           started(false),
00040           document_length(document_length_),
00041           database_size(database_size_),
00042           this_db(this_db_),
00043           did(did_)
00044 {
00045 }
00046 
00047 Xapian::termcount
00048 NetworkTermList::get_approx_size() const
00049 {
00050     return items.size();
00051 }
00052 
00053 void
00054 NetworkTermList::accumulate_stats(Xapian::Internal::ExpandStats & stats) const
00055 {
00056     Assert(started);
00057     Assert(!at_end());
00058 
00059     stats.accumulate(current_position->wdf,
00060                      document_length,
00061                      current_position->termfreq,
00062                      database_size);
00063 }
00064 
00065 string
00066 NetworkTermList::get_termname() const
00067 {
00068     Assert(started);
00069     Assert(!at_end());
00070     return current_position->tname;
00071 }
00072 
00073 Xapian::termcount
00074 NetworkTermList::get_wdf() const
00075 {
00076     Assert(started);
00077     Assert(!at_end());
00078     return current_position->wdf;
00079 }
00080 
00081 Xapian::doccount
00082 NetworkTermList::get_termfreq() const
00083 {
00084     Assert(started);
00085     Assert(!at_end());
00086     return current_position->termfreq;
00087 }
00088 
00089 TermList *
00090 NetworkTermList::next()
00091 {
00092     if (started) {
00093         Assert(!at_end());
00094         current_position++;
00095     } else {
00096         started = true;
00097     }
00098     return NULL;
00099 }
00100 
00101 bool
00102 NetworkTermList::at_end() const
00103 {
00104     Assert(started);
00105     return (current_position == items.end());
00106 }
00107 
00108 Xapian::termcount
00109 NetworkTermList::positionlist_count() const
00110 {
00111     throw Xapian::UnimplementedError("NetworkTermList::positionlist_count() not implemented");
00112 }
00113 
00114 Xapian::PositionIterator
00115 NetworkTermList::positionlist_begin() const
00116 {
00117     return Xapian::PositionIterator(this_db->open_position_list(did, get_termname()));
00118 }

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