00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef OM_HGUARD_DATABASE_H
00025 #define OM_HGUARD_DATABASE_H
00026
00027 #include <string>
00028
00029 #include <xapian/base.h>
00030 #include <xapian/types.h>
00031 #include <xapian/database.h>
00032 #include <xapian/document.h>
00033 #include <xapian/positioniterator.h>
00034 #include <xapian/termiterator.h>
00035 #include "omdebug.h"
00036
00037 using namespace std;
00038
00039 class LeafPostList;
00040 class RemoteDatabase;
00041
00042 typedef Xapian::TermIterator::Internal TermList;
00043 typedef Xapian::PositionIterator::Internal PositionList;
00044
00045 namespace Xapian {
00046
00049 class Database::Internal : public Xapian::Internal::RefCntBase {
00050 private:
00052 Internal(const Internal &);
00053
00055 void operator=(const Internal &);
00056
00057 protected:
00059 enum {
00060 TRANSACTION_UNIMPLEMENTED = -1,
00061 TRANSACTION_NONE = 0,
00062 TRANSACTION_UNFLUSHED = 1,
00063 TRANSACTION_FLUSHED = 2
00064 } transaction_state;
00065
00066 bool transaction_active() const { return int(transaction_state) > 0; }
00067
00070 Internal();
00071
00082 void dtor_called();
00083
00084 public:
00096 virtual ~Internal();
00097
00101 virtual void keep_alive();
00102
00104
00105
00106
00109 virtual Xapian::doccount get_doccount() const = 0;
00110
00113 virtual Xapian::docid get_lastdocid() const = 0;
00114
00120 virtual Xapian::doclength get_avlength() const = 0;
00121
00132 virtual Xapian::doclength get_doclength(Xapian::docid did) const = 0;
00133
00141 virtual Xapian::doccount get_termfreq(const string & tname) const = 0;
00142
00151 virtual Xapian::termcount get_collection_freq(const string & tname) const = 0;
00152
00157 virtual bool term_exists(const string & tname) const = 0;
00158
00161 virtual bool has_positions() const = 0;
00162
00164
00165
00166
00182 virtual LeafPostList * open_post_list(const string & tname) const = 0;
00183
00194 virtual TermList * open_term_list(Xapian::docid did) const = 0;
00195
00205 virtual TermList * open_allterms(const string & prefix) const = 0;
00206
00218 virtual PositionList * open_position_list(Xapian::docid did,
00219 const string & tname) const = 0;
00220
00237 virtual Xapian::Document::Internal *
00238 open_document(Xapian::docid did, bool lazy = false) const = 0;
00239
00244 virtual TermList * open_spelling_termlist(const string & word) const;
00245
00251 virtual TermList * open_spelling_wordlist() const;
00252
00254 virtual Xapian::doccount get_spelling_frequency(const string & word) const;
00255
00263 virtual void add_spelling(const string & word,
00264 Xapian::termcount freqinc) const;
00265
00274 virtual void remove_spelling(const string & word,
00275 Xapian::termcount freqdec) const;
00276
00281 virtual TermList * open_synonym_termlist(const string & term) const;
00282
00288 virtual TermList * open_synonym_keylist(const string & prefix) const;
00289
00295 virtual void add_synonym(const string & term, const string & synonym) const;
00296
00301 virtual void remove_synonym(const string & term, const string & synonym) const;
00302
00307 virtual void clear_synonyms(const string & term) const;
00308
00313 virtual string get_metadata(const string & key) const;
00314
00323 virtual TermList * open_metadata_keylist(const std::string &prefix) const;
00324
00329 virtual void set_metadata(const string & key, const string & value);
00330
00336 virtual void reopen();
00337
00339
00340
00341
00346 virtual void flush();
00347
00349 virtual void cancel();
00350
00355 void begin_transaction(bool flushed);
00356
00361 void commit_transaction();
00362
00367 void cancel_transaction();
00368
00373 virtual Xapian::docid add_document(const Xapian::Document & document);
00374
00379 virtual void delete_document(Xapian::docid did);
00380
00385 virtual void delete_document(const string & unique_term);
00386
00391 virtual void replace_document(Xapian::docid did,
00392 const Xapian::Document & document);
00393
00398 virtual Xapian::docid replace_document(const string & unique_term,
00399 const Xapian::Document & document);
00400
00411 virtual void request_document(Xapian::docid ) const;
00412
00413 virtual Xapian::Document::Internal * collect_document(Xapian::docid did) const;
00415
00417
00418
00419
00426 virtual RemoteDatabase * as_remotedatabase();
00427 };
00428
00429 }
00430
00431 #endif