JASSv2
Classes | Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Protected Attributes | List of all members
JASS::query Class Referenceabstract

Everything necessary to process a query is encapsulated in an object of this type. More...

#include <query.h>

Inheritance diagram for JASS::query:
Inheritance graph
[legend]
Collaboration diagram for JASS::query:
Collaboration graph
[legend]

Classes

class  docid_rsv_pair
 Literally a <document_id, rsv> ordered pair. More...
 
class  printer
 

Public Types

typedef uint8_t ACCUMULATOR_TYPE
 the type of an accumulator (probably a uint16_t)
 
typedef uint32_t DOCID_TYPE
 the type of a document id (from a compressor)
 

Public Member Functions

 query (compress_integer &codex)
 Constructor.
 
virtual void init (const std::vector< std::string > &primary_keys, DOCID_TYPE documents=1024, DOCID_TYPE top_k=10, size_t width=7)
 Initialise the object. MUST be called before first use. More...
 
virtual ~query ()
 Destructor.
 
template<typename STRING_TYPE >
void parse (const STRING_TYPE &query, parser_query::parser_type which_parser=parser_query::parser_type::query)
 Take the given query and parse it. More...
 
query_term_listterms (void)
 Return a reference to the parsed query. More...
 
virtual docid_rsv_pairget_first (void)=0
 Retrun the top result. More...
 
virtual docid_rsv_pairget_next (void)=0
 After calling get_first(), return the next result. More...
 
virtual void rewind (ACCUMULATOR_TYPE smallest_possible_rsv=0, ACCUMULATOR_TYPE top_k_lower_bound=0, ACCUMULATOR_TYPE largest_possible_rsv=0)
 Clear this object after use and ready for re-use. More...
 
forceinline void set_impact (ACCUMULATOR_TYPE score)
 Set the impact score to use in a push_back(). More...
 
virtual void sort (void)=0
 sort this resuls list before iteration over it.
 
forceinline void decode_and_process (ACCUMULATOR_TYPE impact, size_t integers, const void *compressed, size_t compressed_size)
 Given the integer decoder, the number of integes to decode, and the compressed sequence, decompress (but do not process). More...
 
virtual void decode_with_writer (size_t integers, const void *compressed, size_t compressed_size)=0
 Given the integer decoder, the number of integes to decode, and the compressed sequence, decompress (but do not process). More...
 
virtual void decode_with_writer (query::printer &writer, size_t integers, const void *compressed, size_t compressed_size)
 Given the integer decoder, the number of integes to decode, and the compressed sequence, decompress (but do not process). More...
 

Public Attributes

DOCID_TYPE top_k
 The number of results to track.
 

Static Public Attributes

static constexpr size_t MAX_DOCUMENTS = 200'000'000
 the maximum number of documents an index can hold
 
static constexpr size_t MAX_TOP_K = 1'000
 the maximum top-k value
 
static constexpr size_t MAX_RSV = (std::numeric_limits<ACCUMULATOR_TYPE>::max)()
 

Protected Attributes

ACCUMULATOR_TYPE impact
 The impact score to be added on a call to add_rsv()
 
allocator_pool memory
 All memory allocation happens in this "arena".
 
std::vector< DOCID_TYPEdecompress_buffer
 The delta-encoded decopressed integer sequence.
 
DOCID_TYPE documents
 The numnber of documents this index contains.
 
parser_query parser
 Parser responsible for converting text into a parsed query.
 
query_term_listparsed_query
 The parsed query.
 
const std::vector< std::string > * primary_keys
 A vector of strings, each the primary key for the document with an id equal to the vector index.
 
compress_integercodex
 The decompressor to use.
 

Detailed Description

Everything necessary to process a query is encapsulated in an object of this type.

Member Function Documentation

◆ decode_and_process()

forceinline void JASS::query::decode_and_process ( ACCUMULATOR_TYPE  impact,
size_t  integers,
const void *  compressed,
size_t  compressed_size 
)
inline

Given the integer decoder, the number of integes to decode, and the compressed sequence, decompress (but do not process).

