summaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/searchdefinition/MapEvaluationTypeContext.java
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@oath.com>2018-02-21 16:02:19 +0100
committerJon Bratseth <bratseth@oath.com>2018-02-21 16:02:19 +0100
commit31805b7b9640302067713ce05573d9d1e5c92f39 (patch)
tree1952bfd2c241c095cd74fc9d8f08ec0ca7edf3bb /config-model/src/main/java/com/yahoo/searchdefinition/MapEvaluationTypeContext.java
parentf5a796313c118d62614d170f31286556ef6bb367 (diff)
Undeclared query features are taken as double-valued
Diffstat (limited to 'config-model/src/main/java/com/yahoo/searchdefinition/MapEvaluationTypeContext.java')
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/MapEvaluationTypeContext.java13
1 files changed, 12 insertions, 1 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/MapEvaluationTypeContext.java b/config-model/src/main/java/com/yahoo/searchdefinition/MapEvaluationTypeContext.java
index fcae756eab3..cf6d90db7fa 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/MapEvaluationTypeContext.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/MapEvaluationTypeContext.java
@@ -70,7 +70,7 @@ public class MapEvaluationTypeContext extends FunctionReferenceContext implement
// The argument may be a local identifier bound to the actual value
String argument = simpleArgument(reference.arguments()).get();
reference = Reference.simple(reference.name(), bindings.getOrDefault(argument, argument));
- return featureTypes.get(reference);
+ return featureTypes.getOrDefault(reference, defaultTypeOf(reference));
}
Optional<ExpressionFunction> function = functionInvocation(reference);
@@ -85,6 +85,17 @@ public class MapEvaluationTypeContext extends FunctionReferenceContext implement
}
/**
+ * Returns the default type for this simple feature, or nullif it does not have a default
+ */
+ public TensorType defaultTypeOf(Reference reference) {
+ if ( ! isSimpleFeature(reference))
+ throw new IllegalArgumentException("This can only be called for simple references, not " + reference);
+ if (reference.name().equals("query")) // we do not require all query features to be declared, only non-doubles
+ return TensorType.empty;
+ return null;
+ }
+
+ /**
* Returns the binding if this reference is a simple identifier which is bound in this context.
* Returns empty otherwise.
*/