Update for 1.4.18
[xapian.git] / xapian-core / common / submatch.h
blobf199802cb9e8ce35ee16a38809eb9c1c8fd3b921
1 /** @file submatch.h
2 * @brief base class for sub-matchers
3 */
4 /* Copyright (C) 2006,2007,2009,2011,2014 Olly Betts
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef XAPIAN_INCLUDED_SUBMATCH_H
22 #define XAPIAN_INCLUDED_SUBMATCH_H
24 #include "xapian/intrusive_ptr.h"
25 #include <xapian/types.h>
27 #include "api/omenquireinternal.h"
28 #include "api/postlist.h"
29 #include "xapian/weight.h"
31 class MultiMatch;
33 class SubMatch : public Xapian::Internal::intrusive_base {
34 public:
35 /** Virtual destructor.
37 * Required because we have virtual methods and delete derived objects
38 * via a pointer to this base class.
40 virtual ~SubMatch() { }
42 /** Fetch and collate statistics.
44 * Before we can calculate term weights we need to fetch statistics from
45 * each database involved and collate them.
47 * @param nowait A RemoteSubMatch may not be able to report statistics
48 * when first asked. If nowait is true, it will return
49 * false in this situation allowing the matcher to ask
50 * other database. If nowait is false, then this method
51 * will block until statistics are available.
53 * @param total_stats A stats object to which the statistics should be
54 * added.
56 * @return If nowait is true and results aren't available yet
57 * then false will be returned and this method must be
58 * called again before the match can proceed. If results
59 * are available or nowait is false, then this method
60 * returns true.
62 virtual bool prepare_match(bool nowait,
63 Xapian::Weight::Internal & total_stats) = 0;
65 /** Start the match.
67 * @param first The first item in the result set to return.
68 * @param maxitems The maximum number of items to return.
69 * @param check_at_least The minimum number of items to check.
70 * @param total_stats The total statistics for the collection.
72 virtual void start_match(Xapian::doccount first,
73 Xapian::doccount maxitems,
74 Xapian::doccount check_at_least,
75 Xapian::Weight::Internal & total_stats) = 0;
77 /// Get PostList.
78 virtual PostList * get_postlist(MultiMatch *matcher,
79 Xapian::termcount* total_subqs_ptr,
80 Xapian::Weight::Internal& total_stats) = 0;
83 #endif /* XAPIAN_INCLUDED_SUBMATCH_H */