matcher/remotesubmatch.cc

Go to the documentation of this file.
00001 
00004 /* Copyright (C) 2006,2007 Olly Betts
00005  * Copyright (C) 2007,2008 Lemur Consulting Ltd
00006  *
00007  * This program is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2 of the License, or
00010  * (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 USA
00020  */
00021 
00022 #include <config.h>
00023 #include "remotesubmatch.h"
00024 
00025 #include "msetpostlist.h"
00026 #include "omdebug.h"
00027 #include "remote-database.h"
00028 #include "stats.h"
00029 
00030 RemoteSubMatch::RemoteSubMatch(RemoteDatabase *db_, bool decreasing_relevance_)
00031         : db(db_), decreasing_relevance(decreasing_relevance_)
00032 {
00033     DEBUGCALL(MATCH, void, "RemoteSubMatch",
00034               db_ << ", " << decreasing_relevance_);
00035 }
00036 
00037 bool
00038 RemoteSubMatch::prepare_match(bool nowait, Stats & total_stats)
00039 {
00040     DEBUGCALL(MATCH, bool, "RemoteSubMatch::prepare_match", nowait);
00041     Stats remote_stats;
00042     if (!db->get_remote_stats(nowait, remote_stats)) RETURN(false);
00043     total_stats += remote_stats;
00044     RETURN(true);
00045 }
00046 
00047 void
00048 RemoteSubMatch::start_match(Xapian::doccount first,
00049                             Xapian::doccount maxitems,
00050                             Xapian::doccount check_at_least,
00051                             const Stats & total_stats)
00052 {
00053     DEBUGCALL(MATCH, void, "RemoteSubMatch::start_match",
00054               first << ", " << maxitems << ", " << check_at_least);
00055     db->send_global_stats(first, maxitems, check_at_least, total_stats);
00056 }
00057 
00058 PostList *
00059 RemoteSubMatch::get_postlist_and_term_info(MultiMatch *,
00060         map<string, Xapian::MSet::Internal::TermFreqAndWeight> * termfreqandwts)
00061 {
00062     DEBUGCALL(MATCH, PostList *, "RemoteSubMatch::get_postlist_and_term_info",
00063               "[matcher], " << (void*)termfreqandwts);
00064     Xapian::MSet mset;
00065     db->get_mset(mset);
00066     percent_factor = mset.internal->percent_factor;
00067     if (termfreqandwts) *termfreqandwts = mset.internal->termfreqandwts;
00068     return new MSetPostList(mset, decreasing_relevance);
00069 }

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