From 101e046bb6df5a3269331600228c75c372102979 Mon Sep 17 00:00:00 2001 From: Jon Bratseth Date: Fri, 9 Feb 2018 12:54:15 +0100 Subject: Re-apply typecheck ranking expressions in Java --- .../searchlib/rankingexpression/rule/ReferenceNode.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'searchlib/src') diff --git a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/ReferenceNode.java b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/ReferenceNode.java index 05a6773c5cb..b9b377dc0ec 100755 --- a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/ReferenceNode.java +++ b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/ReferenceNode.java @@ -60,6 +60,10 @@ public final class ReferenceNode extends CompositeNode { @Override public String toString(SerializationContext context, Deque path, CompositeNode parent) { + return toString(context, path, true); + } + + private String toString(SerializationContext context, Deque path, boolean includeOutput) { if (path == null) path = new ArrayDeque<>(); String myName = this.name; @@ -101,14 +105,21 @@ public final class ReferenceNode extends CompositeNode { } ret.append(")"); } - ret.append(myOutput != null ? "." + myOutput : ""); + if (includeOutput) + ret.append(myOutput != null ? "." + myOutput : ""); return ret.toString(); } @Override public TensorType type(TypeContext context) { - // Don't support outputs of different type, for simplicity - return context.getType(toString()); + // Ensure base name (excluding output exists, + // but don't support outputs of different tensor types (not used, so no need) + String name = toString(new SerializationContext(), null, false); + TensorType type = context.getType(name); + + if (type == null) + throw new IllegalArgumentException("Unknown feature '" + toString() + "'"); + return type; } @Override -- cgit v1.2.3