summaryrefslogtreecommitdiffstats
path: root/container-search
diff options
context:
space:
mode:
authorjonmv <venstad@gmail.com>2023-11-23 11:52:59 +0100
committerjonmv <venstad@gmail.com>2023-11-23 11:52:59 +0100
commit5ddba8a9bb72beed19a7edb47182116c74f502ac (patch)
treebabb406561cb6deef5e1290db4dc58bbbaf8203e /container-search
parentedabe158d03acf71dc54c73f036c0f12cb4d2412 (diff)
Log whenever hits are created (FS4, Fast) with negative distribution keys
Diffstat (limited to 'container-search')
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/fastsearch/FastHit.java23
-rw-r--r--container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcProtobufFillInvoker.java11
2 files changed, 13 insertions, 21 deletions
diff --git a/container-search/src/main/java/com/yahoo/prelude/fastsearch/FastHit.java b/container-search/src/main/java/com/yahoo/prelude/fastsearch/FastHit.java
index 3bf10295ed9..b5e5ed9ed8f 100644
--- a/container-search/src/main/java/com/yahoo/prelude/fastsearch/FastHit.java
+++ b/container-search/src/main/java/com/yahoo/prelude/fastsearch/FastHit.java
@@ -22,6 +22,8 @@ import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.function.BiConsumer;
+import java.util.logging.Level;
+import java.util.logging.Logger;
/**
* A regular hit from a Vespa backend
@@ -31,6 +33,8 @@ import java.util.function.BiConsumer;
*/
public class FastHit extends Hit {
+ private static final Logger log = Logger.getLogger(FastHit.class.getName());
+
private static final byte[] emptyGID = new byte[GlobalId.LENGTH];
/** The index of the content node this hit originated at */
private int distributionKey;
@@ -67,35 +71,26 @@ public class FastHit extends Hit {
* Creates an empty and temporarily invalid summary hit
*/
public FastHit() {
- super(new Relevance(0.0));
- globalId = emptyGID;
- partId = 0;
- distributionKey = 0;
+ this(emptyGID, 0.0, 0, 0);
}
public FastHit(byte[] gid, double relevance, int partId, int distributionKey) {
this(gid, new Relevance(relevance), partId, distributionKey);
}
+
public FastHit(byte[] gid, Relevance relevance, int partId, int distributionKey) {
super(relevance);
this.globalId = gid;
this.partId = partId;
this.distributionKey = distributionKey;
+ if (distributionKey < 0)
+ log.log(Level.WARNING, "Distribution key is negative: " + this, new RuntimeException());
}
// Note: This constructor is only used for tests, production use is always of the empty constructor
public FastHit(String uri, double relevancy) {
- this(uri, relevancy, null);
- }
-
- // Note: This constructor is only used for tests, production use is always of the empty constructor
- private FastHit(String uri, double relevance, String source) {
- super(new Relevance(relevance));
- partId = 0;
- distributionKey = 0;
- globalId = emptyGID;
+ this(emptyGID, relevancy, 0, 0);
setId(uri);
- setSource(source);
types().add("summary");
}
diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcProtobufFillInvoker.java b/container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcProtobufFillInvoker.java
index 358336d0e43..7220bc61fe5 100644
--- a/container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcProtobufFillInvoker.java
+++ b/container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcProtobufFillInvoker.java
@@ -126,13 +126,10 @@ public class RpcProtobufFillInvoker extends FillInvoker {
/** Return a map of hits by their search node (partition) id */
private static ListMap<Integer, FastHit> hitsByNode(Result result) {
ListMap<Integer, FastHit> hitsByNode = new ListMap<>();
- for (Iterator<Hit> i = result.hits().unorderedDeepIterator(); i.hasNext();) {
- Hit h = i.next();
- if (!(h instanceof FastHit hit))
- continue;
+ for (Hit hit : (Iterable<Hit>) result.hits()::unorderedDeepIterator)
+ if (hit instanceof FastHit fastHit)
+ hitsByNode.put(fastHit.getDistributionKey(), fastHit);
- hitsByNode.put(hit.getDistributionKey(), hit);
- }
return hitsByNode;
}
@@ -144,7 +141,7 @@ public class RpcProtobufFillInvoker extends FillInvoker {
String error = "Could not fill hits from unknown node " + nodeId;
receive(Client.ResponseOrError.fromError(error), hits);
result.hits().addError(ErrorMessage.createEmptyDocsums(error));
- log.warning("Got hits with partid " + nodeId + ", which is not included in the current dispatch config");
+ log.warning("Got hits with node id " + nodeId + ", which is not included in the current dispatch config");
return;
}