1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "rpinterface.h"
#include "querynode.h"
// Juniper internal implementation of the IQueryVisitor interface as used by
// query providers (this is the initial 1.0.x structure implementation)
typedef juniper::QueryItem QueryItem;
typedef juniper::IQuery IQuery;
typedef juniper::QueryHandle QueryHandle;
class Matcher;
namespace juniper {
class QueryModifier;
}
/** See IQueryVisitor for detailed interface description
*/
class QueryVisitor : public juniper::IQueryVisitor
{
public:
QueryVisitor(const IQuery& query, QueryHandle* qhandle, juniper::QueryModifier & queryModifier);
~QueryVisitor();
bool VisitAND(const QueryItem* item, int arity) override;
bool VisitOR(const QueryItem* item, int arity) override;
bool VisitANY(const QueryItem* item, int arity) override;
bool VisitNEAR(const QueryItem* item, int arity, int limit) override;
bool VisitWITHIN(const QueryItem* item, int arity, int limit) override;
bool VisitRANK(const QueryItem* item, int arity) override;
bool VisitPHRASE(const QueryItem* item, int arity) override;
bool VisitANDNOT(const QueryItem* item, int arity) override;
bool VisitTHRESHOLD(const QueryItem* item, int arity, int threshold) override;
bool VisitOther(const QueryItem* item, int arity) override;
void VisitKeyword(const QueryItem* item, const char* keyword,
const size_t length = 0, bool prefix = false, bool specialToken = false) override;
/** Grab pointer to (and ownership of) the query structure generated by this visitor.
* The call releases the query structure from this visitor.
* @return The root node in the generated query tree now to be managed and
* subsequently deleted by caller
*/
QueryExpr* GetQuery();
protected:
std::string get_index(const QueryItem* item);
private:
// Helper functions/members for use during construction only.
void update_parameters(const char* options);
void insert(QueryExpr* expr);
void postprocess_query();
juniper::QueryModifier & _queryModifier;
const IQuery* _fquery; // Temp.pointer to the input query (valid in constructor only..
// Members valid after init..
QueryExpr* _query; // Root of query
QueryExpr* _current; // Current position in query tree
QueryHandle* _qhandle;
int _term_index;
bool _got_stack; // Set when we have created a stack root
QueryVisitor(QueryVisitor &);
QueryVisitor &operator=(QueryVisitor &);
};
|