Parameters
impact[in] The impact score to add for each document id in the list.
integers[in] The number of integers that are compressed.
compressed[in] The compressed sequence.
compressed_size[in] The length of the compressed sequence.

◆ decode_with_writer() [1/2]

virtual void JASS::query::decode_with_writer ( size_t  integers,
const void *  compressed,
size_t  compressed_size 
)
pure virtual

Given the integer decoder, the number of integes to decode, and the compressed sequence, decompress (but do not process).

Parameters
integers[in] The number of integers that are compressed.
compressed[in] The compressed sequence.
compressed_size[in] The length of the compressed sequence.

Implemented in JASS::query_block_max, JASS::query_heap< ACCUMULATOR_ARRAY >, and JASS::query_simple.

◆ decode_with_writer() [2/2]

virtual void JASS::query::decode_with_writer ( query::printer writer,
size_t  integers,
const void *  compressed,
size_t  compressed_size 
)
inlinevirtual

Given the integer decoder, the number of integes to decode, and the compressed sequence, decompress (but do not process).

Parameters
writer[in] the device to write to
integers[in] The number of integers that are compressed.
compressed[in] The compressed sequence.
compressed_size[in] The length of the compressed sequence.

◆ get_first()

virtual docid_rsv_pair* JASS::query::get_first ( void  )
pure virtual

Retrun the top result.

Returns
The first (i.e. top) result in the results list.

Implemented in JASS::query_heap< ACCUMULATOR_ARRAY >, JASS::query_block_max, and JASS::query_simple.

◆ get_next()

virtual docid_rsv_pair* JASS::query::get_next ( void  )
pure virtual

After calling get_first(), return the next result.

Returns
The next result in the results list, or NULL if at end of list

Implemented in JASS::query_heap< ACCUMULATOR_ARRAY >, JASS::query_block_max, and JASS::query_simple.

◆ init()

virtual void JASS::query::init ( const std::vector< std::string > &  primary_keys,
DOCID_TYPE  documents = 1024,
DOCID_TYPE  top_k = 10,
size_t  width = 7 
)
inlinevirtual

Initialise the object. MUST be called before first use.

Parameters
primary_keys[in] Vector of the document primary keys used to convert from internal document ids to external primary keys.
documents[in] The number of documents in the collection.
top_k[in] The top-k documents to return from the query once executed.
width[in] The width of the 2-d accumulators (if they are being used).

Reimplemented in JASS::query_heap< ACCUMULATOR_ARRAY >, JASS::query_block_max, and JASS::query_simple.

◆ parse()

template<typename STRING_TYPE >
void JASS::query::parse ( const STRING_TYPE &  query,
parser_query::parser_type  which_parser = parser_query::parser_type::query 
)
inline

Take the given query and parse it.

Template Parameters
STRING_TYPEEither a std::string or JASS::string.
Parameters
query[in] The query to parse.

◆ rewind()

virtual void JASS::query::rewind ( ACCUMULATOR_TYPE  smallest_possible_rsv = 0,
ACCUMULATOR_TYPE  top_k_lower_bound = 0,
ACCUMULATOR_TYPE  largest_possible_rsv = 0 
)
inlinevirtual

Clear this object after use and ready for re-use.

Parameters
smallest_possible_rsv[in] No rsv can be smaller than this (other than documents that are not found
top_k_lower_bound[in] No rsv smaller than this can enter the top-k results list
largest_possible_rsv[in] No rsv can be larger than this (but need no one need be this large)

Reimplemented in JASS::query_heap< ACCUMULATOR_ARRAY >, JASS::query_block_max, and JASS::query_simple.

◆ set_impact()

forceinline void JASS::query::set_impact ( ACCUMULATOR_TYPE  score)
inline

Set the impact score to use in a push_back().

Parameters
score[in] The impact score to be added to accumulators.

◆ terms()

query_term_list& JASS::query::terms ( void  )
inline

Return a reference to the parsed query.

Returns
A reference to the parsed query.

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