xapian-core  1.4.26
Classes | Public Member Functions | Private Attributes | List of all members
Xapian::ValueCountMatchSpy Class Reference

Class for counting the frequencies of values in the matching documents. More...

#include <matchspy.h>

+ Inheritance diagram for Xapian::ValueCountMatchSpy:
+ Collaboration diagram for Xapian::ValueCountMatchSpy:

Classes

struct  Internal
 

Public Member Functions

 ValueCountMatchSpy ()
 Construct an empty ValueCountMatchSpy. More...
 
 ValueCountMatchSpy (Xapian::valueno slot_)
 Construct a MatchSpy which counts the values in a particular slot. More...
 
size_t get_total () const
 Return the total number of documents tallied. More...
 
TermIterator values_begin () const
 Get an iterator over the values seen in the slot. More...
 
TermIterator values_end () const
 End iterator corresponding to values_begin() More...
 
TermIterator top_values_begin (size_t maxvalues) const
 Get an iterator over the most frequent values seen in the slot. More...
 
TermIterator top_values_end (size_t) const
 End iterator corresponding to top_values_begin() More...
 
void operator() (const Xapian::Document &doc, double wt)
 Implementation of virtual operator(). More...
 
virtual MatchSpyclone () const
 Clone the match spy. More...
 
virtual std::string name () const
 Return the name of this match spy. More...
 
virtual std::string serialise () const
 Return this object's parameters serialised as a single string. More...
 
virtual MatchSpyunserialise (const std::string &serialised, const Registry &context) const
 Unserialise parameters. More...
 
virtual std::string serialise_results () const
 Serialise the results of this match spy. More...
 
virtual void merge_results (const std::string &serialised)
 Unserialise some results, and merge them into this matchspy. More...
 
virtual std::string get_description () const
 Return a string describing this object. More...
 
- Public Member Functions inherited from Xapian::MatchSpy
 MatchSpy ()
 Default constructor, needed by subclass constructors. More...
 
virtual ~MatchSpy ()
 Virtual destructor, because we have virtual methods. More...
 
MatchSpyrelease ()
 Start reference counting this object. More...
 
const MatchSpyrelease () const
 Start reference counting this object. More...
 
- Public Member Functions inherited from Xapian::Internal::opt_intrusive_base
 opt_intrusive_base (const opt_intrusive_base &)
 
opt_intrusive_baseoperator= (const opt_intrusive_base &)
 
 opt_intrusive_base ()
 Construct object which is initially not reference counted. More...
 
virtual ~opt_intrusive_base ()
 
void ref () const
 
void unref () const
 

Private Attributes

Xapian::Internal::intrusive_ptr< Internalinternal
 

Additional Inherited Members

- Public Attributes inherited from Xapian::Internal::opt_intrusive_base
unsigned _refs
 Reference count. More...
 
- Protected Member Functions inherited from Xapian::Internal::opt_intrusive_base
void release () const
 Start reference counting. More...
 

Detailed Description

Class for counting the frequencies of values in the matching documents.

Definition at line 205 of file matchspy.h.

Constructor & Destructor Documentation

◆ ValueCountMatchSpy() [1/2]

Xapian::ValueCountMatchSpy::ValueCountMatchSpy ( )
inline

Construct an empty ValueCountMatchSpy.

Definition at line 234 of file matchspy.h.

◆ ValueCountMatchSpy() [2/2]

Xapian::ValueCountMatchSpy::ValueCountMatchSpy ( Xapian::valueno  slot_)
inlineexplicit

Construct a MatchSpy which counts the values in a particular slot.

Definition at line 237 of file matchspy.h.

Member Function Documentation

◆ clone()

MatchSpy * ValueCountMatchSpy::clone ( ) const
virtual

Clone the match spy.

The clone should inherit the configuration of the parent, but need not inherit the state. ie, the clone does not need to be passed information about the results seen by the parent.

If you don't want to support the remote backend in your match spy, you can use the default implementation which simply throws Xapian::UnimplementedError.

Note that the returned object will be deallocated by Xapian after use with "delete". If you want to handle the deletion in a special way (for example when wrapping the Xapian API for use from another language) then you can define a static operator delete method in your subclass as shown here: https://trac.xapian.org/ticket/554#comment:1

Reimplemented from Xapian::MatchSpy.

Definition at line 323 of file matchspy.cc.

References Assert.

◆ get_description()

string ValueCountMatchSpy::get_description ( ) const
virtual

Return a string describing this object.

This default implementation returns a generic answer, to avoid forcing those deriving their own MatchSpy subclasses from having to implement this (they may not care what get_description() gives for their subclass).

Reimplemented from Xapian::MatchSpy.

Definition at line 402 of file matchspy.cc.

References Xapian::Internal::str().

Referenced by DEFINE_TESTCASE().

◆ get_total()

size_t Xapian::ValueCountMatchSpy::get_total ( ) const
inline

Return the total number of documents tallied.

Definition at line 241 of file matchspy.h.

Referenced by DEFINE_TESTCASE().

◆ merge_results()

