summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--container-core/src/main/java/com/yahoo/processing/execution/Execution.java7
-rw-r--r--container-search/abi-spec.json3
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/fastsearch/FastSearcher.java5
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/fastsearch/VespaBackEndSearcher.java19
-rw-r--r--container-search/src/main/java/com/yahoo/search/Query.java5
-rw-r--r--container-search/src/main/java/com/yahoo/search/dispatch/Dispatcher.java6
-rw-r--r--container-search/src/main/java/com/yahoo/search/dispatch/rpc/ProtobufSerialization.java4
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/Trace.java10
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/properties/QueryProperties.java2
-rw-r--r--container-search/src/main/java/com/yahoo/vespa/streamingvisitors/QueryEncoder.java17
-rw-r--r--container-search/src/main/java/com/yahoo/vespa/streamingvisitors/VdsVisitor.java15
-rw-r--r--container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java30
-rw-r--r--searchlib/src/protobuf/search_protocol.proto1
13 files changed, 56 insertions, 68 deletions
diff --git a/container-core/src/main/java/com/yahoo/processing/execution/Execution.java b/container-core/src/main/java/com/yahoo/processing/execution/Execution.java
index 158ec726722..f6a1149f056 100644
--- a/container-core/src/main/java/com/yahoo/processing/execution/Execution.java
+++ b/container-core/src/main/java/com/yahoo/processing/execution/Execution.java
@@ -393,7 +393,7 @@ public class Execution {
/**
* The name of the property to find
*/
- private String name;
+ private final String name;
private Object foundValue = null;
public PropertyValueVisitor(String name) {
@@ -403,9 +403,8 @@ public class Execution {
@Override
public void visit(TraceNode node) {
if (node.payload() == null) return;
- if (!(node.payload() instanceof Pair)) return;
+ if (!(node.payload() instanceof Pair property)) return;
- Pair property = (Pair) node.payload();
if (!property.getFirst().equals(name)) return;
foundValue = property.getSecond();
}
@@ -465,7 +464,7 @@ public class Execution {
/**
* The smallest trace level at which this information will be traced
*/
- private int value;
+ private final int value;
Level(int value) {
this.value = value;
diff --git a/container-search/abi-spec.json b/container-search/abi-spec.json
index b7374ecb81d..d81239d7152 100644
--- a/container-search/abi-spec.json
+++ b/container-search/abi-spec.json
@@ -5633,6 +5633,8 @@
"public boolean isTraceable(int)",
"public void setExplainLevel(int)",
"public int getExplainLevel()",
+ "public void setProfileDepth(int)",
+ "public int getProfileDepth()",
"public boolean getTimestamps()",
"public void setTimestamps(boolean)",
"public boolean getQuery()",
@@ -5653,6 +5655,7 @@
"public static final java.lang.String TRACE",
"public static final java.lang.String LEVEL",
"public static final java.lang.String EXPLAIN_LEVEL",
+ "public static final java.lang.String PROFILE_DEPTH",
"public static final java.lang.String TIMESTAMPS",
"public static final java.lang.String QUERY"
]
diff --git a/container-search/src/main/java/com/yahoo/prelude/fastsearch/FastSearcher.java b/container-search/src/main/java/com/yahoo/prelude/fastsearch/FastSearcher.java
index edd11974f8c..34ddd8e16cc 100644
--- a/container-search/src/main/java/com/yahoo/prelude/fastsearch/FastSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/fastsearch/FastSearcher.java
@@ -6,7 +6,6 @@ import com.yahoo.prelude.Pong;
import com.yahoo.prelude.querytransform.QueryRewrite;
import com.yahoo.search.Query;
import com.yahoo.search.Result;
-import com.yahoo.search.config.SchemaInfoConfig;
import com.yahoo.search.dispatch.Dispatcher;
import com.yahoo.search.dispatch.FillInvoker;
import com.yahoo.search.dispatch.SearchInvoker;
@@ -21,7 +20,6 @@ import com.yahoo.search.searchchain.Execution;
import java.io.IOException;
import java.util.Optional;
-import java.util.logging.Level;
/**
* The searcher which forwards queries to fdispatch nodes, using the fnet/fs4
@@ -170,7 +168,4 @@ public class FastSearcher extends VespaBackEndSearcher {
return "fast searcher (" + getName() + ") ";
}
- protected boolean isLoggingFine() {
- return getLogger().isLoggable(Level.FINE);
- }
}
diff --git a/container-search/src/main/java/com/yahoo/prelude/fastsearch/VespaBackEndSearcher.java b/container-search/src/main/java/com/yahoo/prelude/fastsearch/VespaBackEndSearcher.java
index e184037bc90..f948ddfb8e9 100644
--- a/container-search/src/main/java/com/yahoo/prelude/fastsearch/VespaBackEndSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/fastsearch/VespaBackEndSearcher.java
@@ -28,7 +28,6 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
-import java.util.logging.Level;
import java.util.logging.Logger;
/**
@@ -83,8 +82,7 @@ public abstract class VespaBackEndSearcher extends PingableSearcher {
if (tree instanceof GeoLocationItem) {
return true;
}
- if (tree instanceof CompositeItem) {
- var composite = (CompositeItem)tree;
+ if (tree instanceof CompositeItem composite) {
for (Item child : composite.items()) {
if (hasLocation(child)) return true;
}
@@ -202,8 +200,7 @@ public abstract class VespaBackEndSearcher extends PingableSearcher {
for (Iterator<Hit> i = hitIterator(result); i.hasNext(); ) {
Hit hit = i.next();
- if (hit instanceof FastHit) {
- FastHit fastHit = (FastHit) hit;
+ if (hit instanceof FastHit fastHit) {
if ( ! fastHit.isFilled(summaryClass)) {
Query q = fastHit.getQuery();
if (q == null) {
@@ -309,9 +306,7 @@ public abstract class VespaBackEndSearcher extends PingableSearcher {
s.append(" restrict=").append(query.getModel().getRestrict().toString());
}
- if (quotedSummaryClass.isPresent()) {
- s.append(" summary=").append(quotedSummaryClass.get());
- }
+ quotedSummaryClass.ifPresent((String summaryClass) -> s.append(" summary=").append(summaryClass));
query.trace(s.toString(), false, level);
if (query.getTrace().isTraceable(level + 1)) {
@@ -367,9 +362,7 @@ public abstract class VespaBackEndSearcher extends PingableSearcher {
for (Iterator<Hit> i = hitIterator(result); i.hasNext();) {
Hit hit = i.next();
- if (hit instanceof FastHit && ! hit.isFilled(summaryClass)) {
- FastHit fastHit = (FastHit) hit;
-
+ if (hit instanceof FastHit fastHit && ! hit.isFilled(summaryClass)) {
DocsumPacket docsum = packets[packetIndex];
packetIndex++;
@@ -407,10 +400,6 @@ public abstract class VespaBackEndSearcher extends PingableSearcher {
return error;
}
- protected boolean isLoggingFine() {
- return getLogger().isLoggable(Level.FINE);
- }
-
public void shutDown() { }
}
diff --git a/container-search/src/main/java/com/yahoo/search/Query.java b/container-search/src/main/java/com/yahoo/search/Query.java
index 3a2bccf017e..6930e648ffa 100644
--- a/container-search/src/main/java/com/yahoo/search/Query.java
+++ b/container-search/src/main/java/com/yahoo/search/Query.java
@@ -687,6 +687,7 @@ public class Query extends com.yahoo.processing.Request implements Cloneable {
public void attachContext(Query query) throws IllegalStateException {
query.getTrace().setLevel(getTrace().getLevel());
query.getTrace().setExplainLevel(getTrace().getExplainLevel());
+ query.getTrace().setProfileDepth(getTrace().getProfileDepth());
if (context == null) return;
if (query.getContext(false) != null) {
// If we added the other query's context info as a subnode in this
@@ -851,8 +852,7 @@ public class Query extends com.yahoo.processing.Request implements Cloneable {
public boolean equals(Object other) {
if (this == other) return true;
- if ( ! (other instanceof Query)) return false;
- Query q = (Query) other;
+ if ( ! (other instanceof Query q)) return false;
if (getOffset() != q.getOffset()) return false;
if (getHits() != q.getHits()) return false;
@@ -929,7 +929,6 @@ public class Query extends com.yahoo.processing.Request implements Cloneable {
/**
* Prepares this for binary serialization.
- *
* This must be invoked after all changes have been made to this query before it is passed
* on to a receiving backend. Calling it is somewhat expensive, so it should only happen once.
* If a prepared query is cloned, it stays prepared.
diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/Dispatcher.java b/container-search/src/main/java/com/yahoo/search/dispatch/Dispatcher.java
index 345c621ae24..8df825cf108 100644
--- a/container-search/src/main/java/com/yahoo/search/dispatch/Dispatcher.java
+++ b/container-search/src/main/java/com/yahoo/search/dispatch/Dispatcher.java
@@ -33,11 +33,9 @@ import java.util.Set;
/**
* A dispatcher communicates with search nodes to perform queries and fill hits.
- *
* This class allocates {@link SearchInvoker} and {@link FillInvoker} objects based
* on query properties and general system status. The caller can then use the provided
* invocation object to execute the search or fill.
- *
* This class is multithread safe.
*
* @author bratseth
@@ -142,8 +140,8 @@ public class Dispatcher extends AbstractComponent {
* Will run important code in order to trigger JIT compilation and avoid cold start issues.
* Currently warms up lz4 compression code.
*/
- private static long warmup(double seconds) {
- return new Compressor().warmup(seconds);
+ private static void warmup(double seconds) {
+ new Compressor().warmup(seconds);
}
/** Returns the search cluster this dispatches to */
diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/rpc/ProtobufSerialization.java b/container-search/src/main/java/com/yahoo/search/dispatch/rpc/ProtobufSerialization.java
index 154defe7eb2..e5fa37e7a65 100644
--- a/container-search/src/main/java/com/yahoo/search/dispatch/rpc/ProtobufSerialization.java
+++ b/container-search/src/main/java/com/yahoo/search/dispatch/rpc/ProtobufSerialization.java
@@ -81,6 +81,7 @@ public class ProtobufSerialization {
}
builder.setTraceLevel(getTraceLevelForBackend(query));
+ builder.setProfileDepth(query.getTrace().getProfileDepth());
mergeToSearchRequestFromRanking(query.getRanking(), builder);
@@ -283,8 +284,7 @@ public class ProtobufSerialization {
if (hit.getRelevance() != null) {
hitBuilder.setRelevance(hit.getRelevance().getScore());
}
- if (hit instanceof FastHit) {
- FastHit fhit = (FastHit) hit;
+ if (hit instanceof FastHit fhit) {
hitBuilder.setGlobalId(ByteString.copyFrom(fhit.getRawGlobalId()));
}
builder.addHits(hitBuilder);
diff --git a/container-search/src/main/java/com/yahoo/search/query/Trace.java b/container-search/src/main/java/com/yahoo/search/query/Trace.java
index 9f056b14c21..246c77e6c50 100644
--- a/container-search/src/main/java/com/yahoo/search/query/Trace.java
+++ b/container-search/src/main/java/com/yahoo/search/query/Trace.java
@@ -34,6 +34,7 @@ public class Trace implements Cloneable {
public static final String TRACE = "trace";
public static final String LEVEL = "level";
public static final String EXPLAIN_LEVEL = "explainLevel";
+ public static final String PROFILE_DEPTH = "profileDepth";
public static final String TIMESTAMPS = "timestamps";
public static final String QUERY = "query";
@@ -43,6 +44,7 @@ public class Trace implements Cloneable {
argumentType.setBuiltin(true);
argumentType.addField(new FieldDescription(LEVEL, "integer", "tracelevel traceLevel"));
argumentType.addField(new FieldDescription(EXPLAIN_LEVEL, "integer", "explainlevel explainLevel"));
+ argumentType.addField(new FieldDescription(PROFILE_DEPTH, "integer", "profiledepth profileDepth"));
argumentType.addField(new FieldDescription(TIMESTAMPS, "boolean"));
argumentType.addField(new FieldDescription(QUERY, "boolean"));
argumentType.freeze();
@@ -54,6 +56,7 @@ public class Trace implements Cloneable {
private int level = 0;
private int explainLevel = 0;
+ private int profileDepth = 0;
private boolean timestamps = false;
private boolean query = true;
@@ -70,6 +73,10 @@ public class Trace implements Cloneable {
public void setExplainLevel(int explainLevel) { this.explainLevel = explainLevel; }
public int getExplainLevel() { return explainLevel; }
+ /** Sets the profiling depth. Profiling enabled if non-zero. Higher numbers means increasingly more detail. */
+ public void setProfileDepth(int profileDepth) { this.profileDepth = profileDepth; }
+ public int getProfileDepth() { return profileDepth; }
+
/** Returns whether trace entries should have a timestamp. Default is false. */
public boolean getTimestamps() { return timestamps; }
public void setTimestamps(boolean timestamps) { this.timestamps = timestamps; }
@@ -212,8 +219,7 @@ public class Trace implements Cloneable {
@Override
public boolean equals(Object o) {
if (o == this ) return true;
- if ( ! (o instanceof Trace)) return false;
- Trace other = (Trace)o;
+ if ( ! (o instanceof Trace other)) return false;
if (other.level != this.level) return false;
if (other.explainLevel != this.explainLevel) return false;
if (other.timestamps != this.timestamps) return false;
diff --git a/container-search/src/main/java/com/yahoo/search/query/properties/QueryProperties.java b/container-search/src/main/java/com/yahoo/search/query/properties/QueryProperties.java
index 160a039fe2d..085a6382a13 100644
--- a/container-search/src/main/java/com/yahoo/search/query/properties/QueryProperties.java
+++ b/container-search/src/main/java/com/yahoo/search/query/properties/QueryProperties.java
@@ -312,6 +312,8 @@ public class QueryProperties extends Properties {
query.getTrace().setLevel(asInteger(value, 0));
if (key.last().equals(Trace.EXPLAIN_LEVEL))
query.getTrace().setExplainLevel(asInteger(value, 0));
+ if (key.last().equals(Trace.PROFILE_DEPTH))
+ query.getTrace().setProfileDepth(asInteger(value, 0));
if (key.last().equals(Trace.TIMESTAMPS))
query.getTrace().setTimestamps(asBoolean(value, false));
if (key.last().equals(Trace.QUERY))
diff --git a/container-search/src/main/java/com/yahoo/vespa/streamingvisitors/QueryEncoder.java b/container-search/src/main/java/com/yahoo/vespa/streamingvisitors/QueryEncoder.java
index e252a230d4f..11dcbbdec81 100644
--- a/container-search/src/main/java/com/yahoo/vespa/streamingvisitors/QueryEncoder.java
+++ b/container-search/src/main/java/com/yahoo/vespa/streamingvisitors/QueryEncoder.java
@@ -23,10 +23,9 @@ class QueryEncoder {
* Encodes properties of this query.
*
* @param buffer the buffer to encode to
- * @param encodeQueryData true to encode all properties, false to only include session information, not actual query data
* @return the encoded length
*/
- static int encodeAsProperties(Query query, ByteBuffer buffer, boolean encodeQueryData) {
+ static int encodeAsProperties(Query query, ByteBuffer buffer) {
// Make sure we don't encode anything here if we have turned the property feature off
// Due to sendQuery we sometimes end up turning this feature on and then encoding a 0 int as the number of
// property maps - that's ok (probably we should simplify by just always turning the feature on)
@@ -36,15 +35,13 @@ class QueryEncoder {
int mapCountPosition = buffer.position();
buffer.putInt(0); // map count will go here
int mapCount = 0;
- mapCount += query.getRanking().getProperties().encode(buffer, encodeQueryData);
- if (encodeQueryData) {
- mapCount += query.getRanking().getFeatures().encode(buffer);
- if (query.getPresentation().getHighlight() != null) {
- mapCount += MapEncoder.encodeMultiMap(Highlight.HIGHLIGHTTERMS,
- query.getPresentation().getHighlight().getHighlightTerms(), buffer);
- }
- mapCount += MapEncoder.encodeMap("model", createModelMap(query), buffer);
+ mapCount += query.getRanking().getProperties().encode(buffer, true);
+ mapCount += query.getRanking().getFeatures().encode(buffer);
+ if (query.getPresentation().getHighlight() != null) {
+ mapCount += MapEncoder.encodeMultiMap(Highlight.HIGHLIGHTTERMS,
+ query.getPresentation().getHighlight().getHighlightTerms(), buffer);
}
+ mapCount += MapEncoder.encodeMap("model", createModelMap(query), buffer);
mapCount += MapEncoder.encodeSingleValue(DocumentDatabase.MATCH_PROPERTY, DocumentDatabase.SEARCH_DOC_TYPE_KEY,
query.getModel().getDocumentDb(), buffer);
mapCount += MapEncoder.encodeMap("caches", createCacheSettingMap(query), buffer);
diff --git a/container-search/src/main/java/com/yahoo/vespa/streamingvisitors/VdsVisitor.java b/container-search/src/main/java/com/yahoo/vespa/streamingvisitors/VdsVisitor.java
index bd96f888b87..8501c9664ef 100644
--- a/container-search/src/main/java/com/yahoo/vespa/streamingvisitors/VdsVisitor.java
+++ b/container-search/src/main/java/com/yahoo/vespa/streamingvisitors/VdsVisitor.java
@@ -55,7 +55,6 @@ class VdsVisitor extends VisitorDataHandler implements Visitor {
private static final CompoundName streamingSelection=new CompoundName("streaming.selection");
private static final CompoundName streamingFromtimestamp=new CompoundName("streaming.fromtimestamp");
private static final CompoundName streamingTotimestamp=new CompoundName("streaming.totimestamp");
- private static final CompoundName streamingLoadtype=new CompoundName("streaming.loadtype");
private static final CompoundName streamingPriority=new CompoundName("streaming.priority");
private static final CompoundName streamingMaxbucketspervisitor=new CompoundName("streaming.maxbucketspervisitor");
@@ -69,7 +68,7 @@ class VdsVisitor extends VisitorDataHandler implements Visitor {
private final Map<String, DocumentSummary.Summary> summaryMap = new HashMap<>();
private final Map<Integer, Grouping> groupingMap = new ConcurrentHashMap<>();
private Query query = null;
- private VisitorSessionFactory visitorSessionFactory;
+ private final VisitorSessionFactory visitorSessionFactory;
private final int traceLevelOverride;
private Trace sessionTrace;
@@ -202,11 +201,9 @@ class VdsVisitor extends VisitorDataHandler implements Visitor {
static int getQueryFlags(Query query) {
int flags = 0;
- boolean requestCoverage = true; // Always request coverage information
-
flags |= query.properties().getBoolean(Model.ESTIMATE) ? 0x00000080 : 0;
flags |= (query.getRanking().getFreshness() != null) ? 0x00002000 : 0;
- flags |= requestCoverage ? 0x00008000 : 0;
+ flags |= 0x00008000;
flags |= query.getNoCache() ? 0x00010000 : 0;
flags |= 0x00020000; // was PARALLEL
flags |= query.properties().getBoolean(Ranking.RANKFEATURES,false) ? 0x00040000 : 0;
@@ -241,7 +238,7 @@ class VdsVisitor extends VisitorDataHandler implements Visitor {
ed.setReturned(query.getModel().getQueryTree().getRoot().encode(buf));
break;
case 1:
- ed.setReturned(QueryEncoder.encodeAsProperties(query, buf, true));
+ ed.setReturned(QueryEncoder.encodeAsProperties(query, buf));
break;
case 2:
throw new IllegalArgumentException("old aggregation no longer exists!");
@@ -296,13 +293,11 @@ class VdsVisitor extends VisitorDataHandler implements Visitor {
@Override
public void onMessage(Message m, AckToken token) {
- if (m instanceof QueryResultMessage) {
- QueryResultMessage qm = (QueryResultMessage)m;
+ if (m instanceof QueryResultMessage qm) {
onQueryResult(qm.getResult(), qm.getSummary());
} else if (m instanceof SearchResultMessage) {
onSearchResult(((SearchResultMessage) m).getResult());
- } else if (m instanceof DocumentSummaryMessage) {
- DocumentSummaryMessage dsm = (DocumentSummaryMessage)m;
+ } else if (m instanceof DocumentSummaryMessage dsm) {
onDocumentSummary(dsm.getResult());
} else {
throw new UnsupportedOperationException("Received unsupported message " + m + ". VdsVisitor can only accept query result, search result, and documentsummary messages.");
diff --git a/container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java b/container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java
index a722552b7d2..7b3c790f116 100644
--- a/container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java
@@ -48,10 +48,8 @@ import org.json.JSONObject;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
-import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
@@ -206,18 +204,18 @@ public class QueryTestCase {
WordItem fClone = (WordItem) and2Clone.getItem(0);
WordItem gClone = (WordItem) and2Clone.getItem(1);
- assertTrue(rankClone != rank);
- assertTrue(and1Clone != and1);
- assertTrue(and2Clone != and2);
- assertTrue(orClone != or);
+ assertNotSame(rankClone, rank);
+ assertNotSame(and1Clone, and1);
+ assertNotSame(and2Clone, and2);
+ assertNotSame(orClone, or);
- assertTrue(aClone != a);
- assertTrue(bClone != b);
- assertTrue(cClone != c);
- assertTrue(dClone != d);
- assertTrue(eClone != e);
- assertTrue(fClone != f);
- assertTrue(gClone != g);
+ assertNotSame(aClone, a);
+ assertNotSame(bClone, b);
+ assertNotSame(cClone, c);
+ assertNotSame(dClone, d);
+ assertNotSame(eClone, e);
+ assertNotSame(fClone, f);
+ assertNotSame(gClone, g);
assertEquals(aClone.getConnectedItem(), bClone);
assertEquals(bClone.getConnectedItem(), cClone);
@@ -604,6 +602,12 @@ public class QueryTestCase {
}
@Test
+ void testProfilingDepth() {
+ Query q = new Query("?query=foo&profileDepth=2");
+ assertEquals(2, q.getTrace().getProfileDepth());
+ }
+
+ @Test
void testQueryPropertyResolveTracing() {
QueryProfile testProfile = new QueryProfile("test");
testProfile.setOverridable("u", false, DimensionValues.empty);
diff --git a/searchlib/src/protobuf/search_protocol.proto b/searchlib/src/protobuf/search_protocol.proto
index 7137537d52d..83f6a978bac 100644
--- a/searchlib/src/protobuf/search_protocol.proto
+++ b/searchlib/src/protobuf/search_protocol.proto
@@ -24,6 +24,7 @@ message SearchRequest {
bytes grouping_blob = 15; // serialized opaquely like now, to be changed later
string geo_location = 16; // to be moved into query_tree
bytes query_tree_blob = 17; // serialized opaquely like now, to be changed later
+ int32 profileDepth = 18;
}
message TensorProperty {