00001
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef OM_HGUARD_OMDATABASE_H
00027 #define OM_HGUARD_OMDATABASE_H
00028
00029 #include "om/omdocument.h"
00030 #include "om/ompostlistiterator.h"
00031 #include "om/omtermlistiterator.h"
00032 #include "om/ompositionlistiterator.h"
00033
00034 class OmWritableDatabase;
00035
00046 class OmDatabase {
00047 public:
00056 void add_database(const OmDatabase & database);
00057
00058 public:
00059 class Internal;
00061 Internal *internal;
00062
00063 public:
00066 OmDatabase();
00067
00070 OmDatabase(OmDatabase::Internal *internal);
00071
00076 virtual ~OmDatabase();
00077
00081 OmDatabase(const OmDatabase &other);
00082
00086 virtual void operator=(const OmDatabase &other);
00087
00093 void reopen();
00094
00099 virtual std::string get_description() const;
00100
00104 OmPostListIterator postlist_begin(const om_termname &tname) const;
00105
00108 OmPostListIterator postlist_end(const om_termname &tname) const;
00109
00113 OmTermIterator termlist_begin(om_docid did) const;
00114
00117 OmTermIterator termlist_end(om_docid did) const;
00118
00122 OmPositionListIterator positionlist_begin(om_docid did, const om_termname &tname) const;
00123
00126 OmPositionListIterator positionlist_end(om_docid did, const om_termname &tname) const;
00127
00130 OmTermIterator allterms_begin() const;
00131
00134 OmTermIterator allterms_end() const;
00135
00137 om_doccount get_doccount() const;
00138
00140 om_doclength get_avlength() const;
00141
00143 om_doccount get_termfreq(const om_termname & tname) const;
00144
00151 bool term_exists(const om_termname & tname) const;
00152
00162 om_termcount get_collection_freq(const om_termname & tname) const;
00163
00166 om_doclength get_doclength(om_docid did) const;
00167
00171 void keep_alive();
00172
00185 OmDocument get_document(om_docid did) const;
00186 };
00187
00190 class OmWritableDatabase : public OmDatabase {
00191 public:
00198 virtual ~OmWritableDatabase();
00199
00202 OmWritableDatabase();
00203
00206 OmWritableDatabase(OmDatabase::Internal *internal);
00207
00211 OmWritableDatabase(const OmWritableDatabase &other);
00212
00220 void operator=(const OmWritableDatabase &other);
00221
00263 void flush();
00264
00287 void begin_transaction();
00288
00315 void commit_transaction();
00316
00335 void cancel_transaction();
00336
00366 om_docid add_document(const OmDocument & document);
00367
00370
00371 void delete_document(om_docid did);
00372
00375
00376 void replace_document(om_docid did, const OmDocument & document);
00377
00382 std::string get_description() const;
00383 };
00384
00385 const int OM_DB_CREATE_OR_OPEN = 1;
00386 const int OM_DB_CREATE = 2;
00387 const int OM_DB_CREATE_OR_OVERWRITE = 3;
00388 const int OM_DB_OPEN = 4;
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00404 OmDatabase OmAuto__open(const std::string &path);
00405
00416 OmWritableDatabase OmAuto__open(const std::string &path, int action);
00417
00422 OmDatabase OmQuartz__open(const std::string &dir);
00423
00438 OmWritableDatabase
00439 OmQuartz__open(const std::string &dir, int action, int block_size = 8192);
00440
00443 OmWritableDatabase OmInMemory__open();
00444
00454 OmDatabase OmMuscat36DA__open(const std::string &R, const std::string &T, bool heavy_duty = true);
00455
00466 OmDatabase OmMuscat36DA__open(const std::string &R, const std::string &T, const std::string &values, bool heavy_duty = true);
00467
00476 OmDatabase OmMuscat36DB__open(const std::string &DB, size_t cache_size = 30);
00477
00487 OmDatabase OmMuscat36DB__open(const std::string &DB, const std::string &values = "", size_t cache_size = 30);
00488
00501 OmDatabase OmRemote__open(const std::string &program, const std::string &args,
00502 unsigned int timeout = 10000);
00503
00520 OmDatabase
00521 OmRemote__open(const std::string &host, unsigned int port,
00522 unsigned int timeout = 10000, unsigned int connect_timeout = 0);
00523
00531 OmDatabase
00532 OmStub__open(const std::string &file);
00533
00534 #endif