void ValueCountMatchSpy::merge_results ( const std::string &  serialised)
virtual

Unserialise some results, and merge them into this matchspy.

The order in which results are merged should not be significant, since this order is not specified (and will vary depending on the speed of the search in each sub-database).

If you don't want to support the remote backend in your match spy, you can use the default implementation which simply throws Xapian::UnimplementedError.

Parameters
serialisedA string containing the serialised results.

Reimplemented from Xapian::MatchSpy.

Definition at line 373 of file matchspy.cc.

References Assert, decode_length(), decode_length_and_check(), and LOGCALL_VOID.

Referenced by DEFINE_TESTCASE().

◆ name()

string ValueCountMatchSpy::name ( ) const
virtual

Return the name of this match spy.

This name is used by the remote backend. It is passed with the serialised parameters to the remote server so that it knows which class to create.

Return the full namespace-qualified name of your class here - if your class is called MyApp::FooMatchSpy, return "MyApp::FooMatchSpy" from this method.

If you don't want to support the remote backend in your match spy, you can use the default implementation which simply throws Xapian::UnimplementedError.

Reimplemented from Xapian::MatchSpy.

Definition at line 329 of file matchspy.cc.

◆ operator()()

void ValueCountMatchSpy::operator() ( const Xapian::Document doc,
double  wt 
)
virtual

Implementation of virtual operator().

This implementation tallies values for a matching document.

Parameters
docThe document to tally values for.
wtThe weight of the document (ignored by this class).

Implements Xapian::MatchSpy.

Definition at line 298 of file matchspy.cc.

References Assert, and Xapian::Document::get_value().

◆ serialise()

string ValueCountMatchSpy::serialise ( ) const
virtual

Return this object's parameters serialised as a single string.

If you don't want to support the remote backend in your match spy, you can use the default implementation which simply throws Xapian::UnimplementedError.

Reimplemented from Xapian::MatchSpy.

Definition at line 334 of file matchspy.cc.

References Assert, and encode_length().

◆ serialise_results()

string ValueCountMatchSpy::serialise_results ( ) const
virtual

Serialise the results of this match spy.

If you don't want to support the remote backend in your match spy, you can use the default implementation which simply throws Xapian::UnimplementedError.

Reimplemented from Xapian::MatchSpy.

Definition at line 357 of file matchspy.cc.

References Assert, encode_length(), LOGCALL, and RETURN.

Referenced by DEFINE_TESTCASE().

◆ top_values_begin()

TermIterator ValueCountMatchSpy::top_values_begin ( size_t  maxvalues) const

Get an iterator over the most frequent values seen in the slot.

Items will be returned in descending order of frequency. Values with the same frequency will be returned in ascending alphabetical order.

During the iteration, the frequency of the current value can be obtained with the get_termfreq() method on the iterator.

Parameters
maxvaluesThe maximum number of values to return.

Definition at line 313 of file matchspy.cc.

References Assert, and get_most_frequent_items().

Referenced by DEFINE_TESTCASE().

◆ top_values_end()

TermIterator Xapian::ValueCountMatchSpy::top_values_end ( size_t  ) const
inline

End iterator corresponding to top_values_begin()

Definition at line 272 of file matchspy.h.

References name.

Referenced by DEFINE_TESTCASE().

◆ unserialise()

MatchSpy * ValueCountMatchSpy::unserialise ( const std::string &  serialised,
const Registry context 
) const
virtual

Unserialise parameters.

This method unserialises parameters serialised by the serialise() method and allocates and returns a new object initialised with them.

If you don't want to support the remote backend in your match spy, you can use the default implementation which simply throws Xapian::UnimplementedError.

Note that the returned object will be deallocated by Xapian after use with "delete". If you want to handle the deletion in a special way (for example when wrapping the Xapian API for use from another language) then you can define a static operator delete method in your subclass as shown here: https://trac.xapian.org/ticket/554#comment:1

Parameters
serialisedA string containing the serialised results.
contextRegistry object to use for unserialisation to permit MatchSpy subclasses with sub-MatchSpy objects to be implemented.

Reimplemented from Xapian::MatchSpy.

Definition at line 342 of file matchspy.cc.

References decode_length().

◆ values_begin()

TermIterator ValueCountMatchSpy::values_begin ( ) const

Get an iterator over the values seen in the slot.

Items will be returned in ascending alphabetical order.

During the iteration, the frequency of the current value can be obtained with the get_termfreq() method on the iterator.

Definition at line 306 of file matchspy.cc.

References Assert.

Referenced by DEFINE_TESTCASE(), and values_to_repr().

◆ values_end()

TermIterator Xapian::ValueCountMatchSpy::values_end ( ) const
inline

End iterator corresponding to values_begin()

Definition at line 255 of file matchspy.h.

Referenced by DEFINE_TESTCASE(), and values_to_repr().

Member Data Documentation

◆ internal

Xapian::Internal::intrusive_ptr<Internal> Xapian::ValueCountMatchSpy::internal
private

Reference counted internals.

Definition at line 230 of file matchspy.h.


The documentation for this class was generated from the following files: