Xapian::ValueCountMatchSpy Class Reference

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

Inheritance diagram for Xapian::ValueCountMatchSpy:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 ValueCountMatchSpy ()
 Construct an empty ValueCountMatchSpy.
 ValueCountMatchSpy (Xapian::valueno slot_)
 Construct a MatchSpy which counts the values in a particular slot.
const std::map< std::string,
Xapian::doccount > & 
get_values () const
 Return the values seen in the slot.
size_t get_total () const
 Return the total number of documents tallied.
void get_top_values (std::vector< StringAndFrequency > &result, size_t maxvalues) const
 Get the most frequent values in the slot.
void operator() (const Xapian::Document &doc, Xapian::weight wt)
 Implementation of virtual operator().
virtual MatchSpyclone () const
 Clone the match spy.
virtual std::string name () const
 Return the name of this match spy.
virtual std::string serialise () const
 Return this object's parameters serialised as a single string.
virtual MatchSpyunserialise (const std::string &s, const Registry &context) const
 Unserialise parameters.
virtual std::string serialise_results () const
 Serialise the results of this match spy.
virtual void merge_results (const std::string &s)
 Unserialise some results, and merge them into this matchspy.
virtual std::string get_description () const
 Return a string describing this object.

Protected Attributes

Xapian::valueno slot
 The slot to count.
Xapian::doccount total
 Total number of documents seen by the match spy.
std::map< std::string,
Xapian::doccount
values
 The values seen so far, together with their frequency.


Detailed Description

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

Warning: this API is currently experimental, and is liable to change between releases without warning.


Constructor & Destructor Documentation

Xapian::ValueCountMatchSpy::ValueCountMatchSpy ( Xapian::valueno  slot_  )  [inline]

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

Further slots can be added by calling add_slot().


Member Function Documentation

virtual MatchSpy* Xapian::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". It must therefore have been allocated with "new".

Reimplemented from Xapian::MatchSpy.

virtual std::string Xapian::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.

void Xapian::ValueCountMatchSpy::get_top_values ( std::vector< StringAndFrequency > &  result,
size_t  maxvalues 
) const

Get the most frequent values in the slot.

Parameters:
result A vector which will be filled with the most frequent values, in descending order of frequency. Values with the same frequency will be sorted in ascending alphabetical order.
maxvalues The maximum number of values to return.

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

Return the total number of documents tallied.

virtual void Xapian::ValueCountMatchSpy::merge_results ( const std::string &  s  )  [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.

Reimplemented from Xapian::MatchSpy.

virtual std::string Xapian::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.

void Xapian::ValueCountMatchSpy::operator() ( const Xapian::Document doc,
Xapian::weight  wt 
) [virtual]

Implementation of virtual operator().

This implementation tallies values for a matching document.

Implements Xapian::MatchSpy.

virtual std::string Xapian::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.

virtual std::string Xapian::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.

virtual MatchSpy* Xapian::ValueCountMatchSpy::unserialise ( const std::string &  s,
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". It must therefore have been allocated with "new".

Reimplemented from Xapian::MatchSpy.


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

Documentation for Xapian (version 1.1.3).
Generated on 18 Nov 2009 by Doxygen 1.5.9.