1 /** @file remotesubmatch.cc
2 * @brief SubMatch class for a remote database.
4 /* Copyright (C) 2006,2007,2009,2010,2011,2014,2015 Olly Betts
5 * Copyright (C) 2007,2008 Lemur Consulting Ltd
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.
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.
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
24 #include "remotesubmatch.h"
27 #include "msetpostlist.h"
28 #include "backends/remote/remote-database.h"
29 #include "weight/weightinternal.h"
31 RemoteSubMatch::RemoteSubMatch(RemoteDatabase
*db_
,
32 bool decreasing_relevance_
,
33 const vector
<Xapian::Internal::opt_intrusive_ptr
<Xapian::MatchSpy
>> & matchspies_
)
35 decreasing_relevance(decreasing_relevance_
),
36 matchspies(matchspies_
)
38 LOGCALL_CTOR(MATCH
, "RemoteSubMatch", db_
| decreasing_relevance_
| matchspies_
);
42 RemoteSubMatch::prepare_match(bool nowait
,
43 Xapian::Weight::Internal
& total_stats
)
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
;
53 RemoteSubMatch::start_match(Xapian::doccount first
,
54 Xapian::doccount maxitems
,
55 Xapian::doccount check_at_least
,
56 Xapian::Weight::Internal
& total_stats
)
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
);
63 RemoteSubMatch::get_postlist(MultiMatch
* matcher
,
64 Xapian::termcount
* total_subqs_ptr
)
66 LOGCALL(MATCH
, PostList
*, "RemoteSubMatch::get_postlist", matcher
| total_subqs_ptr
);
69 db
->get_mset(mset
, matchspies
);
70 percent_factor
= mset
.internal
->percent_factor
;
71 // For remote databases we report percent_factor rather than counting the
72 // number of subqueries.
73 (void)total_subqs_ptr
;
74 RETURN(new MSetPostList(mset
, decreasing_relevance
));