xapian-core  1.4.21
remotesubmatch.cc
Go to the documentation of this file.
1 
4 /* Copyright (C) 2006,2007,2009,2010,2011,2014,2015 Olly Betts
5  * Copyright (C) 2007,2008 Lemur Consulting Ltd
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #include <config.h>
23 
24 #include "remotesubmatch.h"
25 
26 #include "debuglog.h"
27 #include "msetpostlist.h"
29 #include "weight/weightinternal.h"
30 
32  bool decreasing_relevance_,
34  : db(db_),
35  decreasing_relevance(decreasing_relevance_),
36  matchspies(matchspies_)
37 {
38  LOGCALL_CTOR(MATCH, "RemoteSubMatch", db_ | decreasing_relevance_ | matchspies_);
39 }
40 
41 bool
43  Xapian::Weight::Internal & total_stats)
44 {
45  LOGCALL(MATCH, bool, "RemoteSubMatch::prepare_match", nowait | total_stats);
46  Xapian::Weight::Internal remote_stats;
47  if (!db->get_remote_stats(nowait, remote_stats)) RETURN(false);
48  total_stats += remote_stats;
49  RETURN(true);
50 }
51 
52 void
54  Xapian::doccount maxitems,
55  Xapian::doccount check_at_least,
56  Xapian::Weight::Internal & total_stats)
57 {
58  LOGCALL_VOID(MATCH, "RemoteSubMatch::start_match", first | maxitems | check_at_least | total_stats);
59  db->send_global_stats(first, maxitems, check_at_least, total_stats);
60 }
61 
62 PostList *
64  Xapian::termcount* total_subqs_ptr,
65  Xapian::Weight::Internal& total_stats)
66 {
67  LOGCALL(MATCH, PostList*, "RemoteSubMatch::get_postlist", matcher | total_subqs_ptr | total_stats);
68  (void)matcher;
69  Xapian::MSet mset;
70  db->get_mset(mset, matchspies);
71  percent_factor = mset.internal->percent_factor;
72  uncollapsed_upper_bound = mset.internal->uncollapsed_upper_bound;
73  total_stats.merge(*(mset.internal->stats));
74  // For remote databases we report percent_factor rather than counting the
75  // number of subqueries.
76  (void)total_subqs_ptr;
78 }
#define RETURN(A)
Definition: debuglog.h:482
Abstract base class for postlists.
Definition: postlist.h:37
bool prepare_match(bool nowait, Xapian::Weight::Internal &total_stats)
Fetch and collate statistics.
Xapian::Internal::intrusive_ptr< Internal > internal
Definition: mset.h:52
Class representing a list of search results.
Definition: mset.h:44
RemoteDatabase is the baseclass for remote database implementations.
#define LOGCALL_VOID(CATEGORY, FUNC, PARAMS)
Definition: debuglog.h:477
double percent_factor
The factor to use to convert weights to percentages.
RemoteSubMatch(const RemoteSubMatch &)
Don&#39;t allow copying.
PostList * get_postlist(MultiMatch *matcher, Xapian::termcount *total_subqs_ptr, Xapian::Weight::Internal &total_stats)
Get PostList.
RemoteDatabase * db
The remote database.
void merge(const Weight::Internal &o)
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
Definition: types.h:72
PostList returning entries from an MSet.
SubMatch class for a remote database.
Xapian::Weight::Internal class, holding database and term statistics.
void get_mset(Xapian::MSet &mset, const vector< Xapian::Internal::opt_intrusive_ptr< Xapian::MatchSpy >> &matchspies)
Get the MSet from the remote server.
Class to hold statistics for a given collection.
void send_global_stats(Xapian::doccount first, Xapian::doccount maxitems, Xapian::doccount check_at_least, const Xapian::Weight::Internal &stats)
Send the global stats to the remote server.
const vector< Xapian::Internal::opt_intrusive_ptr< Xapian::MatchSpy > > & matchspies
The matchspies to use.
bool get_remote_stats(bool nowait, Xapian::Weight::Internal &out)
Get the stats from the remote server.
PostList returning entries from an MSet.
Definition: msetpostlist.h:35
RemoteDatabase is the baseclass for remote database implementations.
#define LOGCALL_CTOR(CATEGORY, CLASS, PARAMS)
Definition: debuglog.h:478
bool decreasing_relevance
Is the sort order such the relevance decreases down the MSet?
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
Definition: types.h:38
void start_match(Xapian::doccount first, Xapian::doccount maxitems, Xapian::doccount check_at_least, Xapian::Weight::Internal &total_stats)
Start the match.
Xapian::doccount uncollapsed_upper_bound
uncollapsed_upper_bound from the remote MSet.
Debug logging macros.
#define LOGCALL(CATEGORY, TYPE, FUNC, PARAMS)
Definition: debuglog.h:476