common/remote-database.h

Go to the documentation of this file.
00001 
00004 /* Copyright (C) 2006,2007 Olly Betts
00005  * Copyright (C) 2007 Lemur Consulting Ltd
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 USA
00020  */
00021 
00022 #ifndef XAPIAN_INCLUDED_REMOTE_DATABASE_H
00023 #define XAPIAN_INCLUDED_REMOTE_DATABASE_H
00024 
00025 #include "database.h"
00026 #include "omenquireinternal.h"
00027 #include "omqueryinternal.h"
00028 #include "omtime.h"
00029 #include "remoteconnection.h"
00030 
00031 namespace Xapian {
00032     class RSet;
00033     class Weight;
00034 }
00035 
00036 class NetworkPostList;
00037 class Stats;
00038 
00045 class RemoteDatabase : public Xapian::Database::Internal {
00047     void operator=(const RemoteDatabase &);
00048 
00050     RemoteDatabase(const RemoteDatabase &);
00051 
00053     mutable RemoteConnection link;
00054 
00056     mutable Xapian::doccount doccount;
00057 
00059     mutable Xapian::docid lastdocid;
00060 
00062     mutable Xapian::doclength avlength;
00063 
00065     mutable bool has_positional_info;
00066 
00068     string context;
00069 
00070     mutable bool cached_stats_valid;
00071 
00072     void update_stats(message_type msg_code = MSG_UPDATE) const;
00073 
00074   protected:
00088     RemoteDatabase(int fd, Xapian::timeout timeout_, const string & context_,
00089                    bool writable);
00090 
00092     reply_type get_message(string & message, reply_type required_type = REPLY_MAX) const;
00093 
00095     void send_message(message_type type, const string & data) const;
00096 
00098     void do_close();
00099 
00100     bool get_posting(Xapian::docid &did, Xapian::weight &w, string &value);
00101 
00103     Xapian::timeout timeout;
00104 
00105   public:
00107     RemoteDatabase * as_remotedatabase();
00108 
00110     void keep_alive();
00111 
00126     void set_query(const Xapian::Query::Internal *query,
00127                    Xapian::termcount qlen,
00128                    Xapian::valueno collapse_key,
00129                    Xapian::Enquire::docid_order order,
00130                    Xapian::valueno sort_key,
00131                    Xapian::Enquire::Internal::sort_setting sort_by,
00132                    bool sort_value_forward,
00133                    int percent_cutoff, Xapian::weight weight_cutoff,
00134                    const Xapian::Weight *wtscheme,
00135                    const Xapian::RSet &omrset);
00136 
00141     bool get_remote_stats(bool nowait, Stats &out);
00142 
00144     void send_global_stats(Xapian::doccount first,
00145                            Xapian::doccount maxitems,
00146                            Xapian::doccount check_at_least,
00147                            const Stats &stats);
00148 
00150     void get_mset(Xapian::MSet &mset);
00151 
00153     TermList * open_term_list(Xapian::docid did) const;
00154 
00156     TermList * open_allterms(const string & prefix) const;
00157 
00158     bool has_positions() const;
00159 
00160     void reopen();
00161 
00162     LeafPostList * open_post_list(const string & tname) const;
00163 
00164     Xapian::doccount read_post_list(const string &term, NetworkPostList & pl) const;
00165 
00166     PositionList * open_position_list(Xapian::docid did,
00167                                       const string & tname) const;
00168 
00170     Xapian::Document::Internal * open_document(Xapian::docid did, bool lazy) const;
00171 
00173     Xapian::doccount get_doccount() const;
00174 
00176     Xapian::docid get_lastdocid() const;
00177 
00179     Xapian::doclength get_avlength() const;
00180 
00181     Xapian::doclength get_doclength(Xapian::docid did) const;
00182 
00184     bool term_exists(const string & tname) const;
00185 
00187     Xapian::doccount get_termfreq(const string & tname) const;
00188 
00189     Xapian::termcount get_collection_freq(const string & tname) const;
00190 
00191     void flush();
00192 
00193     void cancel();
00194 
00195     Xapian::docid add_document(const Xapian::Document & doc);
00196 
00197     void delete_document(Xapian::docid did);
00198     void delete_document(const std::string & unique_term);
00199 
00200     void replace_document(Xapian::docid did, const Xapian::Document & doc);
00201     Xapian::docid replace_document(const std::string & unique_term,
00202                                    const Xapian::Document & document);
00203 };
00204 
00205 #endif // XAPIAN_INCLUDED_REMOTE_DATABASE_H

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