Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

include/xapian/database.h

Go to the documentation of this file.
00001 
00004 /* ----START-LICENCE----
00005  * Copyright 1999,2000,2001 BrightStation PLC
00006  * Copyright 2002 Ananova Ltd
00007  * Copyright 2002,2003 Olly Betts
00008  *
00009  * This program is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU General Public License as
00011  * published by the Free Software Foundation; either version 2 of the
00012  * License, or (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00022  * USA
00023  * -----END-LICENCE-----
00024  */
00025 
00026 #ifndef XAPIAN_INCLUDED_DATABASE_H
00027 #define XAPIAN_INCLUDED_DATABASE_H
00028 
00029 #include <string>
00030 #include <vector>
00031 
00032 #include <xapian/base.h>
00033 #include <xapian/types.h>
00034 
00035 namespace Xapian {
00036     
00037 class Document;
00038 class PositionIterator;
00039 class PostingIterator;
00040 class TermIterator;
00041 class WritableDatabase;
00042 
00053 class Database {
00054     public:
00060         void add_database(const Database & database);
00061     
00062     public:
00063         class Internal;
00065         std::vector<Xapian::Internal::RefCntPtr<Internal> > internal;
00066 
00067     public:
00070         Database();
00071 
00074         Database(Internal *internal);
00075 
00081         virtual ~Database();
00082 
00086         Database(const Database &other);
00087 
00091         virtual void operator=(const Database &other);
00092 
00098         void reopen();
00099 
00104         virtual std::string get_description() const;
00105 
00109         PostingIterator postlist_begin(const std::string &tname) const;
00110 
00113         PostingIterator postlist_end(const std::string &tname) const;
00114 
00118         TermIterator termlist_begin(Xapian::docid did) const;
00119         
00122         TermIterator termlist_end(Xapian::docid did) const;
00123 
00127         PositionIterator positionlist_begin(Xapian::docid did, const std::string &tname) const;
00128 
00131         PositionIterator positionlist_end(Xapian::docid did, const std::string &tname) const;
00132 
00135         TermIterator allterms_begin() const;
00136 
00139         TermIterator allterms_end() const;
00140 
00142         Xapian::doccount get_doccount() const;
00143         
00145         Xapian::doclength get_avlength() const;
00146 
00148         Xapian::doccount get_termfreq(const std::string & tname) const;
00149 
00156         bool term_exists(const std::string & tname) const;
00157 
00167         Xapian::termcount get_collection_freq(const std::string & tname) const;
00168 
00171         Xapian::doclength get_doclength(Xapian::docid did) const;
00172 
00176         void keep_alive();
00177 
00190         Xapian::Document get_document(Xapian::docid did) const;
00191 };
00192 
00195 class WritableDatabase : public Database {
00196     public:
00203         virtual ~WritableDatabase();
00204 
00207         WritableDatabase();
00208 
00211         WritableDatabase(Database::Internal *internal);
00212 
00216         WritableDatabase(const WritableDatabase &other);
00217 
00225         void operator=(const WritableDatabase &other);
00226 
00268         void flush();
00269 
00292         void begin_transaction();
00293 
00320         void commit_transaction();
00321 
00340         void cancel_transaction();
00341 
00371         Xapian::docid add_document(const Xapian::Document & document);
00372 
00375         // FIXME: document more.
00376         void delete_document(Xapian::docid did);
00377 
00380         // FIXME: document more.
00381         void replace_document(Xapian::docid did, const Xapian::Document & document);
00382 
00387         std::string get_description() const;
00388 };
00389 
00390 const int DB_CREATE_OR_OPEN = 1;
00391 const int DB_CREATE = 2;
00392 const int DB_CREATE_OR_OVERWRITE = 3;
00393 const int DB_OPEN = 4;
00394 // Can't see any sensible use for this one
00395 // const int DB_OVERWRITE = XXX;
00396 
00397 /* It's mostly harmless to provide prototypes for all the backends, even
00398  * if they may not all be built in - it means the failure will be at
00399  * link time rather than when a file is built.  The main benefit is
00400  * simplicity, but this also allows us to easily split the backends into
00401  * separate libraries and link the ones we actually use in an application.
00402  */
00403 
00404 namespace Auto {
00410 Database open(const std::string &path);
00411 
00422 WritableDatabase open(const std::string &path, int action);
00423 
00431 Database open_stub(const std::string &file);
00432 
00433 }
00434 
00435 namespace Quartz {
00440 Database open(const std::string &dir);
00441 
00456 WritableDatabase
00457 open(const std::string &dir, int action, int block_size = 8192);
00458 
00459 }
00460 
00461 namespace InMemory {
00464 WritableDatabase open();
00465 }
00466 
00467 namespace Muscat36 {
00477 Database open_da(const std::string &R, const std::string &T, bool heavy_duty = true);
00478 
00489 Database open_da(const std::string &R, const std::string &T, const std::string &values, bool heavy_duty = true);
00490 
00499 Database open_db(const std::string &DB, size_t cache_size = 30);
00500 
00510 Database open_db(const std::string &DB, const std::string &values = "", size_t cache_size = 30);
00511 }
00512 
00513 namespace Remote {
00526 Database open(const std::string &program, const std::string &args,
00527         Xapian::timeout timeout = 10000);
00528 
00545 Database
00546 open(const std::string &host, unsigned int port,
00547         Xapian::timeout timeout = 10000, Xapian::timeout connect_timeout = 0);
00548 }
00549 
00550 }
00551 
00552 #endif /* XAPIAN_INCLUDED_DATABASE_H */

Documentation for Xapian (version 0.6.5).
Generated on 4 Jul 2003 by Doxygen 1.2.15.