From 895e5881213da925d71a6d0ad8feffc92acaa96e Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Thu, 25 Aug 2022 11:59:29 +0200 Subject: Wire in query parameter profileDepth to control how deep down in the depency tree profiling shall go. --- .../src/main/java/com/yahoo/search/query/Trace.java | 10 ++++++++-- .../com/yahoo/search/query/properties/QueryProperties.java | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'container-search/src/main/java/com/yahoo/search/query') 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)) -- cgit v1.2.3