# Xapian::ValueCountMatchSpy Class Reference

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

`#include <matchspy.h>`

Inheritance diagram for Xapian::ValueCountMatchSpy:

[legend]
Collaboration diagram for Xapian::ValueCountMatchSpy:

[legend]
List of all members.

## Public Member Functions

| ValueCountMatchSpy ()
| Default constructor.
| ValueCountMatchSpy (Xapian::valueno valno, bool multivalue=false)
| Construct a MatchSpy which counts the values in a particular slot.
void | add_slot (Xapian::valueno valno, bool multivalue=false)
| Add a slot number to count values in.
const std::map< std::string, Xapian::doccount > & | get_values (Xapian::valueno valno) const
| Return the values seen in slot number valno.
size_t | get_total () const
| Return the total number of documents tallied.
void | get_top_values (std::vector< StringAndFrequency > &result, Xapian::valueno valno, size_t maxvalues) const
| Get the most frequent values in a slot.
bool | operator() (const Xapian::Document &doc) const
| Implementation of virtual operator().

## Protected Attributes

Xapian::doccount | total
| Total number of documents seen by the match spy.
std::map< Xapian::valueno, std::map< std::string, Xapian::doccount > > | values
| Set of values seen in each slot so far, together with their frequency.
std::set< Xapian::valueno > | multivalues
| Set tracking which value slots can have multiple values.

## Detailed Description

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

## Constructor & Destructor Documentation

Xapian::ValueCountMatchSpy::ValueCountMatchSpy | ( |  | ) | `[inline]`

Default constructor.

Xapian::ValueCountMatchSpy::ValueCountMatchSpy | ( | Xapian::valueno | valno,
|  | bool | multivalue = `false` |
| ) |  |  | `[inline]`

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

Further slots can be added by calling add_slot().

## Member Function Documentation

void Xapian::ValueCountMatchSpy::add_slot | ( | Xapian::valueno | valno,
|  | bool | multivalue = `false` |
| ) |  |  | `[inline]`

Add a slot number to count values in.

A ValueCountMatchSpy can count values in one or more slots.

const std::map<std::string, Xapian::doccount>& Xapian::ValueCountMatchSpy::get_values | ( | Xapian::valueno | valno | ) | const`[inline]`

Return the values seen in slot number valno.

Parameters:

  | valno | The slot to examine (must have specified for examination before performing the match - either by using the add_slot() method, or using the constructor which takes a slot number.)

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

Return the total number of documents tallied.

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

Get the most frequent values in a 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.
  | valno | The slot to examine (must have specified for examination before performing the match - either by using the add_slot() method, or using the constructor which takes a slot number.)
  | maxvalues | The maximum number of values to return.

bool Xapian::ValueCountMatchSpy::operator() | ( | const Xapian::Document & | doc | ) | const`[virtual]`

Implementation of virtual operator().

This implementation tallies values for a matching document.

Implements Xapian::MatchDecider.

## Member Data Documentation

Xapian::doccount Xapian::ValueCountMatchSpy::total`[mutable, protected]`

Total number of documents seen by the match spy.

std::map<Xapian::valueno, std::map<std::string, Xapian::doccount> > Xapian::ValueCountMatchSpy::values`[mutable, protected]`

Set of values seen in each slot so far, together with their frequency.

std::set<Xapian::valueno> Xapian::ValueCountMatchSpy::multivalues`[protected]`

Set tracking which value slots can have multiple values.

If a valuno is in this set, its value is assumed to have been serialised by a StringListSerialiser class.

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

- include/xapian/matchspy.h