00001
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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