summaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/search/query/profile/compiled
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@verizonmedia.com>2019-10-28 14:43:39 +0100
committerJon Bratseth <bratseth@verizonmedia.com>2019-10-28 14:43:39 +0100
commit7b9f05860e4906dc68a4bbd5d8382976eb720d74 (patch)
tree8d1ab52324858fc8b5f76d4f2779f380379f94ae /container-search/src/main/java/com/yahoo/search/query/profile/compiled
parentf55ece33c8f97ad8c51f58ebdfed15a7d95e89dc (diff)
Trace sources of query profile values
Diffstat (limited to 'container-search/src/main/java/com/yahoo/search/query/profile/compiled')
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/profile/compiled/CompiledQueryProfile.java21
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/profile/compiled/ValueWithSource.java5
2 files changed, 25 insertions, 1 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/compiled/CompiledQueryProfile.java b/container-search/src/main/java/com/yahoo/search/query/profile/compiled/CompiledQueryProfile.java
index 06a6ac48cb6..644d366e7d0 100644
--- a/container-search/src/main/java/com/yahoo/search/query/profile/compiled/CompiledQueryProfile.java
+++ b/container-search/src/main/java/com/yahoo/search/query/profile/compiled/CompiledQueryProfile.java
@@ -104,6 +104,7 @@ public class CompiledQueryProfile extends AbstractComponent implements Cloneable
*/
public final Map<String, Object> listValues(CompoundName prefix) { return listValues(prefix, Collections.<String,String>emptyMap()); }
public final Map<String, Object> listValues(String prefix) { return listValues(new CompoundName(prefix)); }
+
/**
* Return all objects that start with the given prefix path. Use "" to list all.
* <p>
@@ -113,6 +114,7 @@ public class CompiledQueryProfile extends AbstractComponent implements Cloneable
public final Map<String, Object> listValues(String prefix, Map<String, String> context) {
return listValues(new CompoundName(prefix), context);
}
+
/**
* Return all objects that start with the given prefix path. Use "" to list all.
* <p>
@@ -122,6 +124,7 @@ public class CompiledQueryProfile extends AbstractComponent implements Cloneable
public final Map<String, Object> listValues(CompoundName prefix, Map<String, String> context) {
return listValues(prefix, context, null);
}
+
/**
* Adds all objects that start with the given path prefix to the given value map. Use "" to list all.
* <p>
@@ -147,6 +150,24 @@ public class CompiledQueryProfile extends AbstractComponent implements Cloneable
return values;
}
+ public Map<String, ValueWithSource> listValuesWithSources(CompoundName prefix,
+ Map<String, String> context,
+ Properties substitution) {
+ Map<String, ValueWithSource> values = new HashMap<>();
+ for (Map.Entry<CompoundName, DimensionalValue<ValueWithSource>> entry : entries.entrySet()) {
+ if ( entry.getKey().size() <= prefix.size()) continue;
+ if ( ! entry.getKey().hasPrefix(prefix)) continue;
+
+ ValueWithSource valueWithSource = entry.getValue().get(context);
+ if (valueWithSource == null) continue;
+
+ valueWithSource = valueWithSource.withValue(substitute(valueWithSource.value(), context, substitution));
+ CompoundName suffixName = entry.getKey().rest(prefix.size());
+ values.put(suffixName.toString(), valueWithSource);
+ }
+ return values;
+ }
+
public final Object get(String name) {
return get(name, Collections.emptyMap());
}
diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/compiled/ValueWithSource.java b/container-search/src/main/java/com/yahoo/search/query/profile/compiled/ValueWithSource.java
index c2ce34c3f47..11281b3cd52 100644
--- a/container-search/src/main/java/com/yahoo/search/query/profile/compiled/ValueWithSource.java
+++ b/container-search/src/main/java/com/yahoo/search/query/profile/compiled/ValueWithSource.java
@@ -39,7 +39,10 @@ public class ValueWithSource {
@Override
public String toString() {
- return value + " from " + ownerId + ( variant != null ? " variant " + variant : "");
+ return value +
+ " (from query profile '" + ownerId + "'" +
+ ( variant != null ? " variant " + variant : "") +
+ ")";
}
}