Public Member Functions | Protected Member Functions | Protected Attributes | Friends

Sphinx::MultiQueryOpt_t Class Reference

Optimisation-enabled multi query data structure. More...

#include <sphinxclient.h>

Public Member Functions

 MultiQueryOpt_t (SearchCommandVersion_t cmdVersion=VER_COMMAND_SEARCH_0_9_9)
 Constructor of multiquery.
void optimise ()
void addQuery (const std::string &query, const SearchConfig_t &queryAttr)
 adds a query to multi-query

Protected Member Functions

void initQuery (SearchCommandVersion_t commandVersion)
 resets query data and multi-query command version
Sphinx::Query_t getGroupQuery (size_t groupIndex) const
size_t getGroupQueryCount () const
 returns input query count
int getQueryCount () const
size_t getQueryCountAtGroup (size_t groupIndex) const
 get count of input queries in query group
size_t getResponseIndex (size_t sortedIndex) const
 Find out where to place response of query specified by position at sorted index.
SearchCommandVersion_t getCommandVersion () const
 returns command version

Protected Attributes

SearchCommandVersion_t commandVersion
std::list< SourceQuery_tsourceQueries
 source queries ordered as they come from client
std::vector< const
SourceQuery_t * > 
sortedQueries
std::vector< std::pair< int,
int > > 
responseIndex
 maps <source seqNo -> sortedQuery position in order to order responses
std::vector< int > groupQueries

Friends

class Sphinx::Client_t

Detailed Description

Optimisation-enabled multi query data structure.

This class provides methods and storage for creating multi-queries enabled for efficient processing

Sphinx search daemon sometimes doesn't process multiqueries efficient way. Efficient processing means that matching stage of query is done only once and there are number of sorters or groupers for each specific query. When multiquery is consisted of queries impossible to have the same matching stage, queries are processed one by one separately and processing takes long time to finish.

This version of multiquery analyses input queries and group them to groups efficient for sphinx one-pass multi-query processing. method optimise() do that. If calling optimise is ommited, multiquery is sent in traditional manner as one big multiquery.

Query groups are then sent in Clinent_t::query() to sphinx searchd simultaneously by passing them to QueryMachine_t. After collecting replies from server responses are parsed and ordered as they came to server.

See also:
QueryMachine_t
Client_t

Constructor & Destructor Documentation

Sphinx::MultiQueryOpt_t::MultiQueryOpt_t ( SearchCommandVersion_t  cmdVersion = VER_COMMAND_SEARCH_0_9_9  ) 

Constructor of multiquery.

Parameters:
cv cmdVersion command version of multiquery

Member Function Documentation

void Sphinx::MultiQueryOpt_t::addQuery ( const std::string &  query,
const SearchConfig_t queryAttr 
)

adds a query to multi-query

Adds a query to multi-query and checks command version against multi-query command version

Parameters:
query words in string to search for
queryAttr query attributes
Exceptions:
ClientUsageError_t 
See also:
Client_t::query
SearchConfig_t
size_t Sphinx::MultiQueryOpt_t::getQueryCountAtGroup ( size_t  groupIndex  )  const [protected]

get count of input queries in query group

Parameters:
groupIndex index of queryGroup
Returns:
count of input queries in group
size_t Sphinx::MultiQueryOpt_t::getResponseIndex ( size_t  sortedIndex  )  const [protected]

Find out where to place response of query specified by position at sorted index.

Parameters:
sortedIndex position of query at sorted index
Returns:
index where to place the response

Field Documentation

std::vector<int> Sphinx::MultiQueryOpt_t::groupQueries [protected]

groupQuery specification indexes of first queries within group queries in sortedQueries

std::vector<const SourceQuery_t *> Sphinx::MultiQueryOpt_t::sortedQueries [protected]

queries sorted by hash (queries with same hash are suitable for efficient processing within one sphinx multiquery)


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