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

KeyMaker subclass which combines several values. More...

#include <keymaker.h>

+ Inheritance diagram for Xapian::MultiValueKeyMaker:
+ Collaboration diagram for Xapian::MultiValueKeyMaker:

Classes

struct  KeySpec
 

Public Member Functions

 MultiValueKeyMaker ()
 
template<class Iterator >
 MultiValueKeyMaker (Iterator begin, Iterator end)
 Construct a MultiValueKeyMaker from a pair of iterators. More...
 
virtual std::string operator() (const Xapian::Document &doc) const
 Build a key string for a Document. More...
 
void add_value (Xapian::valueno slot, bool reverse=false, const std::string &defvalue=std::string())
 Add a value slot to the list to build a key from. More...
 
- Public Member Functions inherited from Xapian::KeyMaker
 KeyMaker ()
 Default constructor. More...
 
virtual ~KeyMaker ()
 Virtual destructor, because we have virtual methods. More...
 
KeyMakerrelease ()
 Start reference counting this object. More...
 
const KeyMakerrelease () 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

std::vector< KeySpecslots
 

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

KeyMaker subclass which combines several values.

When the result is used for sorting, results are ordered by the first value. In the event of a tie, the second is used. If this is the same for both, the third is used, and so on. If reverse is true for a value, then the sort order for that value is reversed.

When used for collapsing, the documents will only be considered equal if all the values specified match. If none of the specified values are set then the generated key will be empty, so such documents won't be collapsed (which is consistent with the behaviour in the "collapse on a value" case). If you'd prefer that documents with none of the keys set are collapsed together, then you can set reverse for at least one of the values. Other than this, it isn't useful to set reverse for collapsing.

Definition at line 104 of file keymaker.h.

Constructor & Destructor Documentation

◆ MultiValueKeyMaker() [1/2]

Xapian::MultiValueKeyMaker::MultiValueKeyMaker ( )
inline

Definition at line 117 of file keymaker.h.

◆ MultiValueKeyMaker() [2/2]

template<class Iterator >
Xapian::MultiValueKeyMaker::MultiValueKeyMaker ( Iterator  begin,
Iterator  end 
)
inline

Construct a MultiValueKeyMaker from a pair of iterators.

The iterators must be a begin/end pair returning Xapian::valueno (or a compatible type) when dereferenced.

Definition at line 125 of file keymaker.h.

Member Function Documentation

◆ add_value()

void Xapian::MultiValueKeyMaker::add_value ( Xapian::valueno  slot,
bool  reverse = false,
const std::string &  defvalue = std::string() 
)
inline

Add a value slot to the list to build a key from.

Parameters
slotThe value slot to add
reverseAdjust values from this slot to reverse their sort order (default: false)
defvalueValue to use for documents which don't have a value set in this slot (default: empty). This can be used to make such documents sort after all others by passing get_value_upper_bound(slot) + "x"
  • this is guaranteed to be greater than any value in this slot.

Definition at line 143 of file keymaker.h.

Referenced by DEFINE_TESTCASE().

◆ operator()()

string Xapian::MultiValueKeyMaker::operator() ( const Xapian::Document doc) const
virtual

Build a key string for a Document.

These keys can be used for sorting or collapsing matching documents.

Parameters
docDocument object to build a key for.

Implements Xapian::KeyMaker.

Definition at line 38 of file keymaker.cc.

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

Member Data Documentation

◆ slots

std::vector<KeySpec> Xapian::MultiValueKeyMaker::slots
private

Definition at line 114 of file keymaker.h.


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