summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArne Juul <arnej@verizonmedia.com>2020-03-02 12:17:46 +0000
committerArne Juul <arnej@verizonmedia.com>2020-03-02 12:17:46 +0000
commitb2d91e1c52fc05a38e808da0ba71fab5a90adedb (patch)
treed026c15521c726d8633ea813ed0019779a30901b
parentfeeb478f356b0c2d6c3b7e0d80ef15620dd019b1 (diff)
be more specific in StackDumpIterator API
-rw-r--r--searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp31
-rw-r--r--searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.h24
-rw-r--r--searchlib/src/vespa/searchlib/query/streaming/querynode.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/query/tree/stackdumpquerycreator.h24
-rw-r--r--searchsummary/src/vespa/searchsummary/docsummary/dynamicteaserdfw.cpp4
5 files changed, 43 insertions, 42 deletions
diff --git a/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp b/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp
index f0fb53a5640..c42cf8fc370 100644
--- a/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp
+++ b/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp
@@ -21,9 +21,11 @@ SimpleQueryStackDumpIterator::SimpleQueryStackDumpIterator(vespalib::stringref b
_currUniqueId(0),
_currFlags(0),
_currArity(0),
- _currArg1(0),
- _currArg2(0),
- _currArg3(0),
+ _extraIntArg1(0),
+ _extraIntArg2(0),
+ _extraIntArg3(0),
+ _extraDoubleArg4(0),
+ _extraDoubleArg5(0),
_predicate_query_term(),
_curr_index_name(),
_curr_term(),
@@ -138,7 +140,6 @@ SimpleQueryStackDumpIterator::next()
case ParseItem::ITEM_ANY:
try {
_currArity = readCompressedPositiveInt(p);
- _currArg1 = 0;
_curr_index_name = vespalib::stringref();
_curr_term = vespalib::stringref();
} catch (...) {
@@ -150,7 +151,7 @@ SimpleQueryStackDumpIterator::next()
case ParseItem::ITEM_ONEAR:
try {
_currArity = readCompressedPositiveInt(p);
- _currArg1 = readCompressedPositiveInt(p);
+ _extraIntArg1 = readCompressedPositiveInt(p);
_curr_index_name = vespalib::stringref();
_curr_term = vespalib::stringref();
} catch (...) {
@@ -161,7 +162,7 @@ SimpleQueryStackDumpIterator::next()
case ParseItem::ITEM_WEAK_AND:
try {
_currArity = readCompressedPositiveInt(p);
- _currArg1 = readCompressedPositiveInt(p);
+ _extraIntArg1 = readCompressedPositiveInt(p); // targetNumHits
_curr_index_name = read_stringref(p);
_curr_term = vespalib::stringref();
} catch (...) {
@@ -171,7 +172,6 @@ SimpleQueryStackDumpIterator::next()
case ParseItem::ITEM_SAME_ELEMENT:
try {
_currArity = readCompressedPositiveInt(p);
- _currArg1 = 0;
_curr_index_name = read_stringref(p);
_curr_term = vespalib::stringref();
} catch (...) {
@@ -182,7 +182,6 @@ SimpleQueryStackDumpIterator::next()
case ParseItem::ITEM_PURE_WEIGHTED_STRING:
try {
_curr_term = read_stringref(p);
- _currArg1 = 0;
_currArity = 0;
} catch (...) {
return false;
@@ -196,7 +195,6 @@ SimpleQueryStackDumpIterator::next()
p += sizeof(int64_t);
if (p > _bufEnd) return false;
- _currArg1 = 0;
_currArity = 0;
break;
case ParseItem::ITEM_WORD_ALTERNATIVES:
@@ -218,7 +216,6 @@ SimpleQueryStackDumpIterator::next()
try {
_curr_index_name = read_stringref(p);
_curr_term = read_stringref(p);
- _currArg1 = 0;
_currArity = 0;
} catch (...) {
return false;
@@ -258,11 +255,9 @@ SimpleQueryStackDumpIterator::next()
_currArity = readCompressedPositiveInt(p);
_curr_index_name = read_stringref(p);
if (_currType == ParseItem::ITEM_WAND) {
- _currArg1 = readCompressedPositiveInt(p); // targetNumHits
- _currArg2 = read_double(p); // scoreThreshold
- _currArg3 = read_double(p); // thresholdBoostFactor
- } else {
- _currArg1 = 0;
+ _extraIntArg1 = readCompressedPositiveInt(p); // targetNumHits
+ _extraDoubleArg4 = read_double(p); // scoreThreshold
+ _extraDoubleArg5 = read_double(p); // thresholdBoostFactor
}
_curr_term = vespalib::stringref();
} catch (...) {
@@ -274,9 +269,9 @@ SimpleQueryStackDumpIterator::next()
try {
_curr_index_name = read_stringref(p);
_curr_term = read_stringref(p); // query_tensor_name
- _currArg1 = readCompressedPositiveInt(p); // target_num_hits
- _currArg2 = readCompressedPositiveInt(p); // allow_approximate
- _currArg3 = readCompressedPositiveInt(p); // explore_additional_hits
+ _extraIntArg1 = readCompressedPositiveInt(p); // targetNumHits
+ _extraIntArg2 = readCompressedPositiveInt(p); // allow_approximate
+ _extraIntArg3 = readCompressedPositiveInt(p); // explore_additional_hits
_currArity = 0;
} catch (...) {
return false;
diff --git a/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.h b/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.h
index 6eb3fb7777d..73c97bb5fb3 100644
--- a/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.h
+++ b/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.h
@@ -42,12 +42,13 @@ private:
/** The arity of the current item */
uint32_t _currArity;
- /** The first argument of the current item (length of NEAR/ONEAR area for example) */
- uint32_t _currArg1;
- /** The second argument of the current item (score threshold of WAND for example) */
- double _currArg2;
- /** The third argument of the current item (threshold boost factor of WAND for example) */
- double _currArg3;
+
+ /* extra arguments */
+ uint32_t _extraIntArg1;
+ uint32_t _extraIntArg2;
+ uint32_t _extraIntArg3;
+ double _extraDoubleArg4;
+ double _extraDoubleArg5;
/** The predicate query specification */
query::PredicateQueryTerm::UP _predicate_query_term;
/** The index name (field name) in the current item */
@@ -118,11 +119,12 @@ public:
uint32_t getArity() const { return _currArity; }
- uint32_t getArg1() const { return _currArg1; }
-
- double getArg2() const { return _currArg2; }
-
- double getArg3() const { return _currArg3; }
+ uint32_t getNearDistance() const { return _extraIntArg1; }
+ uint32_t getTargetNumHits() const { return _extraIntArg1; }
+ double getScoreThreshold() const { return _extraDoubleArg4; }
+ double getThresholdBoostFactor() const { return _extraDoubleArg5; }
+ bool getAllowApproximate() const { return (_extraIntArg2 != 0); }
+ uint32_t getExploreAdditionalHits() const { return _extraIntArg3; }
query::PredicateQueryTerm::UP getPredicateQueryTerm()
{ return std::move(_predicate_query_term); }
diff --git a/searchlib/src/vespa/searchlib/query/streaming/querynode.cpp b/searchlib/src/vespa/searchlib/query/streaming/querynode.cpp
index 24c458c7e32..3db6c8e68c8 100644
--- a/searchlib/src/vespa/searchlib/query/streaming/querynode.cpp
+++ b/searchlib/src/vespa/searchlib/query/streaming/querynode.cpp
@@ -41,7 +41,7 @@ QueryNode::Build(const QueryNode * parent, const QueryNodeResultFactory & factor
QueryConnector * qc = dynamic_cast<QueryConnector *> (qn.get());
NearQueryNode * nqn = dynamic_cast<NearQueryNode *> (qc);
if (nqn) {
- nqn->distance(queryRep.getArg1());
+ nqn->distance(queryRep.getNearDistance());
}
if ((type == ParseItem::ITEM_WEAK_AND) ||
(type == ParseItem::ITEM_WEIGHTED_SET) ||
diff --git a/searchlib/src/vespa/searchlib/query/tree/stackdumpquerycreator.h b/searchlib/src/vespa/searchlib/query/tree/stackdumpquerycreator.h
index a57c24584cc..a61fbee067d 100644
--- a/searchlib/src/vespa/searchlib/query/tree/stackdumpquerycreator.h
+++ b/searchlib/src/vespa/searchlib/query/tree/stackdumpquerycreator.h
@@ -48,9 +48,6 @@ public:
private:
static Term * createQueryTerm(search::SimpleQueryStackDumpIterator &queryStack, QueryBuilder<NodeTypes> & builder, vespalib::stringref & pureTermView) {
uint32_t arity = queryStack.getArity();
- uint32_t arg1 = queryStack.getArg1();
- double arg2 = queryStack.getArg2();
- double arg3 = queryStack.getArg3();
ParseItem::ItemType type = queryStack.getType();
Node::UP node;
Term *t = 0;
@@ -68,16 +65,19 @@ private:
pureTermView = view;
} else if (type == ParseItem::ITEM_WEAK_AND) {
vespalib::stringref view = queryStack.getIndexName();
- builder.addWeakAnd(arity, arg1, view);
+ uint32_t targetNumHits = queryStack.getTargetNumHits();
+ builder.addWeakAnd(arity, targetNumHits, view);
pureTermView = view;
} else if (type == ParseItem::ITEM_EQUIV) {
int32_t id = queryStack.getUniqueId();
Weight weight = queryStack.GetWeight();
builder.addEquiv(arity, id, weight);
} else if (type == ParseItem::ITEM_NEAR) {
- builder.addNear(arity, arg1);
+ uint32_t nearDistance = queryStack.getNearDistance();
+ builder.addNear(arity, nearDistance);
} else if (type == ParseItem::ITEM_ONEAR) {
- builder.addONear(arity, arg1);
+ uint32_t nearDistance = queryStack.getNearDistance();
+ builder.addONear(arity, nearDistance);
} else if (type == ParseItem::ITEM_PHRASE) {
vespalib::stringref view = queryStack.getIndexName();
int32_t id = queryStack.getUniqueId();
@@ -104,18 +104,22 @@ private:
vespalib::stringref view = queryStack.getIndexName();
int32_t id = queryStack.getUniqueId();
Weight weight = queryStack.GetWeight();
- t = &builder.addWandTerm(arity, view, id, weight, arg1, arg2, arg3);
+ uint32_t targetNumHits = queryStack.getTargetNumHits();
+ double scoreThreshold = queryStack.getScoreThreshold();
+ double thresholdBoostFactor = queryStack.getThresholdBoostFactor();
+ t = &builder.addWandTerm(arity, view, id, weight,
+ targetNumHits, scoreThreshold, thresholdBoostFactor);
pureTermView = vespalib::stringref();
} else if (type == ParseItem::ITEM_NOT) {
builder.addAndNot(arity);
} else if (type == ParseItem::ITEM_NEAREST_NEIGHBOR) {
vespalib::stringref query_tensor_name = queryStack.getTerm();
vespalib::stringref field_name = queryStack.getIndexName();
- uint32_t target_num_hits = queryStack.getArg1();
+ uint32_t target_num_hits = queryStack.getTargetNumHits();
int32_t id = queryStack.getUniqueId();
Weight weight = queryStack.GetWeight();
- uint32_t allow_approximate = (queryStack.getArg2() != 0);
- uint32_t explore_additional_hits = queryStack.getArg3();
+ uint32_t allow_approximate = queryStack.getAllowApproximate();
+ uint32_t explore_additional_hits = queryStack.getExploreAdditionalHits();
builder.add_nearest_neighbor_term(query_tensor_name, field_name, id, weight,
target_num_hits, allow_approximate, explore_additional_hits);
} else {
diff --git a/searchsummary/src/vespa/searchsummary/docsummary/dynamicteaserdfw.cpp b/searchsummary/src/vespa/searchsummary/docsummary/dynamicteaserdfw.cpp
index 43eaf4b57b8..4872a183358 100644
--- a/searchsummary/src/vespa/searchsummary/docsummary/dynamicteaserdfw.cpp
+++ b/searchsummary/src/vespa/searchsummary/docsummary/dynamicteaserdfw.cpp
@@ -257,11 +257,11 @@ JuniperQueryAdapter::Traverse(juniper::IQueryVisitor *v) const
rc = SkipItem(&iterator);
break;
case search::ParseItem::ITEM_NEAR:
- if (!v->VisitNEAR(&item, iterator.getArity(),iterator.getArg1()))
+ if (!v->VisitNEAR(&item, iterator.getArity(),iterator.getNearDistance()))
rc = SkipItem(&iterator);
break;
case search::ParseItem::ITEM_ONEAR:
- if (!v->VisitWITHIN(&item, iterator.getArity(),iterator.getArg1()))
+ if (!v->VisitWITHIN(&item, iterator.getArity(),iterator.getNearDistance()))
rc = SkipItem(&iterator);
break;
// Unhandled items are just ignored by juniper