xapian-core  1.4.25
leafpostlist.h
Go to the documentation of this file.
1 
4 /* Copyright (C) 2007,2009,2011,2013,2015,2016,2020 Olly Betts
5  * Copyright (C) 2009 Lemur Consulting Ltd
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License as
9  * published by the Free Software Foundation; either version 2 of the
10  * License, or (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 #ifndef XAPIAN_INCLUDED_LEAFPOSTLIST_H
23 #define XAPIAN_INCLUDED_LEAFPOSTLIST_H
24 
25 #include "postlist.h"
26 
27 #include <string>
28 
29 namespace Xapian {
30  class Weight;
31 }
32 
38 class LeafPostList : public PostList {
40  void operator=(const LeafPostList &);
41 
43  LeafPostList(const LeafPostList &);
44 
45  protected:
47 
48  bool need_doclength, need_unique_terms;
49 
51  std::string term;
52 
54  explicit LeafPostList(const std::string & term_)
55  : weight(0), need_doclength(false), need_unique_terms(false),
56  term(term_) { }
57 
58  public:
59  ~LeafPostList();
60 
70  void set_termweight(const Xapian::Weight * weight_);
71 
74  Xapian::termcount qlen,
76  double factor)
77  {
78  weight_->init_(*stats, qlen, term, wqf, factor, this);
79  // There should be an existing LazyWeight set already.
80  Assert(weight);
81  const Xapian::Weight * const_weight_ = weight_;
82  std::swap(weight, const_weight_);
83  delete const_weight_;
84  need_doclength = weight->get_sumpart_needs_doclength_();
85  // We get such terms from the database so they should exist.
86  Assert(get_termfreq() > 0);
87  stats->termfreqs[term].max_part += weight->get_maxpart();
88  return stats->termfreqs[term].max_part;
89  }
90 
96  virtual Xapian::doccount get_termfreq() const = 0;
97 
98  Xapian::doccount get_termfreq_min() const;
99  Xapian::doccount get_termfreq_max() const;
100  Xapian::doccount get_termfreq_est() const;
101 
102  double get_maxweight() const;
103  double get_weight() const;
104  double recalc_maxweight();
105 
106  TermFreqs get_termfreq_est_using_stats(
107  const Xapian::Weight::Internal & stats) const;
108 
109  Xapian::termcount count_matching_subqs() const;
110 
111  void gather_position_lists(OrPositionList* orposlist);
112 
125  virtual LeafPostList * open_nearby_postlist(const std::string & term_) const;
126 
127  virtual Xapian::termcount get_wdf_upper_bound() const = 0;
128 
136  void set_term(const std::string & term_) { term = term_; }
137 };
138 
139 #endif // XAPIAN_INCLUDED_LEAFPOSTLIST_H
The Xapian namespace contains public interfaces for the Xapian library.
Definition: compactor.cc:80
#define Assert(COND)
Definition: omassert.h:122
Abstract base class for postlists.
Definition: postlist.h:37
double resolve_lazy_termweight(Xapian::Weight *weight_, Xapian::Weight::Internal *stats, Xapian::termcount qlen, Xapian::termcount wqf, double factor)
Definition: leafpostlist.h:72
const Xapian::Weight * weight
Definition: leafpostlist.h:46
Abstract base class for leaf postlists.
Definition: leafpostlist.h:38
std::string term
The term name for this postlist (empty for an alldocs postlist).
Definition: leafpostlist.h:51
#define false
Definition: header.h:9
Abstract base class for postlists.
bool get_sumpart_needs_doclength_() const
Definition: weight.h:322
std::map< std::string, TermFreqs > termfreqs
Map of term frequencies and relevant term frequencies for the collection.
virtual double get_maxpart() const =0
Return an upper bound on what get_sumpart() can return for any document.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
Definition: types.h:72
void init_(const Internal &stats, Xapian::termcount query_len_, const std::string &term, Xapian::termcount wqf_, double factor)
Definition: weight.cc:93
Class to hold statistics for a given collection.
LeafPostList(const std::string &term_)
Only constructable as a base class for derived classes.
Definition: leafpostlist.h:54
The frequencies for a term.
void set_term(const std::string &term_)
Set the term name.
Definition: leafpostlist.h:136
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
Definition: types.h:38
bool need_unique_terms
Definition: leafpostlist.h:48
Abstract base class for weighting schemes.
Definition: weight.h:35