diff options
Diffstat (limited to 'container-search')
-rw-r--r-- | container-search/src/main/java/com/yahoo/search/query/profile/ModelObjectMap.java | 11 | ||||
-rw-r--r-- | container-search/src/main/java/com/yahoo/search/query/profile/types/FieldType.java | 25 |
2 files changed, 21 insertions, 15 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/ModelObjectMap.java b/container-search/src/main/java/com/yahoo/search/query/profile/ModelObjectMap.java index 059df807724..4dc9ade62e5 100644 --- a/container-search/src/main/java/com/yahoo/search/query/profile/ModelObjectMap.java +++ b/container-search/src/main/java/com/yahoo/search/query/profile/ModelObjectMap.java @@ -16,11 +16,14 @@ import com.yahoo.search.query.properties.PropertyMap; */ public class ModelObjectMap extends PropertyMap { - /** Returns true if the class of the value is not acceptable as a query profile value */ + /** + * Returns true if the class of the value is *not* acceptable as a query profile value, + * and therefore should be set in this. + */ @Override - protected boolean shouldSet(CompoundName name,Object value) { - if (value==null) return true; - return FieldType.fromClass(value.getClass())==null; + protected boolean shouldSet(CompoundName name, Object value) { + if (value == null) return true; + return ! FieldType.isLegalFieldValue(value); } } diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/types/FieldType.java b/container-search/src/main/java/com/yahoo/search/query/profile/types/FieldType.java index acefa26930a..69c07843681 100644 --- a/container-search/src/main/java/com/yahoo/search/query/profile/types/FieldType.java +++ b/container-search/src/main/java/com/yahoo/search/query/profile/types/FieldType.java @@ -5,6 +5,7 @@ import com.yahoo.search.query.profile.QueryProfile; import com.yahoo.search.query.profile.QueryProfileRegistry; import com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry; import com.yahoo.search.yql.YqlQuery; +import com.yahoo.tensor.Tensor; /** * Superclass of query type field types. @@ -73,17 +74,19 @@ public abstract class FieldType { throw new IllegalArgumentException("Unknown type '" + typeString + "'"); } - /** Returns the field type from a value class, or null if there is no type for it */ - public static FieldType fromClass(Class clazz) { - if (clazz == String.class) return stringType; - if (clazz == Integer.class) return integerType; - if (clazz == Long.class) return longType; - if (clazz == Float.class) return floatType; - if (clazz == Double.class) return doubleType; - if (clazz == Boolean.class) return booleanType; - if (clazz == YqlQuery.class) return queryType; - if (clazz == QueryProfile.class) return genericQueryProfileType; - return null; + /** Returns true if the given object is a legal field value of some field value type */ + public static boolean isLegalFieldValue(Object value) { + Class clazz = value.getClass(); + if (clazz == String.class) return true; + if (clazz == Integer.class) return true; + if (clazz == Long.class) return true; + if (clazz == Float.class) return true; + if (clazz == Double.class) return true; + if (clazz == Boolean.class) return true; + if (clazz == YqlQuery.class) return true; + if (clazz == QueryProfile.class) return true; + if (clazz == Tensor.class) return true; + return false; } } |