diff options
author | Arne Juul <arnej@verizonmedia.com> | 2021-01-08 14:42:36 +0000 |
---|---|---|
committer | Arne Juul <arnej@verizonmedia.com> | 2021-01-08 14:42:36 +0000 |
commit | feef42f47a71d1bc9028d2151d6725e4917db1bd (patch) | |
tree | cc1db0f28a4f5c58a565bacd90a55a3ece8a96af | |
parent | 290cc71ab1aa3b6c8eedd93d82351000873bb300 (diff) |
only send distanceThreshold conditionally
* abuse a bit in the "allow approximation" integer
* we want to cleanup this in several steps later.
3 files changed, 19 insertions, 4 deletions
diff --git a/container-search/src/main/java/com/yahoo/prelude/query/NearestNeighborItem.java b/container-search/src/main/java/com/yahoo/prelude/query/NearestNeighborItem.java index 4a827813e81..bb95cbad178 100644 --- a/container-search/src/main/java/com/yahoo/prelude/query/NearestNeighborItem.java +++ b/container-search/src/main/java/com/yahoo/prelude/query/NearestNeighborItem.java @@ -79,10 +79,18 @@ public class NearestNeighborItem extends SimpleTaggableItem { super.encodeThis(buffer); putString(field, buffer); putString(queryTensorName, buffer); + int approxNum = (approximate ? 1 : 0); + // should become always-true later: + boolean sendDistanceThreshold = (distanceThreshold < Double.POSITIVE_INFINITY); + if (sendDistanceThreshold) { + approxNum |= 0x40; // temporary flag bit + } IntegerCompressor.putCompressedPositiveNumber(targetNumHits, buffer); - IntegerCompressor.putCompressedPositiveNumber((approximate ? 1 : 0), buffer); + IntegerCompressor.putCompressedPositiveNumber(approxNum, buffer); IntegerCompressor.putCompressedPositiveNumber(hnswExploreAdditionalHits, buffer); - buffer.putDouble(distanceThreshold); + if (sendDistanceThreshold) { + buffer.putDouble(distanceThreshold); + } return 1; // number of encoded stack dump items } diff --git a/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp b/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp index 6feec9bbba2..ce24de02281 100644 --- a/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp +++ b/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp @@ -273,7 +273,13 @@ SimpleQueryStackDumpIterator::next() _extraIntArg1 = readCompressedPositiveInt(p); // targetNumHits _extraIntArg2 = readCompressedPositiveInt(p); // allow_approximate _extraIntArg3 = readCompressedPositiveInt(p); // explore_additional_hits - _extraDoubleArg4 = read_double(p); // distance threshold + if ((_extraIntArg2 & 0x40) != 0) { + _extraIntArg2 &= ~0x40; + // in some later release, do this always: + _extraDoubleArg4 = read_double(p); // distance threshold + } else { + _extraDoubleArg4 = std::numeric_limits<double>::max(); + } _currArity = 0; } catch (...) { return false; diff --git a/searchlib/src/vespa/searchlib/query/tree/stackdumpcreator.cpp b/searchlib/src/vespa/searchlib/query/tree/stackdumpcreator.cpp index a006e66310c..d2ac46157b1 100644 --- a/searchlib/src/vespa/searchlib/query/tree/stackdumpcreator.cpp +++ b/searchlib/src/vespa/searchlib/query/tree/stackdumpcreator.cpp @@ -263,7 +263,8 @@ class QueryNodeConverter : public QueryVisitor { createTermNode(node, ParseItem::ITEM_NEAREST_NEIGHBOR); appendString(node.get_query_tensor_name()); appendCompressedPositiveNumber(node.get_target_num_hits()); - appendCompressedPositiveNumber(node.get_allow_approximate() ? 1 : 0); + // XXX subtract 0x40 later: + appendCompressedPositiveNumber(node.get_allow_approximate() ? 0x41 : 0x40); appendCompressedPositiveNumber(node.get_explore_additional_hits()); appendDouble(node.get_distance_threshold()); } |