diff options
author | Jon Bratseth <bratseth@gmail.com> | 2022-06-14 15:55:57 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2022-06-14 15:55:57 +0200 |
commit | 1a4e603b63216fd459b4b1a6e26e27d737f39c37 (patch) | |
tree | 230aa5642c48646bd0a5b9342127cd4379b7d5cc /container-search/src/main/java/com/yahoo | |
parent | 2788e1e0530c2d54d513ac460f919405a58657d6 (diff) |
Move explainLevel into query.trace
Diffstat (limited to 'container-search/src/main/java/com/yahoo')
4 files changed, 28 insertions, 37 deletions
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 131fe8d151a..b50a7ccc2db 100644 --- a/container-search/src/main/java/com/yahoo/search/Query.java +++ b/container-search/src/main/java/com/yahoo/search/Query.java @@ -138,9 +138,6 @@ public class Query extends com.yahoo.processing.Request implements Cloneable { /** The number of hits to return */ private int hits = 10; - /** The query explain level, 0 means no explaining */ - private int explainLevel = 0; - // The timeout to be used when dumping rank features private static final long dumpTimeout = (6 * 60 * 1000); // 6 minutes private static final long defaultTimeout = 500; @@ -189,7 +186,6 @@ public class Query extends com.yahoo.processing.Request implements Cloneable { public static final CompoundName QUERY_PROFILE = new CompoundName("queryProfile"); public static final CompoundName SEARCH_CHAIN = new CompoundName("searchChain"); - public static final CompoundName EXPLAIN_LEVEL = new CompoundName("explainLevel"); public static final CompoundName NO_CACHE = new CompoundName("noCache"); public static final CompoundName GROUPING_SESSION_CACHE = new CompoundName("groupingSessionCache"); public static final CompoundName TIMEOUT = new CompoundName("timeout"); @@ -198,6 +194,10 @@ public class Query extends com.yahoo.processing.Request implements Cloneable { @Deprecated // TODO: Remove on Vespa 9 public static final CompoundName TRACE_LEVEL = new CompoundName("traceLevel"); + /** @deprecated use Trace.EXPLAIN_LEVEL */ + @Deprecated // TODO: Remove on Vespa 9 + public static final CompoundName EXPLAIN_LEVEL = new CompoundName("explainLevel"); + private static final QueryProfileType argumentType; static { argumentType = new QueryProfileType("native"); @@ -209,7 +209,6 @@ public class Query extends com.yahoo.processing.Request implements Cloneable { argumentType.addField(new FieldDescription(HITS.toString(), "integer", "hits count")); argumentType.addField(new FieldDescription(QUERY_PROFILE.toString(), "string")); argumentType.addField(new FieldDescription(SEARCH_CHAIN.toString(), "string")); - argumentType.addField(new FieldDescription(EXPLAIN_LEVEL.toString(), "integer", "explainlevel")); argumentType.addField(new FieldDescription(NO_CACHE.toString(), "boolean", "nocache")); argumentType.addField(new FieldDescription(GROUPING_SESSION_CACHE.toString(), "boolean", "groupingSessionCache")); argumentType.addField(new FieldDescription(TIMEOUT.toString(), "string", "timeout")); @@ -543,35 +542,21 @@ public class Query extends com.yahoo.processing.Request implements Cloneable { */ public void resetTimeout() { this.startTime = System.currentTimeMillis(); } - /** - * Sets the context level of this query, 0 means no tracing - * Higher numbers means increasingly more tracing - * - * @deprecated use getTrace().setLevel(level) - */ + /** @deprecated use getTrace().setLevel(level) */ @Deprecated // TODO: Remove on Vespa 9 public void setTraceLevel(int traceLevel) { trace.setLevel(traceLevel); } - /** - * Sets the explain level of this query, 0 means no tracing - * Higher numbers means increasingly more explaining - */ - public void setExplainLevel(int explainLevel) { this.explainLevel = explainLevel; } + /** @deprecated use getTrace().setExplainLevel(level) */ + @Deprecated // TODO: Remove on Vespa 9 + public void setExplainLevel(int explainLevel) { trace.setExplainLevel(explainLevel); } - /** - * Returns the context level of this query, 0 means no tracing - * Higher numbers means increasingly more tracing - * - * @deprecated use getTrace().setLevel(level) - */ + /** @deprecated use getTrace().setLevel(level) */ @Deprecated // TODO: Remove on Vespa 9 public int getTraceLevel() { return trace.getLevel(); } - /** - * Returns the explain level of this query, 0 means no tracing - * Higher numbers means increasingly more explaining - */ - public int getExplainLevel() { return explainLevel; } + /** @deprecated use getTrace().getExplainLevel(level) */ + @Deprecated // TODO: Remove on Vespa 9 + public int getExplainLevel() { return getTrace().getExplainLevel(); } /** * Returns the context level of this query, 0 means no tracing @@ -701,7 +686,7 @@ public class Query extends com.yahoo.processing.Request implements Cloneable { */ public void attachContext(Query query) throws IllegalStateException { query.getTrace().setLevel(getTrace().getLevel()); - query.setExplainLevel(getExplainLevel()); + query.getTrace().setExplainLevel(getTrace().getExplainLevel()); if (context == null) return; if (query.getContext(false) != null) { // If we added the other query's context info as a subnode in this @@ -901,8 +886,6 @@ public class Query extends com.yahoo.processing.Request implements Cloneable { assert (clone.properties().getParentQuery() == clone); clone.setTimeout(getTimeout()); - clone.setTraceLevel(getTraceLevel()); - clone.setExplainLevel(getExplainLevel()); clone.setHits(getHits()); clone.setOffset(getOffset()); clone.setNoCache(getNoCache()); 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 256ea0185a0..8b2457606ab 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 @@ -93,8 +93,8 @@ public class ProtobufSerialization { if (query.getModel().getExecution().trace().getForceTimestamps()) { traceLevel = Math.max(traceLevel, 5); // Backend produces timing information on level 4 and 5 } - if (query.getExplainLevel() > 0) { - traceLevel = Math.max(traceLevel, query.getExplainLevel() + 5); + if (query.getTrace().getExplainLevel() > 0) { + traceLevel = Math.max(traceLevel, query.getTrace().getExplainLevel() + 5); } return traceLevel; } 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 024e956e0ef..9f056b14c21 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 @@ -33,6 +33,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 TIMESTAMPS = "timestamps"; public static final String QUERY = "query"; @@ -41,6 +42,7 @@ public class Trace implements Cloneable { argumentType.setStrict(true); argumentType.setBuiltin(true); argumentType.addField(new FieldDescription(LEVEL, "integer", "tracelevel traceLevel")); + argumentType.addField(new FieldDescription(EXPLAIN_LEVEL, "integer", "explainlevel explainLevel")); argumentType.addField(new FieldDescription(TIMESTAMPS, "boolean")); argumentType.addField(new FieldDescription(QUERY, "boolean")); argumentType.freeze(); @@ -51,6 +53,7 @@ public class Trace implements Cloneable { private Query parent; private int level = 0; + private int explainLevel = 0; private boolean timestamps = false; private boolean query = true; @@ -63,6 +66,10 @@ public class Trace implements Cloneable { public void setLevel(int level) { this.level = level; } public boolean isTraceable(int level) { return level <= this.level; } + /** Sets the explain level of this query, 0 means no tracing. Higher numbers means increasingly more explaining. */ + public void setExplainLevel(int explainLevel) { this.explainLevel = explainLevel; } + public int getExplainLevel() { return explainLevel; } + /** Returns whether trace entries should have a timestamp. Default is false. */ public boolean getTimestamps() { return timestamps; } public void setTimestamps(boolean timestamps) { this.timestamps = timestamps; } @@ -208,13 +215,14 @@ public class Trace implements Cloneable { if ( ! (o instanceof Trace)) return false; Trace other = (Trace)o; if (other.level != this.level) return false; + if (other.explainLevel != this.explainLevel) return false; if (other.timestamps != this.timestamps) return false; if (other.query != this.query) return false; return true; } @Override - public int hashCode() { return Objects.hash(level, timestamps, query); } + public int hashCode() { return Objects.hash(level, explainLevel, timestamps, query); } @Override public Trace clone() { @@ -228,7 +236,7 @@ public class Trace implements Cloneable { @Override public String toString() { - return "trace [level: " + level + ", timestamps: " + timestamps + ", query: " + query + "]"; + return "trace [level: " + level + ", explainLevel: " + explainLevel + ", timestamps: " + timestamps + ", query: " + query + "]"; } } 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 cc84cba327f..f6e158cf04a 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 @@ -136,13 +136,13 @@ public class QueryProperties extends Properties { } else if (key.size() == 2 && key.first().equals(Trace.TRACE)) { if (key.last().equals(Trace.LEVEL)) return query.getTrace().getLevel(); + if (key.last().equals(Trace.EXPLAIN_LEVEL)) return query.getTrace().getExplainLevel(); if (key.last().equals(Trace.TIMESTAMPS)) return query.getTrace().getTimestamps(); if (key.last().equals(Trace.QUERY)) return query.getTrace().getQuery(); } else if (key.size() == 1) { if (key.equals(Query.HITS)) return query.getHits(); if (key.equals(Query.OFFSET)) return query.getOffset(); - if (key.equals(Query.EXPLAIN_LEVEL)) return query.getExplainLevel(); if (key.equals(Query.TIMEOUT)) return query.getTimeout(); if (key.equals(Query.NO_CACHE)) return query.getNoCache(); if (key.equals(Query.GROUPING_SESSION_CACHE)) return query.getGroupingSessionCache(); @@ -310,6 +310,8 @@ public class QueryProperties extends Properties { else if (key.size() == 2 && key.first().equals(Trace.TRACE)) { if (key.last().equals(Trace.LEVEL)) query.getTrace().setLevel(asInteger(value, 0)); + if (key.last().equals(Trace.EXPLAIN_LEVEL)) + query.getTrace().setExplainLevel(asInteger(value, 0)); if (key.last().equals(Trace.TIMESTAMPS)) query.getTrace().setTimestamps(asBoolean(value, false)); if (key.last().equals(Trace.QUERY)) @@ -336,8 +338,6 @@ public class QueryProperties extends Properties { query.setHits(asInteger(value,10)); else if (key.equals(Query.OFFSET)) query.setOffset(asInteger(value,0)); - else if (key.equals(Query.EXPLAIN_LEVEL)) - query.setExplainLevel(asInteger(value,0)); else if (key.equals(Query.TIMEOUT)) query.setTimeout(value.toString()); else if (key.equals(Query.NO_CACHE)) |