backends/multi/multi_termlist.cc

Go to the documentation of this file.
00001 /* multi_termlist.cc: C++ class definition for multiple database access
00002  *
00003  * Copyright 1999,2000,2001 BrightStation PLC
00004  * Copyright 2002,2003,2004,2005,2006,2007 Olly Betts
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License as
00008  * published by the Free Software Foundation; either version 2 of the
00009  * License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
00019  * USA
00020  */
00021 
00022 #include <config.h>
00023 
00024 #include "expandweight.h"
00025 #include "omdebug.h"
00026 #include "multi_termlist.h"
00027 #include "database.h"
00028 
00029 MultiTermList::MultiTermList(TermList * tl_,
00030                              const Xapian::Database &db_,
00031                              size_t db_index_)
00032         : tl(tl_), db(db_), db_index(db_index_)
00033 {
00034     termfreq_factor = double(db.get_doccount());
00035     termfreq_factor /= db.internal[db_index]->get_doccount();
00036     DEBUGLINE(DB, "Approximation factor for termfreq: " << termfreq_factor);
00037 }
00038 
00039 MultiTermList::~MultiTermList()
00040 {
00041     delete tl;
00042 }
00043 
00044 Xapian::termcount
00045 MultiTermList::get_approx_size() const
00046 {
00047     return tl->get_approx_size();
00048 }
00049 
00050 void
00051 MultiTermList::accumulate_stats(Xapian::Internal::ExpandStats & stats) const
00052 {
00053     // For a multidb, every termlist access during expand will be through
00054     // a MultiTermList, so it's safe to just set db_index like this.
00055     stats.db_index = db_index;
00056     tl->accumulate_stats(stats);
00057 }
00058 
00059 string
00060 MultiTermList::get_termname() const
00061 {
00062     return tl->get_termname();
00063 }
00064 
00065 Xapian::termcount MultiTermList::get_wdf() const
00066 {
00067     return tl->get_wdf();
00068 }
00069 
00070 Xapian::doccount MultiTermList::get_termfreq() const
00071 {
00072     // Approximate term frequency
00073     return Xapian::doccount(tl->get_termfreq() * termfreq_factor);
00074 }
00075 
00076 TermList * MultiTermList::next()
00077 {
00078     return tl->next();
00079 }
00080 
00081 bool MultiTermList::at_end() const
00082 {
00083     return tl->at_end();
00084 }
00085 
00086 Xapian::termpos
00087 MultiTermList::positionlist_count() const
00088 {
00089     return tl->positionlist_count();
00090 }
00091 
00092 Xapian::PositionIterator
00093 MultiTermList::positionlist_begin() const
00094 {
00095     return tl->positionlist_begin();
00096 }

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