00001
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <config.h>
00023
00024 #include "remotesubmatch.h"
00025
00026 #include "debuglog.h"
00027 #include "msetpostlist.h"
00028 #include "remote-database.h"
00029 #include "weightinternal.h"
00030
00031 RemoteSubMatch::RemoteSubMatch(RemoteDatabase *db_,
00032 bool decreasing_relevance_,
00033 const vector<Xapian::MatchSpy *> & matchspies_)
00034 : db(db_),
00035 decreasing_relevance(decreasing_relevance_),
00036 matchspies(matchspies_)
00037 {
00038 LOGCALL_CTOR(MATCH, "RemoteSubMatch", db_ | decreasing_relevance_ | matchspies_);
00039 }
00040
00041 bool
00042 RemoteSubMatch::prepare_match(bool nowait,
00043 Xapian::Weight::Internal & total_stats)
00044 {
00045 LOGCALL(MATCH, bool, "RemoteSubMatch::prepare_match", nowait | total_stats);
00046 Xapian::Weight::Internal remote_stats;
00047 if (!db->get_remote_stats(nowait, remote_stats)) RETURN(false);
00048 total_stats += remote_stats;
00049 RETURN(true);
00050 }
00051
00052 void
00053 RemoteSubMatch::start_match(Xapian::doccount first,
00054 Xapian::doccount maxitems,
00055 Xapian::doccount check_at_least,
00056 const Xapian::Weight::Internal & total_stats)
00057 {
00058 LOGCALL_VOID(MATCH, "RemoteSubMatch::start_match", first | maxitems | check_at_least | total_stats);
00059 db->send_global_stats(first, maxitems, check_at_least, total_stats);
00060 }
00061
00062 PostList *
00063 RemoteSubMatch::get_postlist_and_term_info(MultiMatch *,
00064 map<string, Xapian::MSet::Internal::TermFreqAndWeight> * termfreqandwts,
00065 Xapian::termcount * total_subqs_ptr)
00066 {
00067 LOGCALL(MATCH, PostList *, "RemoteSubMatch::get_postlist_and_term_info", Literal("[matcher]") | termfreqandwts | total_subqs_ptr);
00068 Xapian::MSet mset;
00069 db->get_mset(mset, matchspies);
00070 percent_factor = mset.internal->percent_factor;
00071 if (termfreqandwts) *termfreqandwts = mset.internal->termfreqandwts;
00072
00073
00074 (void)total_subqs_ptr;
00075 return new MSetPostList(mset, decreasing_relevance);
00076 }