diff options
Diffstat (limited to 'container-search/src/main')
5 files changed, 46 insertions, 40 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/AllValuesQueryProfileVisitor.java b/container-search/src/main/java/com/yahoo/search/query/profile/AllValuesQueryProfileVisitor.java index 68bf112133a..3c336c80d37 100644 --- a/container-search/src/main/java/com/yahoo/search/query/profile/AllValuesQueryProfileVisitor.java +++ b/container-search/src/main/java/com/yahoo/search/query/profile/AllValuesQueryProfileVisitor.java @@ -3,6 +3,9 @@ package com.yahoo.search.query.profile; import com.yahoo.processing.request.CompoundName; import com.yahoo.search.query.profile.compiled.ValueWithSource; +import com.yahoo.search.query.profile.types.FieldDescription; +import com.yahoo.search.query.profile.types.QueryProfileFieldType; +import com.yahoo.search.query.profile.types.QueryProfileType; import java.util.Collections; import java.util.HashMap; @@ -13,7 +16,7 @@ import java.util.Map; */ final class AllValuesQueryProfileVisitor extends PrefixQueryProfileVisitor { - private final Map<String, ValueWithSource> values = new HashMap<>(); + private Map<String, ValueWithSource> values = new HashMap<>(); /* Lists all values starting at prefix */ public AllValuesQueryProfileVisitor(CompoundName prefix) { diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/BackedOverridableQueryProfile.java b/container-search/src/main/java/com/yahoo/search/query/profile/BackedOverridableQueryProfile.java index 0bb36d87f64..11864e60cec 100644 --- a/container-search/src/main/java/com/yahoo/search/query/profile/BackedOverridableQueryProfile.java +++ b/container-search/src/main/java/com/yahoo/search/query/profile/BackedOverridableQueryProfile.java @@ -22,7 +22,7 @@ import java.util.Map; public class BackedOverridableQueryProfile extends OverridableQueryProfile implements Cloneable { /** The backing read only query profile, or null if this is not backed */ - private final QueryProfile backingProfile; + private QueryProfile backingProfile; /** * Creates an overridable profile from the given backing profile. The backing profile will never be @@ -95,16 +95,16 @@ public class BackedOverridableQueryProfile extends OverridableQueryProfile imple } @Override - protected void visitInherited(boolean allowContent, QueryProfileVisitor visitor, DimensionBinding dimensionBinding, QueryProfile owner) { - super.visitInherited(allowContent, visitor, dimensionBinding, owner); + protected void visitInherited(boolean allowContent,QueryProfileVisitor visitor,DimensionBinding dimensionBinding, QueryProfile owner) { + super.visitInherited(allowContent,visitor,dimensionBinding, owner); if (visitor.isDone()) return; - backingProfile.visitInherited(allowContent, visitor, dimensionBinding,owner); + backingProfile.visitInherited(allowContent,visitor,dimensionBinding,owner); } /** Returns a value from the content of this: The value in this, or the value from the backing if not set in this */ protected Object getContent(String localKey) { - Object value = super.getContent(localKey); - if (value != null) return value; + Object value=super.getContent(localKey); + if (value!=null) return value; return backingProfile.getContent(localKey); } @@ -125,7 +125,7 @@ public class BackedOverridableQueryProfile extends OverridableQueryProfile imple @Override public String toString() { - return "overridable wrapper of " + backingProfile; + return "overridable wrapper of " + backingProfile.toString(); } @Override diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfile.java b/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfile.java index d0a42e8a1f9..6008b046d1a 100644 --- a/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfile.java +++ b/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfile.java @@ -366,7 +366,7 @@ public class QueryProfile extends FreezableSimpleComponent implements Cloneable * @throws IllegalArgumentException if the given name is illegal given the types of this or any nested query profile * @throws IllegalStateException if this query profile is frozen */ - public final void set(String name, Object value, DimensionValues dimensionValues, QueryProfileRegistry registry) { + public final void set(String name,Object value, DimensionValues dimensionValues, QueryProfileRegistry registry) { set(new CompoundName(name), value, DimensionBinding.createFrom(getDimensions(), dimensionValues), registry); } @@ -527,6 +527,7 @@ public class QueryProfile extends FreezableSimpleComponent implements Cloneable QueryProfileVisitor visitor, DimensionBinding dimensionBinding, QueryProfile owner) { + //System.out.println(" visiting " + this); visitor.onQueryProfile(this, dimensionBinding, owner, null); if (visitor.isDone()) return; @@ -540,6 +541,7 @@ public class QueryProfile extends FreezableSimpleComponent implements Cloneable if (visitor.visitInherited()) visitInherited(allowContent, visitor, dimensionBinding, owner); + //System.out.println(" done visiting " + this); } protected void visitVariants(boolean allowContent, QueryProfileVisitor visitor, DimensionBinding dimensionBinding) { @@ -736,7 +738,7 @@ public class QueryProfile extends FreezableSimpleComponent implements Cloneable parent.overridable.put(fieldName.last(), overridable); } - /** Sets a value to a (possibly non-local) node. */ + /** Sets a value to a (possibly non-local) node. The parent query profile holding the value is returned */ private void setNode(CompoundName name, Object value, QueryProfileType parentType, DimensionBinding dimensionBinding, QueryProfileRegistry registry) { ensureNotFrozen(); @@ -809,18 +811,19 @@ public class QueryProfile extends FreezableSimpleComponent implements Cloneable validateName(localName); value = convertToSubstitutionString(value); - if (dimensionBinding.isNull()) { - Object combinedValue = value instanceof QueryProfile - ? combineValues(value, content == null ? null : content.get(localName)) - : combineValues(value, localLookup(localName, dimensionBinding)); - if (combinedValue != null) + Object combinedValue; + if (value instanceof QueryProfile) + combinedValue = combineValues(value, content == null ? null : content.get(localName)); + else + combinedValue = combineValues(value, localLookup(localName, dimensionBinding)); + + if (combinedValue!=null) content.put(localName, combinedValue); } else { - if (variants == null) { + if (variants == null) variants = new QueryProfileVariants(dimensionBinding.getDimensions(), this); - } variants.set(localName, dimensionBinding.getValues(), value); } } diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileVariant.java b/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileVariant.java index a33ee33b652..3f70ff98373 100644 --- a/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileVariant.java +++ b/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileVariant.java @@ -16,13 +16,13 @@ public class QueryProfileVariant implements Cloneable, Comparable<QueryProfileVa private List<QueryProfile> inherited = null; - private final DimensionValues dimensionValues; + private DimensionValues dimensionValues; private Map<String, Object> values; private boolean frozen = false; - private final QueryProfile owner; + private QueryProfile owner; public QueryProfileVariant(DimensionValues dimensionValues, QueryProfile owner) { this.dimensionValues = dimensionValues; @@ -59,16 +59,20 @@ public class QueryProfileVariant implements Cloneable, Comparable<QueryProfileVa return inherited; } - public Object set(String key, Object newValue) { + public void set(String key, Object newValue) { if (values == null) values = new HashMap<>(); Object oldValue = values.get(key); - Object combinedOrNull = QueryProfile.combineValues(newValue, oldValue); - if (combinedOrNull != null) - values.put(key, combinedOrNull); - return combinedOrNull; + if (oldValue == null) { + values.put(key, newValue); + } else { + Object combinedOrNull = QueryProfile.combineValues(newValue, oldValue); + if (combinedOrNull != null) { + values.put(key, combinedOrNull); + } + } } public void inherit(QueryProfile profile) { @@ -134,7 +138,6 @@ public class QueryProfileVariant implements Cloneable, Comparable<QueryProfileVa frozen=true; } - @Override public QueryProfileVariant clone() { if (frozen) return this; try { @@ -153,7 +156,7 @@ public class QueryProfileVariant implements Cloneable, Comparable<QueryProfileVa @Override public String toString() { - return "query profile variant of " + owner + " for " + dimensionValues; + return "query profile variant for " + dimensionValues; } } diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileVariants.java b/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileVariants.java index 062b9d8c6e4..4c4d6778d86 100644 --- a/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileVariants.java +++ b/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileVariants.java @@ -43,10 +43,10 @@ public class QueryProfileVariants implements Freezable, Cloneable { * Order matters - more specific values to the left in this list are more significant than more specific values * to the right */ - private final List<String> dimensions; + private List<String> dimensions; /** The query profile this variants of */ - private final QueryProfile owner; + private QueryProfile owner; /** * Creates a set of virtual query profiles which may return varying values over the set of dimensions given. @@ -105,10 +105,14 @@ public class QueryProfileVariants implements Freezable, Cloneable { if (contentName != null) { if (type != null) contentName = type.unalias(contentName); + //System.out.println(" accepting single value in " + this + " for local key " + contentName); acceptSingleValue(contentName, allowContent, visitor, dimensionBinding); // Special cased for performance + //System.out.println(" done accepting single value in " + this + " for local key " + contentName); } else { + //System.out.println(" accepting all values in " + this); acceptAllValues(allowContent, visitor, type, dimensionBinding); + //System.out.println(" done accepting all values in " + this); } } @@ -219,7 +223,7 @@ public class QueryProfileVariants implements Freezable, Cloneable { ensureNotFrozen(); // Update variant - Object combinedValue = getVariant(dimensionValues, true).set(fieldName, value); + getVariant(dimensionValues, true).set(fieldName, value); // Update per-variable optimized structure FieldValues fieldValues = fieldValuesByName.get(fieldName); @@ -228,6 +232,7 @@ public class QueryProfileVariants implements Freezable, Cloneable { fieldValuesByName.put(fieldName, fieldValues); } + Object combinedValue = QueryProfile.combineValues(value, fieldValues.getExact(dimensionValues)); if (combinedValue != null) fieldValues.put(dimensionValues, combinedValue); } @@ -256,7 +261,6 @@ public class QueryProfileVariants implements Freezable, Cloneable { return Collections.unmodifiableList(variants); } - @Override public QueryProfileVariants clone() { try { if (frozen) return this; @@ -304,12 +308,9 @@ public class QueryProfileVariants implements Freezable, Cloneable { return variant; } - @Override - public String toString() { return "variants of " + owner; } - public static class FieldValues implements Freezable, Cloneable { - private List<FieldValue> resolutionList = null; + private List<FieldValue> resolutionList=null; private boolean frozen = false; @@ -423,7 +424,7 @@ public class QueryProfileVariants implements Freezable, Cloneable { public static class FieldValue implements Comparable<FieldValue>, Cloneable { - private final DimensionValues dimensionValues; + private DimensionValues dimensionValues; private Object value; public FieldValue(DimensionValues dimensionValues, Object value) { @@ -461,7 +462,7 @@ public class QueryProfileVariants implements Freezable, Cloneable { } /** Clone by filling in the value from the given variants */ - public FieldValue clone(String fieldName, List<QueryProfileVariant> clonedVariants) { + public FieldValue clone(String fieldName,List<QueryProfileVariant> clonedVariants) { try { FieldValue clone = (FieldValue)super.clone(); if (this.value instanceof QueryProfile) @@ -474,7 +475,6 @@ public class QueryProfileVariants implements Freezable, Cloneable { } } - @Override public FieldValue clone() { try { FieldValue clone = (FieldValue)super.clone(); @@ -494,9 +494,6 @@ public class QueryProfileVariants implements Freezable, Cloneable { return null; } - @Override - public String toString() { return "field value " + value + " for " + dimensionValues; } - } } |