summaryrefslogtreecommitdiffstats
path: root/container-search
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-03-30 12:34:42 +0200
committerGitHub <noreply@github.com>2023-03-30 12:34:42 +0200
commita12d48f225b525d40f4eb28601e71cb0fd640cc1 (patch)
treec738995167eb52d043abec9269e74e2d9c04d980 /container-search
parentabea67baa0f5f10537268e73bc8402fb6e512f8f (diff)
parent4667008acc2054fab15525198d7833459c2a1c63 (diff)
Merge pull request #26641 from vespa-engine/balder/control-slime-decoding
Propagate the configured slime decode type into the rpc summary handl…
Diffstat (limited to 'container-search')
-rw-r--r--container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcInvokerFactory.java12
-rw-r--r--container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcProtobufFillInvoker.java12
2 files changed, 21 insertions, 3 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcInvokerFactory.java b/container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcInvokerFactory.java
index 4466b03a713..154002c4f77 100644
--- a/container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcInvokerFactory.java
+++ b/container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcInvokerFactory.java
@@ -20,11 +20,20 @@ public class RpcInvokerFactory extends InvokerFactory {
private final RpcConnectionPool rpcResourcePool;
private final CompressPayload compressor;
+ private final RpcProtobufFillInvoker.DecodePolicy decodeType;
+
+ private static RpcProtobufFillInvoker.DecodePolicy convert(DispatchConfig.SummaryDecodePolicy.Enum decoding) {
+ return switch (decoding) {
+ case EAGER -> RpcProtobufFillInvoker.DecodePolicy.EAGER;
+ case ONDEMAND -> RpcProtobufFillInvoker.DecodePolicy.ONDEMAND;
+ };
+ }
public RpcInvokerFactory(RpcConnectionPool rpcResourcePool, SearchGroups cluster, DispatchConfig dispatchConfig) {
super(cluster, dispatchConfig);
this.rpcResourcePool = rpcResourcePool;
this.compressor = new CompressService();
+ decodeType = convert(dispatchConfig.summaryDecodePolicy());
}
@Override
@@ -37,6 +46,7 @@ public class RpcInvokerFactory extends InvokerFactory {
Query query = result.getQuery();
boolean summaryNeedsQuery = searcher.summaryNeedsQuery(query);
- return new RpcProtobufFillInvoker(rpcResourcePool, compressor, searcher.getDocumentDatabase(query), searcher.getServerId(), summaryNeedsQuery);
+ return new RpcProtobufFillInvoker(rpcResourcePool, compressor, searcher.getDocumentDatabase(query),
+ searcher.getServerId(), decodeType, summaryNeedsQuery);
}
}
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 4e538fb54dc..2bdafecfaba 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
@@ -21,6 +21,7 @@ import com.yahoo.search.result.ErrorMessage;
import com.yahoo.search.result.Hit;
import com.yahoo.slime.ArrayTraverser;
import com.yahoo.slime.BinaryFormat;
+import com.yahoo.slime.BinaryView;
import java.util.Iterator;
import java.util.List;
@@ -42,11 +43,14 @@ public class RpcProtobufFillInvoker extends FillInvoker {
private static final Logger log = Logger.getLogger(RpcProtobufFillInvoker.class.getName());
+ enum DecodePolicy {EAGER, ONDEMAND}
+
private final DocumentDatabase documentDb;
private final RpcConnectionPool resourcePool;
private final boolean summaryNeedsQuery;
private final String serverId;
private final CompressPayload compressor;
+ private final DecodePolicy decodePolicy;
private BlockingQueue<Pair<Client.ResponseOrError<ProtobufResponse>, List<FastHit>>> responses;
@@ -56,12 +60,14 @@ public class RpcProtobufFillInvoker extends FillInvoker {
/** The number of responses we should receive (and process) before this is complete */
private int outstandingResponses;
- RpcProtobufFillInvoker(RpcConnectionPool resourcePool, CompressPayload compressor, DocumentDatabase documentDb, String serverId, boolean summaryNeedsQuery) {
+ RpcProtobufFillInvoker(RpcConnectionPool resourcePool, CompressPayload compressor, DocumentDatabase documentDb,
+ String serverId, DecodePolicy decodePolicy, boolean summaryNeedsQuery) {
this.documentDb = documentDb;
this.resourcePool = resourcePool;
this.serverId = serverId;
this.summaryNeedsQuery = summaryNeedsQuery;
this.compressor = compressor;
+ this.decodePolicy = decodePolicy;
}
@Override
@@ -211,7 +217,9 @@ public class RpcProtobufFillInvoker extends FillInvoker {
private int fill(Result result, List<FastHit> hits, String summaryClass, byte[] payload) {
try {
var protobuf = SearchProtocol.DocsumReply.parseFrom(payload);
- var root = BinaryFormat.decode(protobuf.getSlimeSummaries().toByteArray()).get();
+ var root = (decodePolicy == DecodePolicy.ONDEMAND)
+ ? BinaryView.inspect(protobuf.getSlimeSummaries().toByteArray())
+ : BinaryFormat.decode(protobuf.getSlimeSummaries().toByteArray()).get();
var errors = root.field("errors");
boolean hasErrors = errors.valid() && (errors.entries() > 0);
if (hasErrors) {