xapian-core  2.0.0
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
Matcher Class Reference

#include <matcher.h>

+ Collaboration diagram for Matcher:

Public Member Functions

 Matcher (const Xapian::Database &db_, const Xapian::Query &query, Xapian::termcount query_length, const Xapian::RSet *rset, Xapian::Weight::Internal &stats, const Xapian::Weight &wtscheme, bool have_mdecider, Xapian::valueno collapse_key, Xapian::doccount collapse_max, int percent_threshold, double weight_threshold, Xapian::Enquire::docid_order order, Xapian::valueno sort_key, Xapian::Enquire::Internal::sort_setting sort_by, bool sort_val_reverse, double time_limit, const std::vector< opt_ptr_spy > &matchspies)
 Constructor. More...
 
Xapian::MSet get_mset (Xapian::doccount first, Xapian::doccount maxitems, Xapian::doccount check_at_least, Xapian::Weight::Internal &stats, const Xapian::Weight &wtscheme, const Xapian::MatchDecider *mdecider, const Xapian::KeyMaker *sorter, Xapian::valueno collapse_key, Xapian::doccount collapse_max, int percent_threshold, double weight_threshold, Xapian::Enquire::docid_order order, Xapian::valueno sort_key, Xapian::Enquire::Internal::sort_setting sort_by, bool sort_val_reverse, double time_limit, const std::vector< opt_ptr_spy > &matchspies)
 Run the match and produce an MSet object. More...
 

Private Types

typedef Xapian::Internal::opt_intrusive_ptr< Xapian::MatchSpyopt_ptr_spy
 

Private Member Functions

 Matcher (const Matcher &)=delete
 
Matcheroperator= (const Matcher &)=delete
 
Xapian::MSet get_local_mset (Xapian::doccount first, Xapian::doccount maxitems, Xapian::doccount check_at_least, const Xapian::Weight &wtscheme, const Xapian::MatchDecider *mdecider, const Xapian::KeyMaker *sorter, Xapian::valueno collapse_key, Xapian::doccount collapse_max, int percent_threshold, double percent_threshold_factor, double weight_threshold, Xapian::Enquire::docid_order order, Xapian::valueno sort_key, Xapian::Enquire::Internal::sort_setting sort_by, bool sort_val_reverse, double time_limit, const std::vector< opt_ptr_spy > &matchspies)
 
template<typename Action >
void for_all_remotes (Action action)
 Perform action on remotes as they become ready using poll() or select(). More...
 

Private Attributes

Xapian::Database db
 
std::vector< std::unique_ptr< LocalSubMatch > > locals
 LocalSubMatch objects for local databases. More...
 
std::vector< std::unique_ptr< RemoteSubMatch > > remotes
 RemoteSubMatch objects for remote databases. More...
 
std::size_t first_nonselectable
 Partition point in remotes. More...
 

Detailed Description

Definition at line 46 of file matcher.h.

Member Typedef Documentation

◆ opt_ptr_spy

Definition at line 47 of file matcher.h.

Constructor & Destructor Documentation

◆ Matcher() [1/2]

Matcher::Matcher ( const Matcher )
privatedelete

◆ Matcher() [2/2]

Matcher::Matcher ( const Xapian::Database db_,
const Xapian::Query query,
Xapian::termcount  query_length,
const Xapian::RSet rset,
Xapian::Weight::Internal stats,
const Xapian::Weight wtscheme,
bool  have_mdecider,
Xapian::valueno  collapse_key,
Xapian::doccount  collapse_max,
int  percent_threshold,
double  weight_threshold,
Xapian::Enquire::docid_order  order,
Xapian::valueno  sort_key,
Xapian::Enquire::Internal::sort_setting  sort_by,
bool  sort_val_reverse,
double  time_limit,
const std::vector< opt_ptr_spy > &  matchspies 
)

Constructor.

