File: localsubmatch.h

package info (click to toggle)
xapian-core 1.4.3-2%2Bdeb9u3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 21,412 kB
  • sloc: cpp: 113,868; ansic: 8,723; sh: 4,433; perl: 836; makefile: 566; tcl: 317; python: 40
file content (105 lines) | stat: -rw-r--r-- 3,265 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/** @file localsubmatch.h
 *  @brief SubMatch class for a local database.
 */
/* Copyright (C) 2006,2007,2009,2010,2011,2013,2014,2015,2016 Olly Betts
 * Copyright (C) 2007 Lemur Consulting Ltd
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 */

#ifndef XAPIAN_INCLUDED_LOCALSUBMATCH_H
#define XAPIAN_INCLUDED_LOCALSUBMATCH_H

#include "backends/database.h"
#include "debuglog.h"
#include "api/leafpostlist.h"
#include "api/queryinternal.h"
#include "submatch.h"
#include "xapian/enquire.h"
#include "xapian/weight.h"

#include <map>

class LeafPostList;

class LocalSubMatch : public SubMatch {
    /// Don't allow assignment.
    void operator=(const LocalSubMatch &);

    /// Don't allow copying.
    LocalSubMatch(const LocalSubMatch &);

    /// The statistics for the collection.
    Xapian::Weight::Internal * stats;

    /// The original query before any rearrangement.
    Xapian::Query query;

    /// The query length (used by some weighting schemes).
    Xapian::termcount qlen;

    /// The (sub-)Database we're searching.
    const Xapian::Database::Internal *db;

    /** The RSet (used to calculate R and r).
     *
     *  R and r are used in probabilistic weighting formulae.
     */
    Xapian::RSet rset;

    /// Weight object (used as a factory by calling create on it).
    const Xapian::Weight * wt_factory;

  public:
    /// Constructor.
    LocalSubMatch(const Xapian::Database::Internal *db_,
		  const Xapian::Query & query_,
		  Xapian::termcount qlen_,
		  const Xapian::RSet & rset_,
		  const Xapian::Weight *wt_factory_)
	: stats(NULL), query(query_), qlen(qlen_), db(db_), rset(rset_),
	  wt_factory(wt_factory_)
    {
	LOGCALL_CTOR(MATCH, "LocalSubMatch", db_ | query_ | qlen_ | rset_ | wt_factory_);
    }

    /// Fetch and collate statistics.
    bool prepare_match(bool nowait, Xapian::Weight::Internal & total_stats);

    /// Start the match.
    void start_match(Xapian::doccount first,
		     Xapian::doccount maxitems,
		     Xapian::doccount check_at_least,
		     Xapian::Weight::Internal & total_stats);

    /// Get PostList.
    PostList * get_postlist(MultiMatch *matcher,
			    Xapian::termcount * total_subqs_ptr);

    /** Convert a postlist into a synonym postlist.
     */
    PostList * make_synonym_postlist(PostList * or_pl, MultiMatch * matcher,
				     double factor);

    LeafPostList * open_post_list(const std::string& term,
				  Xapian::termcount wqf,
				  double factor,
				  bool need_positions,
				  bool in_synonym,
				  QueryOptimiser * qopt,
				  bool lazy_weight);
};

#endif /* XAPIAN_INCLUDED_LOCALSUBMATCH_H */