common/rset.h

Go to the documentation of this file.
00001 /* rset.h
00002  *
00003  * Copyright 1999,2000,2001 BrightStation PLC
00004  * Copyright 2003,2005,2006 Olly Betts
00005  * Copyright 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
00020  * USA
00021  */
00022 
00023 #ifndef OM_HGUARD_RSET_H
00024 #define OM_HGUARD_RSET_H
00025 
00026 #include <set>
00027 #include <map>
00028 #include "omassert.h"
00029 #include "omdebug.h"
00030 #include "xapian/enquire.h"
00031 #include "omenquireinternal.h"
00032 
00033 // Forward declaration.
00034 class Stats;
00035 
00041 class RSetI {
00042     private:
00043         // disallow copy
00044         RSetI(const RSetI &);
00045         void operator=(const RSetI &);
00046 
00047         // FIXME: should use one or the other (probably Xapian::Database)
00048         const Xapian::Database root;
00049         const Xapian::Database::Internal *dbroot;
00050 
00051         std::map<string, Xapian::doccount> reltermfreqs;
00052         bool calculated_reltermfreqs;
00053 
00058         void calculate_stats();
00059     public:
00060         std::set<Xapian::docid> documents;
00061 
00062         RSetI(const Xapian::Database &root_, const Xapian::RSet & rset);
00063         RSetI(const Xapian::Database::Internal *dbroot_, const Xapian::RSet & rset);
00064 
00069         void will_want_reltermfreq(string tname);
00070 
00077         void contribute_stats(Stats & stats);
00078 
00080         Xapian::doccount get_rsize() const;
00081 };
00082 
00084 // Inline method definitions //
00086 
00088 inline
00089 RSetI::RSetI(const Xapian::Database &root_, const Xapian::RSet & rset)
00090         : root(root_), dbroot(NULL), calculated_reltermfreqs(false),
00091           documents(rset.internal->get_items())
00092 {
00093 }
00094 
00096 inline
00097 RSetI::RSetI(const Xapian::Database::Internal *dbroot_, const Xapian::RSet & rset)
00098         : dbroot(dbroot_), calculated_reltermfreqs(false),
00099           documents(rset.internal->get_items())
00100 {
00101 }
00102 
00103 inline void
00104 RSetI::will_want_reltermfreq(string tname)
00105 {
00106     reltermfreqs[tname] = 0;
00107 }
00108 
00109 inline Xapian::doccount
00110 RSetI::get_rsize() const
00111 {
00112     return documents.size();
00113 }
00114 
00115 #endif /* OM_HGUARD_RSET_H */

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