Parameters
db_Database to search
queryQuery object
query_lengthQuery length
rsetRelevance set (NULL for none)
statsObject to collate stats into
wtschemeWeight object to use as factory
have_mdeciderMatchDecider specified?
collapse_keyvalue slot to collapse on (Xapian::BAD_VALUENO which means no collapsing)
collapse_maxMaximum number of documents with the same key to allow
percent_thresholdLower bound on percentage score
weight_thresholdLower bound on weight
orderXapian::docid sort order
sort_keyValue slot to sort on
sort_byWhat to sort results on
sort_val_reverseReverse direction keys sort in?
time_limittime in seconds after which to disable check_at_least (0.0 means don't).
matchspiesMatchSpy objects to use

Member Function Documentation

◆ for_all_remotes()

template<typename Action >
void Matcher::for_all_remotes ( Action  action)
inlineprivate

Perform action on remotes as they become ready using poll() or select().

Definition at line 80 of file matcher.cc.

References socket_errno().

Referenced by get_mset().

◆ get_local_mset()

Xapian::MSet Matcher::get_local_mset ( Xapian::doccount  first,
Xapian::doccount  maxitems,
Xapian::doccount  check_at_least,
const Xapian::Weight wtscheme,
const Xapian::MatchDecider mdecider,
const Xapian::KeyMaker sorter,
Xapian::valueno  collapse_key,
Xapian::doccount  collapse_max,
int  percent_threshold,
double  percent_threshold_factor,
double  weight_threshold,
Xapian::Enquire::docid_order  order,
Xapian::valueno  sort_key,
Xapian::Enquire::Internal::sort_setting  sort_by,
bool  sort_val_reverse,
double  time_limit,
const std::vector< opt_ptr_spy > &  matchspies 
)
private

◆ get_mset()

Xapian::MSet Matcher::get_mset ( Xapian::doccount  first,
Xapian::doccount  maxitems,
Xapian::doccount  check_at_least,
Xapian::Weight::Internal stats,
const Xapian::Weight wtscheme,
const Xapian::MatchDecider mdecider,
const Xapian::KeyMaker sorter,
Xapian::valueno  collapse_key,
Xapian::doccount  collapse_max,
int  percent_threshold,
double  weight_threshold,
Xapian::Enquire::docid_order  order,
Xapian::valueno  sort_key,
Xapian::Enquire::Internal::sort_setting  sort_by,
bool  sort_val_reverse,
double  time_limit,
const std::vector< opt_ptr_spy > &  matchspies 
)

Run the match and produce an MSet object.

Parameters
firstZero-based index of the first result to return (which supports retrieving pages of results).
maxitemsThe maximum number of documents to return.
checkatleastCheck at least this many documents. By default Xapian will avoiding considering documents which it can prove can't match, which is faster but can result in a loose bounds on and a poor estimate of the total number of matches - setting checkatleast higher allows trading off speed for tighter bounds and a more accurate estimate.
msetMSet object to full in
statsCollated stats
wtschemeWeight object to use as factory
mdeciderMatchDecider to use (NULL for none)
sorterKeyMaker for sort keys (NULL for none)
collapse_keyvalue slot to collapse on (Xapian::BAD_VALUENO which means no collapsing)
collapse_maxMaximum number of documents with the same key to allow
collapse_keyvalue slot to collapse on (Xapian::BAD_VALUENO which means no collapsing)
collapse_maxMaximum number of documents with the same key to allow
percent_thresholdLower bound on percentage score
weight_thresholdLower bound on weight
orderXapian::docid sort order
sort_keyValue slot to sort on
sort_byWhat to sort results on
sort_val_reverseReverse direction keys sort in?
time_limittime in seconds after which to disable check_at_least (0.0 means don't).
matchspiesMatchSpy objects to use

Definition at line 577 of file matcher.cc.

References Assert, AssertRel, db, Xapian::MSet::empty(), for_all_remotes(), Xapian::Internal::intrusive_ptr_nonnull< T >::get(), get_local_mset(), RemoteSubMatch::get_mset(), RemoteSubMatch::get_shard(), if(), Xapian::Database::internal, Xapian::MSet::internal, locals, remotes, and RemoteSubMatch::start_match().

Referenced by Xapian::Enquire::Internal::get_mset(), and RemoteServer::msg_query().

◆ operator=()

Matcher& Matcher::operator= ( const Matcher )
privatedelete

Member Data Documentation

◆ db

Xapian::Database Matcher::db
private

Definition at line 49 of file matcher.h.

Referenced by get_local_mset(), and get_mset().

◆ first_nonselectable

std::size_t Matcher::first_nonselectable
private

Partition point in remotes.

We call select() on remotes[i]->get_read_fd() for all i < first_nonselectable. See doc comment for remotes for more details.

Definition at line 86 of file matcher.h.

◆ locals

std::vector<std::unique_ptr<LocalSubMatch> > Matcher::locals
private

LocalSubMatch objects for local databases.

The entries are at the same index as the corresponding shard in the Database object, with NULL entries for any remote shards.

Definition at line 56 of file matcher.h.

Referenced by get_local_mset(), and get_mset().

◆ remotes

std::vector<std::unique_ptr<RemoteSubMatch> > Matcher::remotes
private

RemoteSubMatch objects for remote databases.

Unlike locals, this only contains entries for remote shards, and each RemoteSubMatch object knows its shard index.

If poll() isn't available then select() has to be used to wait for fds to become ready to read, which imposes some limitations:

  • Generally select() only works for fds < FD_SETSIZE
  • On Microsoft Windows, select() only works for sockets and FD_SETSIZE has a different meaning - it's the maximum number of sockets which we can select() on at once.

To work within these limitations, we order the objects in the vector so the ones we can select() on all come before the ones we can't select() on.

The partition point is recorded in first_nonselectable.

Definition at line 78 of file matcher.h.

Referenced by get_mset().


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