diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2024-02-05 15:00:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-05 15:00:31 +0100 |
commit | a30640c1aed5cbe03b0e992936d39ca0263e93d4 (patch) | |
tree | 7a150762b72b15667e5d5c824f97ea1095df4978 | |
parent | 964deac9f61da6e3cbbbdadb6a3cee14448ec4b6 (diff) | |
parent | 54e84a1eb1bc7bcee58890515ddeb8e7a18c07e7 (diff) |
Merge pull request #30180 from vespa-engine/balder/use-stringref
- Avoid default arguments on virtual methods.
9 files changed, 124 insertions, 160 deletions
diff --git a/searchsummary/src/tests/juniper/queryvisitor_test.cpp b/searchsummary/src/tests/juniper/queryvisitor_test.cpp index 3e656ccb0f6..a5862c0aec3 100644 --- a/searchsummary/src/tests/juniper/queryvisitor_test.cpp +++ b/searchsummary/src/tests/juniper/queryvisitor_test.cpp @@ -27,14 +27,14 @@ private: vespalib::string _term; public: - MyQuery(const vespalib::string &term) : _term(term) {} + explicit MyQuery(const vespalib::string &term) : _term(term) {} - virtual bool Traverse(IQueryVisitor* v) const override { + bool Traverse(IQueryVisitor* v) const override { MyQueryItem item; - v->VisitKeyword(&item, _term.c_str(), _term.size()); + v->visitKeyword(&item, _term, false, false); return true; } - virtual bool UsefulIndex(const QueryItem*) const override { + bool UsefulIndex(const QueryItem*) const override { return true; } }; @@ -45,7 +45,7 @@ struct Fixture QueryModifier modifier; QueryHandle handle; QueryVisitor visitor; - Fixture(const vespalib::string &term) + explicit Fixture(const vespalib::string &term) : query(term), modifier(), handle(query, "", modifier), diff --git a/searchsummary/src/vespa/juniper/query.h b/searchsummary/src/vespa/juniper/query.h index 87d3231cd2d..14ea641e2c9 100644 --- a/searchsummary/src/vespa/juniper/query.h +++ b/searchsummary/src/vespa/juniper/query.h @@ -3,6 +3,7 @@ #pragma once #include <vespa/searchlib/parsequery/item_creator.h> +#include <vespa/vespalib/stllike/string.h> #include <cstddef> #include <cstdint> @@ -43,7 +44,7 @@ class QueryItem; class IQuery { public: - virtual ~IQuery() { } + virtual ~IQuery() = default; /** Traverse the query. * This will lead to a prefix depth first traversal of the complete query @@ -153,11 +154,9 @@ public: * otherwise caller should proceed as normal * @param specialToken true if this term is treated as a special token */ - virtual void VisitKeyword(const QueryItem* item, - const char* keyword, const size_t length = 0, - bool prefix = false, bool specialToken = false) = 0; + virtual void visitKeyword(const QueryItem* item, vespalib::stringref keyword, bool prefix, bool specialToken) = 0; - virtual ~IQueryVisitor() { } + virtual ~IQueryVisitor() = default; }; } diff --git a/searchsummary/src/vespa/juniper/querynode.cpp b/searchsummary/src/vespa/juniper/querynode.cpp index 5d6469f10f2..a52f8d07c80 100644 --- a/searchsummary/src/vespa/juniper/querynode.cpp +++ b/searchsummary/src/vespa/juniper/querynode.cpp @@ -1,7 +1,6 @@ // Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "querynode.h" -#include "queryvisitor.h" #include "juniperdebug.h" #include <vespa/vespalib/util/stringfmt.h> #include <cassert> @@ -14,26 +13,26 @@ LOG_SETUP(".juniper.querynode"); */ QueryExpr::QueryExpr(int weight, int arity) : - _options(0), _weight(weight), _arity(arity), _parent(NULL), _childno(0) + _options(0), _weight(weight), _arity(arity), _parent(nullptr), _childno(0) { } QueryExpr::QueryExpr(QueryExpr* e) : _options(e->_options), _weight(e->_weight), _arity(e->_arity), - _parent(NULL), + _parent(nullptr), _childno(0) { } -QueryExpr::~QueryExpr() { } +QueryExpr::~QueryExpr() = default; QueryTerm::QueryTerm(const char* t, int length, int ix, int wgt) : QueryExpr(wgt, 0), len(length), ucs4_len(0), total_match_cnt(0), exact_match_cnt(0), - idx(ix), rewriter(NULL), reduce_matcher(NULL), _rep(NULL), - _ucs4_term(NULL) + idx(ix), rewriter(nullptr), reduce_matcher(nullptr), _rep(nullptr), + _ucs4_term(nullptr) { if (len <= 0) len = strlen(t); @@ -49,8 +48,8 @@ QueryTerm::QueryTerm(QueryTerm* t) : QueryExpr(t), len(t->len), ucs4_len(0), total_match_cnt(0), exact_match_cnt(0), - idx(-1), rewriter(NULL), reduce_matcher(NULL), _rep(NULL), - _ucs4_term(NULL) + idx(-1), rewriter(nullptr), reduce_matcher(nullptr), _rep(nullptr), + _ucs4_term(nullptr) { _rep = new char[len+1]; strncpy(_rep, t->term(), len); _rep[len] = '\0'; @@ -70,7 +69,7 @@ QueryTerm::~QueryTerm() QueryNode::QueryNode(int arity, int threshold, int weight) : QueryExpr(weight, arity), _threshold(threshold), _limit(0), - _children(NULL), + _children(nullptr), _nchild(0), _node_idx(-1) { assert(arity > 0); @@ -82,7 +81,7 @@ QueryNode::QueryNode(QueryNode* n) : QueryExpr(n), _threshold(n->_threshold), _limit(n->_limit), - _children(NULL), + _children(nullptr), _nchild(0), _node_idx(n->_node_idx) { @@ -104,7 +103,8 @@ int QueryNode::Limit() { return _options & X_LIMIT ? _limit : -1; } int QueryTerm::Limit() { return 0; } -QueryNode* QueryTerm::AddChild(QueryExpr*) +QueryNode* +QueryTerm::AddChild(QueryExpr*) { LOG(warning, "stack inconsistency, attempt to add children to a terminal node"); @@ -114,7 +114,8 @@ QueryNode* QueryTerm::AddChild(QueryExpr*) } -QueryNode* QueryNode::AddChild(QueryExpr* child) +QueryNode* +QueryNode::AddChild(QueryExpr* child) { if (!child) _arity--; @@ -137,7 +138,8 @@ void QueryExpr::ComputeThreshold() {} // Compute threshold and constraint info -void QueryNode::ComputeThreshold() +void +QueryNode::ComputeThreshold() { bool no_threshold = false; int th = 0; @@ -163,14 +165,16 @@ void QueryNode::ComputeThreshold() } -void QueryTerm::Dump(std::string& out) +void +QueryTerm::Dump(std::string& out) { out.append(term()); out.append(vespalib::make_string("%s:%d", (_options & X_PREFIX ? "*" : ""), _weight)); } -void QueryNode::Dump(std::string& out) +void +QueryNode::Dump(std::string& out) { out.append(vespalib::make_string("Node<a:%d", _arity)); if (_options & X_ORDERED) out.append(",o"); @@ -191,45 +195,15 @@ void QueryNode::Dump(std::string& out) } -bool QueryNode::StackComplete() +bool +QueryNode::StackComplete() { // Stack is complete if rightmost nodes in tree are complete return (Complete() && (!_arity || _children[_arity - 1]->StackComplete())); } - -bool QueryTerm::StackComplete() -{ - return true; -} - - -QueryNode* QueryNode::AsNode() -{ - return this; -} - -QueryNode* QueryTerm::AsNode() -{ - return NULL; -} - -QueryTerm* QueryNode::AsTerm() -{ - return NULL; -} - -QueryTerm* QueryTerm::AsTerm() -{ - return this; -} - -bool QueryTerm::Complex() -{ - return false; -} - -bool QueryNode::Complex() +bool +QueryNode::Complex() { for (int i = 0; i < _nchild; i++) { if (_children[i]->_arity > 1) return true; @@ -238,7 +212,8 @@ bool QueryNode::Complex() } -int QueryNode::MaxArity() +int +QueryNode::MaxArity() { int max_arity = _arity; for (int i = 0; i < _nchild; i++) { @@ -249,7 +224,8 @@ int QueryNode::MaxArity() } -bool QueryNode::AcceptsInitially(QueryExpr* n) +bool +QueryNode::AcceptsInitially(QueryExpr* n) { assert(n->_parent == this); // return (!(_options & X_ORDERED)) || n->_childno == 0; @@ -262,7 +238,8 @@ bool QueryNode::AcceptsInitially(QueryExpr* n) /** Modify the given stack by eliminating unnecessary internal nodes * with arity 1 or non-terms with arity 0 */ -void SimplifyStack(QueryExpr*& orig_stack) +void +SimplifyStack(QueryExpr*& orig_stack) { if (!orig_stack) return; QueryNode* node = orig_stack->AsNode(); @@ -274,7 +251,7 @@ void SimplifyStack(QueryExpr*& orig_stack) LOG(warning, "juniper: query stack incomplete, got arity %d, expected %d", node->_nchild, node->_arity); delete node; - orig_stack = NULL; + orig_stack = nullptr; return; } @@ -282,12 +259,12 @@ void SimplifyStack(QueryExpr*& orig_stack) if (i > 0 && (node->_options & X_ONLY_1)) { // Get rid of children # >2 for RANK/ANDNOT delete node->_children[i]; - node->_children[i] = NULL; + node->_children[i] = nullptr; } else SimplifyStack(node->_children[i]); - if (node->_children[i] == NULL) + if (node->_children[i] == nullptr) compact++; } if (compact > 0) { @@ -307,10 +284,10 @@ void SimplifyStack(QueryExpr*& orig_stack) } if (node->_arity <= 1) { - QueryExpr* ret = NULL; + QueryExpr* ret = nullptr; if (node->_arity == 1) { ret = node->_children[0]; - node->_children[0] = NULL; + node->_children[0] = nullptr; ret->_parent = node->_parent; ret->_childno = node->_childno; } @@ -321,19 +298,20 @@ void SimplifyStack(QueryExpr*& orig_stack) // default implementation of 2nd visit to QueryNode objs: -void IQueryExprVisitor::RevisitQueryNode(QueryNode*) -{ } +void IQueryExprVisitor::RevisitQueryNode(QueryNode*) { } // visitor pattern: -void QueryTerm::Accept(IQueryExprVisitor& v) +void +QueryTerm::Accept(IQueryExprVisitor& v) { v.VisitQueryTerm(this); } -void QueryNode::Accept(IQueryExprVisitor& v) +void +QueryNode::Accept(IQueryExprVisitor& v) { int i; v.VisitQueryNode(this); diff --git a/searchsummary/src/vespa/juniper/querynode.h b/searchsummary/src/vespa/juniper/querynode.h index 5ff7310e752..cf8f7eb119f 100644 --- a/searchsummary/src/vespa/juniper/querynode.h +++ b/searchsummary/src/vespa/juniper/querynode.h @@ -102,20 +102,22 @@ class QueryNode : public QueryExpr { public: // Create a new node with arity children + QueryNode(QueryNode &) = delete; + QueryNode &operator=(QueryNode &) = delete; QueryNode(int arity, int threshold, int weight = 0); // Create a copy of the node n wrt. arity etc, but without adding any children.. explicit QueryNode(QueryNode* n); - ~QueryNode(); + ~QueryNode() override; QueryNode* AddChild(QueryExpr* child) override; int Limit() override; bool Complete() const { return _arity == _nchild; } void Dump(std::string&) override; bool StackComplete() override; void ComputeThreshold() override; - QueryNode* AsNode() override; - QueryTerm* AsTerm() override; + QueryNode* AsNode() override { return this; } + QueryTerm* AsTerm() override { return nullptr; } bool Complex() override; int MaxArity() override; @@ -133,10 +135,6 @@ public: QueryExpr** _children; int _nchild; // end pointer (fill level) of _children int _node_idx; // Index (position) of this nonterminal within table of all nonterminals - -private: - QueryNode(QueryNode &); - QueryNode &operator=(QueryNode &); }; @@ -151,10 +149,10 @@ public: int Limit() override; QueryNode* AddChild(QueryExpr* child) override; void Dump(std::string&) override; - bool StackComplete() override; - QueryNode* AsNode() override; - QueryTerm* AsTerm() override; - bool Complex() override; + bool StackComplete() override { return true; } + QueryNode* AsNode() override { return nullptr; } + QueryTerm* AsTerm() override { return this; } + bool Complex() override { return false; } void Accept(IQueryExprVisitor& v) override; inline const char* term() { return _rep; } diff --git a/searchsummary/src/vespa/juniper/queryparser.cpp b/searchsummary/src/vespa/juniper/queryparser.cpp index 90f92a05f75..6e0f17b4dd7 100644 --- a/searchsummary/src/vespa/juniper/queryparser.cpp +++ b/searchsummary/src/vespa/juniper/queryparser.cpp @@ -75,7 +75,7 @@ QueryParser::QueryParser(const char* query_string) : _op_to_type(), _query_string(query_string), _curtok(), - _v(NULL), + _v(nullptr), _exp(), _parse_errno(0), _reached_end(false) { _op_to_type["AND"] = TOK_NORM_OP; @@ -97,7 +97,7 @@ QueryParser::QueryParser(const char* query_string) : } else { - _exp = NULL; + _exp = nullptr; _parse_errno = 1; return; } @@ -152,8 +152,9 @@ void QueryParser::trav(QueryItem* e_abstract) const { auto e = dynamic_cast<QueryParserQueryItem*>(e_abstract); assert(e != nullptr); - if (e->arity() == 0) - _v->VisitKeyword(e, e->_name.c_str(), e->_name.size(), e->_prefix); + if (e->arity() == 0) { + _v->visitKeyword(e, e->_name, e->_prefix, false); + } if (e->_name.compare("AND") == 0) _v->VisitAND(e, e->arity()); else if (e->_name.compare("OR") == 0) _v->VisitOR(e, e->arity()); else if (e->_name.compare("ANY") == 0) _v->VisitANY(e, e->arity()); @@ -173,7 +174,7 @@ std::unique_ptr<QueryItem> QueryParser::ParseExpr() { int p1 = -1; - std::map<std::string, int>::iterator it = _op_to_type.find(_curtok); + auto it = _op_to_type.find(_curtok); if (it == _op_to_type.end()) return ParseIndexTerm(); std::string op = _curtok; @@ -183,7 +184,7 @@ QueryParser::ParseExpr() break; case TOK_PARAM1_OP: next(); - if (!match("/", true)) return NULL; + if (!match("/", true)) return nullptr; next(); p1 = atoi(_curtok.c_str()); LOG(debug, "constraint operator %s - value %d", op.c_str(), p1); @@ -192,11 +193,11 @@ QueryParser::ParseExpr() LOG_ABORT("should not reach here"); } next(); - if (!match("(", true)) return NULL; + if (!match("(", true)) return nullptr; auto e = std::make_unique<QueryParserQueryItem>(op.c_str(), p1); do { - if (ParseError()) return NULL; + if (ParseError()) return nullptr; next(); auto ep = ParseExpr(); if (!ep) diff --git a/searchsummary/src/vespa/juniper/queryvisitor.cpp b/searchsummary/src/vespa/juniper/queryvisitor.cpp index ef88fd79f6f..bd18b548ab7 100644 --- a/searchsummary/src/vespa/juniper/queryvisitor.cpp +++ b/searchsummary/src/vespa/juniper/queryvisitor.cpp @@ -45,7 +45,7 @@ void QueryVisitor::insert(QueryExpr* expr) QueryVisitor::QueryVisitor(const IQuery& fquery, QueryHandle* qhandle, juniper::QueryModifier & queryModifier) : _queryModifier(queryModifier), - _fquery(&fquery), _query(NULL), _current(NULL), _qhandle(qhandle), + _fquery(&fquery), _query(nullptr), _current(nullptr), _qhandle(qhandle), _term_index(0), _got_stack(false) { /* Create a query node structure by traversing the input */ @@ -61,15 +61,15 @@ QueryVisitor::QueryVisitor(const IQuery& fquery, QueryHandle* qhandle, juniper:: else if (_query) { delete _query; - _query = NULL; + _query = nullptr; } - _fquery = NULL; // To avoid misuse after invalidation.. + _fquery = nullptr; // To avoid misuse after invalidation.. } QueryVisitor::~QueryVisitor() { - if (_query) delete _query; + delete _query; } @@ -87,15 +87,13 @@ void QueryVisitor::postprocess_query() SimplifyStack(_query); if (!_query) return; // convert special case of one query term to a node with 1 child: - if (_query->_arity == 0) - { - QueryNode* newroot = new QueryNode(1, _query->_weight, _query->_weight); + if (_query->_arity == 0) { + auto * newroot = new QueryNode(1, _query->_weight, _query->_weight); newroot->AddChild(_query); _query = newroot; } // Handle limit in root node only for now.. - if (!_current && _qhandle->_options & X_LIMIT) - { + if (!_current && _qhandle->_options & X_LIMIT) { QueryNode* qn = _query->AsNode(); if (qn) qn->_limit = _qhandle->_limit; } @@ -104,55 +102,61 @@ void QueryVisitor::postprocess_query() -QueryExpr* QueryVisitor::GetQuery() +QueryExpr* +QueryVisitor::GetQuery() { QueryExpr* q = _query; - _query = NULL; + _query = nullptr; return q; } -bool QueryVisitor::VisitAND(const QueryItem*, int arity) +bool +QueryVisitor::VisitAND(const QueryItem*, int arity) { LOG(debug, "juniper: VisitAND[%d]", arity); - QueryNode* node = new QueryNode(arity, -1); + auto * node = new QueryNode(arity, -1); node->_options = _qhandle->_options | X_AND; insert(node); return true; } -bool QueryVisitor::VisitOR(const QueryItem*, int arity) +bool +QueryVisitor::VisitOR(const QueryItem*, int arity) { LOG(debug, "juniper: VisitOR[%d]", arity); - QueryNode* node = new QueryNode(arity, -1); + auto * node = new QueryNode(arity, -1); node->_options = _qhandle->_options | X_OR; insert(node); return true; } -bool QueryVisitor::VisitANY(const QueryItem*, int arity) +bool +QueryVisitor::VisitANY(const QueryItem*, int arity) { LOG(debug, "juniper: VisitANY[%d]", arity); - QueryNode* node = new QueryNode(arity, -1); + auto * node = new QueryNode(arity, -1); node->_options = _qhandle->_options | X_ANY; insert(node); return true; } -bool QueryVisitor::VisitNEAR(const QueryItem*, int arity, int limit) +bool +QueryVisitor::VisitNEAR(const QueryItem*, int arity, int limit) { LOG(debug, "juniper: VisitNEAR(%d)[%d]", limit, arity); - QueryNode* node = new QueryNode(arity, -1); + auto * node = new QueryNode(arity, -1); node->_options = _qhandle->_options | X_AND | X_LIMIT | X_COMPLETE | X_CONSTR | X_CHKVAL; node->_limit = limit; insert(node); return true; } -bool QueryVisitor::VisitWITHIN(const QueryItem*, int arity, int limit) +bool +QueryVisitor::VisitWITHIN(const QueryItem*, int arity, int limit) { LOG(debug, "juniper: VisitWITHIN(%d)[%d]", limit, arity); - QueryNode* node = new QueryNode(arity, -1); + auto * node = new QueryNode(arity, -1); node->_options = _qhandle->_options | X_AND | X_LIMIT | X_ORDERED | X_COMPLETE | X_CONSTR | X_CHKVAL; node->_limit = limit; @@ -160,10 +164,11 @@ bool QueryVisitor::VisitWITHIN(const QueryItem*, int arity, int limit) return true; } -bool QueryVisitor::VisitRANK(const QueryItem*, int arity) +bool +QueryVisitor::VisitRANK(const QueryItem*, int arity) { LOG(debug, "juniper: VisitRANK[%d]", arity); - QueryNode* node = new QueryNode(arity, -1); + auto * node = new QueryNode(arity, -1); node->_options = X_ONLY_1; // Only keep first child (simpl.executed by simplifier) insert(node); return true; @@ -173,7 +178,7 @@ bool QueryVisitor::VisitPHRASE(const QueryItem*, int arity) { LOG(debug, "juniper: VisitPHRASE[%d]", arity); // PHRASE is identical to WITHIN(0) + exact matches only - QueryNode* node = new QueryNode(arity, -1); + auto * node = new QueryNode(arity, -1); node->_options = _qhandle->_options | X_AND | X_LIMIT | X_ORDERED | X_COMPLETE | X_EXACT | X_CHKVAL; node->_limit = 0; @@ -184,7 +189,7 @@ bool QueryVisitor::VisitPHRASE(const QueryItem*, int arity) bool QueryVisitor::VisitANDNOT(const QueryItem*, int arity) { LOG(debug, "juniper: VisitANDNOT[%d]", arity); - QueryNode* node = new QueryNode(arity, -1); + auto * node = new QueryNode(arity, -1); node->_options = X_ONLY_1; // Only keep first child (simpl.executed by simplifier) insert(node); return true; @@ -205,17 +210,16 @@ std::string QueryVisitor::get_index(const QueryItem* item) } -void QueryVisitor::VisitKeyword(const QueryItem* item, const char* keyword, - const size_t length, bool prefix, bool specialToken) +void +QueryVisitor::visitKeyword(const QueryItem* item, vespalib::stringref keyword, bool prefix, bool specialToken) { - if (length == 0) { + if (keyword.empty()) { // Do not consider empty terms. insert(nullptr); // keep arity of parent in sync! return; } juniper::ItemCreator creator = item->get_creator(); - switch (creator) - { + switch (creator) { case juniper::ItemCreator::CREA_ORIG: LOG(debug, "(juniper::VisitKeyword) Found valid creator '%s'", juniper::creator_text(creator)); break; @@ -223,7 +227,7 @@ void QueryVisitor::VisitKeyword(const QueryItem* item, const char* keyword, /** Keep track of eliminated children to have correct arity in rep. */ insert(nullptr); if (LOG_WOULD_LOG(debug)) { - std::string s(keyword, length); + std::string s = keyword; std::string ind = get_index(item); LOG(debug, "juniper: VisitKeyword(%s:%s) - skip - unwanted creator %s", ind.c_str(), s.c_str(), juniper::creator_text(creator)); @@ -231,10 +235,9 @@ void QueryVisitor::VisitKeyword(const QueryItem* item, const char* keyword, return; } - if (!_fquery->UsefulIndex(item)) - { + if (!_fquery->UsefulIndex(item)) { if (LOG_WOULD_LOG(debug)) { - std::string s(keyword, length); + std::string s = keyword; std::string ind = get_index(item); LOG(debug, "juniper: VisitKeyword(%s:%s) - not applicable index", ind.c_str(), s.c_str()); } @@ -242,44 +245,33 @@ void QueryVisitor::VisitKeyword(const QueryItem* item, const char* keyword, return; } if (LOG_WOULD_LOG(debug)) { - std::string s(keyword, length); + std::string s = keyword; std::string ind = get_index(item); LOG(debug, "juniper: VisitKeyword(%s%s%s)", - ind.c_str(), (ind.size() > 0 ? ":" : ""), s.c_str()); + ind.c_str(), (!ind.empty() ? ":" : ""), s.c_str()); } - QueryTerm* term = new QueryTerm(keyword, length, _term_index++, item->get_weight()); - if (prefix) - { - size_t tmplen = length; - while (tmplen > 0 && *keyword != '*' && *keyword != '?') - { - ++keyword; - --tmplen; - } - term->_options |= (tmplen == 0 ? X_PREFIX : X_WILD); + auto * term = new QueryTerm(keyword.data(), keyword.size(), _term_index++, item->get_weight()); + if (prefix) { + bool is_wild = std::any_of(keyword.begin(), keyword.end(), [](char c) {return (c == '*') || (c == '?'); }); + term->_options |= (is_wild ? X_WILD : X_PREFIX); } if (specialToken) { term->_options |= X_SPECIALTOKEN; } - if (_queryModifier.HasRewriters()) - { + if (_queryModifier.HasRewriters()) { auto ind = item->get_index(); - if (!ind.empty()) - { + if (!ind.empty()) { // record any rewriter for easier lookup later on.. juniper::Rewriter* rh = _queryModifier.FindRewriter(ind); - if (rh) - { + if (rh) { term->rewriter = rh; - if (rh->ForQuery()) - { + if (rh->ForQuery()) { // Notify query handler that an expansion query cache must be // maintained for this query: _qhandle->SetExpansions(); } - if (rh->ForDocument()) - { + if (rh->ForDocument()) { // Notify query handler that on-the-fly document rewriting might be needed _qhandle->SetReductions(); } diff --git a/searchsummary/src/vespa/juniper/queryvisitor.h b/searchsummary/src/vespa/juniper/queryvisitor.h index def4b26480a..082b28bbf30 100644 --- a/searchsummary/src/vespa/juniper/queryvisitor.h +++ b/searchsummary/src/vespa/juniper/queryvisitor.h @@ -25,7 +25,7 @@ public: QueryVisitor(QueryVisitor &) = delete; QueryVisitor &operator=(QueryVisitor &) = delete; QueryVisitor(const IQuery& query, QueryHandle* qhandle, juniper::QueryModifier & queryModifier); - ~QueryVisitor(); + ~QueryVisitor() override; bool VisitAND(const QueryItem* item, int arity) override; bool VisitOR(const QueryItem* item, int arity) override; @@ -36,8 +36,8 @@ public: bool VisitPHRASE(const QueryItem* item, int arity) override; bool VisitANDNOT(const QueryItem* item, int arity) 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; + void visitKeyword(const QueryItem* item, vespalib::stringref keyword, + bool prefix, bool specialToken) override; /** Grab pointer to (and ownership of) the query structure generated by this visitor. * The call releases the query structure from this visitor. diff --git a/searchsummary/src/vespa/searchsummary/docsummary/juniper_dfw_term_visitor.cpp b/searchsummary/src/vespa/searchsummary/docsummary/juniper_dfw_term_visitor.cpp index 9fcee220bc9..9b845e7c4b1 100644 --- a/searchsummary/src/vespa/searchsummary/docsummary/juniper_dfw_term_visitor.cpp +++ b/searchsummary/src/vespa/searchsummary/docsummary/juniper_dfw_term_visitor.cpp @@ -25,11 +25,11 @@ JuniperDFWTermVisitor::visitProperty(const search::fef::Property::Value &key, co _visitor->VisitPHRASE(&item, phraseLen); s = & values.getAt(index++); while ((*s)[0] != '"') { - _visitor->VisitKeyword(&item, s->c_str(), s->length()); + _visitor->visitKeyword(&item, *s, false, false); s = & values.getAt(index++); } } else { - _visitor->VisitKeyword(&item, s->c_str(), s->length()); + _visitor->visitKeyword(&item, *s, false, false); } } } diff --git a/searchsummary/src/vespa/searchsummary/docsummary/juniper_query_adapter.cpp b/searchsummary/src/vespa/searchsummary/docsummary/juniper_query_adapter.cpp index 4e29a9a2f0b..11bf664b767 100644 --- a/searchsummary/src/vespa/searchsummary/docsummary/juniper_query_adapter.cpp +++ b/searchsummary/src/vespa/searchsummary/docsummary/juniper_query_adapter.cpp @@ -72,7 +72,7 @@ JuniperQueryAdapter::Traverse(juniper::IQueryVisitor *v) const case search::ParseItem::ITEM_PURE_WEIGHTED_STRING: { vespalib::stringref term = iterator.getTerm(); - v->VisitKeyword(&item, term.data(), term.size(), false, isSpecialToken); + v->visitKeyword(&item, term, false, isSpecialToken); } break; case search::ParseItem::ITEM_NUMTERM: @@ -82,17 +82,13 @@ JuniperQueryAdapter::Traverse(juniper::IQueryVisitor *v) const if (splitter.parts() > 1) { if (v->VisitPHRASE(&item, splitter.parts())) { for (size_t i = 0; i < splitter.parts(); ++i) { - v->VisitKeyword(&item, - splitter.getPart(i).c_str(), - splitter.getPart(i).size(), false); + v->visitKeyword(&item, splitter.getPart(i), false, false); } } } else if (splitter.parts() == 1) { - v->VisitKeyword(&item, - splitter.getPart(0).c_str(), - splitter.getPart(0).size(), false); + v->visitKeyword(&item, splitter.getPart(0), false, false); } else { - v->VisitKeyword(&item, term.c_str(), term.size(), false, true); + v->visitKeyword(&item, term, false, true); } } break; @@ -104,7 +100,7 @@ JuniperQueryAdapter::Traverse(juniper::IQueryVisitor *v) const case search::ParseItem::ITEM_SUBSTRINGTERM: { vespalib::stringref term = iterator.getTerm(); - v->VisitKeyword(&item, term.data(), term.size(), true, isSpecialToken); + v->visitKeyword(&item, term, true, isSpecialToken); } break; case search::ParseItem::ITEM_ANY: |