22 #ifndef XAPIAN_INCLUDED_POSTINGSOURCE_H
23 #define XAPIAN_INCLUDED_POSTINGSOURCE_H
25 #if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD
26 # error Never use <xapian/postingsource.h> directly; include <xapian.h> instead.
55 double max_weight_ = 0.0;
58 bool* max_weight_cached_flag_ptr =
nullptr;
72 max_weight_cached_flag_ptr = flag_ptr;
126 max_weight_ = max_weight;
127 if (max_weight_cached_flag_ptr) {
128 *max_weight_cached_flag_ptr =
false;
148 virtual double get_weight()
const;
173 virtual void next(
double min_wt) = 0;
287 virtual std::string
name()
const;
298 virtual std::string serialise()
const;
314 virtual PostingSource * unserialise(
const std::string &serialised)
const;
334 virtual PostingSource * unserialise_with_registry(
const std::string &serialised,
381 virtual void init(
const Database& db);
390 virtual std::string get_description()
const;
400 opt_intrusive_base::release();
412 opt_intrusive_base::release();
455 void next(
double min_wt);
508 termfreq_min = termfreq_min_;
519 termfreq_est = termfreq_est_;
530 termfreq_max = termfreq_max_;
533 std::string get_description()
const;
564 double get_weight()
const;
566 std::string
name()
const;
567 std::string serialise()
const;
571 std::string get_description()
const;
615 void skip_if_in_range(
double min_wt);
630 double get_weight()
const override;
632 std::string
name()
const override;
633 std::string serialise()
const override;
635 unserialise(
const std::string& serialised)
const override;
638 void next(
double min_wt)
override;
639 void skip_to(
Xapian::docid min_docid,
double min_wt)
override;
642 std::string get_description()
const override;
677 void add_mapping(
const std::string &key,
double wt);
680 void clear_mappings();
686 void set_default_weight(
double wt);
688 double get_weight()
const override;
690 std::string
name()
const override;
691 std::string serialise()
const override;
693 unserialise(
const std::string& serialised)
const override;
696 std::string get_description()
const override;
736 double get_weight()
const override;
738 void next(
double min_wt)
override;
739 void skip_to(
Xapian::docid min_docid,
double min_wt)
override;
742 bool at_end()
const override;
747 std::string
name()
const override;
748 std::string serialise()
const override;
750 unserialise(
const std::string& serialised)
const override;
753 std::string get_description()
const override;
Compiler attribute macros.
An indexed database of documents.
ValueIterator valuestream_end(Xapian::valueno) const noexcept
Return end iterator corresponding to valuestream_begin().
Read weights from a value which is known to decrease as docid increases.
Xapian::docid range_end
End of range of docids for which weights are known to be decreasing.
double curr_weight
Weight at current position.
Xapian::docid range_start
Start of range of docids for which weights are known to be decreasing.
bool items_at_end
Flag, set to true if there are docs after the end of the range.
A posting source which returns a fixed weight for all documents.
Xapian::PostingIterator it
Iterator over all documents.
bool started
Flag indicating if we've started (true if we have).
Xapian::docid check_docid
The docid last passed to check() (0 if check() wasn't the last move).
Xapian::doccount termfreq
Number of documents in the posting source.
Xapian::Database db
The database we're reading documents from.
Base class for objects managed by opt_intrusive_ptr.
Class for iterating over a list of terms.
Base class which provides an "external" source of postings.
PostingSource(const PostingSource &)=delete
Don't allow copying.
virtual Xapian::doccount get_termfreq_est() const =0
An estimate of the number of documents this object can return.
void set_max_weight_cached_flag_ptr_(bool *flag_ptr)
virtual void next(double min_wt)=0
Advance the current position to the next matching document.
const PostingSource * release() const
Start reference counting this object.
virtual Xapian::doccount get_termfreq_max() const =0
An upper bound on the number of documents this object can return.
PostingSource * release()
Start reference counting this object.
PostingSource() noexcept
Allow subclasses to be instantiated.
virtual Xapian::doccount get_termfreq_min() const =0
A lower bound on the number of documents this object can return.
void set_maxweight(double max_weight)
Specify an upper bound on what get_weight() will return from now on.
virtual Xapian::docid get_docid() const =0
Return the current docid.
virtual bool at_end() const =0
Return true if the current position is past the last entry in this list.
void operator=(const PostingSource &)=delete
Don't allow assignment.
double get_maxweight() const noexcept
Return the currently set upper bound on what get_weight() can return.
Registry for user subclasses.
Class for iterating over document values.
A posting source which looks up weights in a map using values as the key.
std::map< std::string, double > weight_map
The value -> weight map.
double max_weight_in_map
The maximum weight in weight_map.
double default_weight
The default weight.
A posting source which generates weights from a value slot.
Xapian::doccount termfreq_min
void set_termfreq_min(Xapian::doccount termfreq_min_)
Set a lower bound on the term frequency.
Xapian::doccount termfreq_max
Xapian::Database get_database() const
The database we're reading values from.
void set_termfreq_est(Xapian::doccount termfreq_est_)
An estimate of the term frequency.
bool get_started() const
Flag indicating if we've started (true if we have).
Xapian::doccount termfreq_est
ValuePostingSource(Xapian::valueno slot_) noexcept
Construct a ValuePostingSource.
void set_termfreq_max(Xapian::doccount termfreq_max_)
An upper bound on the term frequency.
std::string get_value() const
Read current value.
Xapian::ValueIterator value_it
Xapian::valueno get_slot() const
The slot we're reading values from.
void done()
End the iteration.
A posting source which reads weights from a value slot.
An indexed database of documents.
The Xapian namespace contains public interfaces for the Xapian library.
unsigned valueno
The number for a value slot in a document.
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
Class for iterating over a list of document ids.
Class for iterating over document values.
Define XAPIAN_VISIBILITY_* macros.
#define XAPIAN_VISIBILITY_DEFAULT
#define XAPIAN_VISIBILITY_INTERNAL