diff options
author | Jon Bratseth <bratseth@oath.com> | 2018-02-09 12:54:15 +0100 |
---|---|---|
committer | Jon Bratseth <bratseth@oath.com> | 2018-02-09 12:54:15 +0100 |
commit | 101e046bb6df5a3269331600228c75c372102979 (patch) | |
tree | 6a043bd83e0e2b3148acb0c447bc9646f031d884 /searchlib | |
parent | 4f55d543f0569d992a21f69b4b3c1309790de74d (diff) |
Re-apply typecheck ranking expressions in Java
Diffstat (limited to 'searchlib')
-rwxr-xr-x | searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/ReferenceNode.java | 17 |
1 files changed, 14 insertions, 3 deletions
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<String> path, CompositeNode parent) { + return toString(context, path, true); + } + + private String toString(SerializationContext context, Deque<String> 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 |