diff options
author | Jon Bratseth <bratseth@verizonmedia.com> | 2019-12-04 05:26:01 -0800 |
---|---|---|
committer | Jon Bratseth <bratseth@verizonmedia.com> | 2019-12-04 05:26:01 -0800 |
commit | e4bce25aba236f4c0a5929acce15da424ea674c4 (patch) | |
tree | 8ea4d1a4c2196802ca72ce5bef166a238a3b953e | |
parent | a71001d66ada9eaf4ae89d896fea60a39ea2056b (diff) |
Cleanup and update ABI spec
5 files changed, 43 insertions, 16 deletions
diff --git a/searchlib/abi-spec.json b/searchlib/abi-spec.json index db9c2d46534..98b975546e7 100644 --- a/searchlib/abi-spec.json +++ b/searchlib/abi-spec.json @@ -1399,13 +1399,11 @@ "public void <init>(java.util.Map)", "public void <init>(java.util.Map, java.util.Map)", "public com.yahoo.searchlib.rankingexpression.ExpressionFunction getFunction(java.lang.String)", - "protected final com.google.common.collect.ImmutableMap functions()", + "protected com.google.common.collect.ImmutableMap functions()", "public java.lang.String getBinding(java.lang.String)", "public com.yahoo.searchlib.rankingexpression.rule.FunctionReferenceContext withBindings(java.util.Map)" ], - "fields": [ - "public final java.util.Map bindings" - ] + "fields": [] }, "com.yahoo.searchlib.rankingexpression.rule.GeneratorLambdaFunctionNode": { "superClass": "com.yahoo.searchlib.rankingexpression.rule.CompositeNode", @@ -1553,7 +1551,7 @@ "public void <init>()", "public void <init>(java.util.Collection)", "public void <init>(java.util.Map)", - "public void <init>(java.util.List, java.util.Map)", + "public void <init>(java.util.Collection, java.util.Map)", "public void <init>(java.util.Collection, java.util.Map, java.util.Map)", "public void <init>(com.google.common.collect.ImmutableMap, java.util.Map, java.util.Map)", "public void addFunctionSerialization(java.lang.String, java.lang.String)", diff --git a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/TensorFunctionNode.java b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/TensorFunctionNode.java index f510f38d7a7..0a67ab5534e 100644 --- a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/TensorFunctionNode.java +++ b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/TensorFunctionNode.java @@ -120,8 +120,8 @@ public class TensorFunctionNode extends CompositeNode { @Override public String toString(ToStringContext c) { ToStringContext outermost = c; - while (outermost.wrapped() != null) - outermost = outermost.wrapped(); + while (outermost.parent() != null) + outermost = outermost.parent(); if (outermost instanceof ExpressionToStringContext) { ExpressionToStringContext context = (ExpressionToStringContext)outermost; @@ -190,8 +190,8 @@ public class TensorFunctionNode extends CompositeNode { @Override public String toString(ToStringContext c) { ToStringContext outermost = c; - while (outermost.wrapped() != null) - outermost = outermost.wrapped(); + while (outermost.parent() != null) + outermost = outermost.parent(); if (outermost instanceof ExpressionToStringContext) { ExpressionToStringContext context = (ExpressionToStringContext)outermost; @@ -208,7 +208,16 @@ public class TensorFunctionNode extends CompositeNode { } - /** Allows passing serialization context arguments through TensorFunctions */ + /** + * This is used to pass a full expression serialization context through tensor functions. + * Tensor functions cannot see the full serialization context because it exposes expressions + * (which depends on the tensor module), but they need to be able to recursively add their own + * contexts (binding scopes) due to Generate binding dimension names. + * + * To be able to achieve both passing the serialization context through functions *and* allow them + * to add more context, we need to keep track of both these contexts here separately and map between + * contexts as seen in the toString methods of the function classes above. + */ private static class ExpressionToStringContext extends SerializationContext implements ToStringContext { private final ToStringContext wrappedToStringContext; @@ -258,7 +267,7 @@ public class TensorFunctionNode extends CompositeNode { protected ImmutableMap<String, ExpressionFunction> functions() { return wrappedSerializationContext.functions(); } - public ToStringContext wrapped() { return wrappedToStringContext; } + public ToStringContext parent() { return wrappedToStringContext; } /** Returns the resolution of an identifier, or null if it isn't defined in this context */ @Override diff --git a/vespajlib/abi-spec.json b/vespajlib/abi-spec.json index 8aca75ac1be..63cae3904e3 100644 --- a/vespajlib/abi-spec.json +++ b/vespajlib/abi-spec.json @@ -2495,6 +2495,21 @@ ], "fields": [] }, + "com.yahoo.tensor.functions.ToStringContext$EmptyStringContext": { + "superClass": "java.lang.Object", + "interfaces": [ + "com.yahoo.tensor.functions.ToStringContext" + ], + "attributes": [ + "public" + ], + "methods": [ + "public void <init>()", + "public java.lang.String getBinding(java.lang.String)", + "public com.yahoo.tensor.functions.ToStringContext parent()" + ], + "fields": [] + }, "com.yahoo.tensor.functions.ToStringContext": { "superClass": "java.lang.Object", "interfaces": [], @@ -2504,7 +2519,9 @@ "abstract" ], "methods": [ - "public static com.yahoo.tensor.functions.ToStringContext empty()" + "public static com.yahoo.tensor.functions.ToStringContext empty()", + "public abstract java.lang.String getBinding(java.lang.String)", + "public abstract com.yahoo.tensor.functions.ToStringContext parent()" ], "fields": [] }, diff --git a/vespajlib/src/main/java/com/yahoo/tensor/functions/Generate.java b/vespajlib/src/main/java/com/yahoo/tensor/functions/Generate.java index ac6621ce78b..fa3d70a4ddf 100644 --- a/vespajlib/src/main/java/com/yahoo/tensor/functions/Generate.java +++ b/vespajlib/src/main/java/com/yahoo/tensor/functions/Generate.java @@ -190,7 +190,7 @@ public class Generate<NAMETYPE extends Name> extends PrimitiveTensorFunction<NAM } @Override - public ToStringContext wrapped() { return context; } + public ToStringContext parent() { return context; } } diff --git a/vespajlib/src/main/java/com/yahoo/tensor/functions/ToStringContext.java b/vespajlib/src/main/java/com/yahoo/tensor/functions/ToStringContext.java index c09631d36d7..634ba4fe6ab 100644 --- a/vespajlib/src/main/java/com/yahoo/tensor/functions/ToStringContext.java +++ b/vespajlib/src/main/java/com/yahoo/tensor/functions/ToStringContext.java @@ -13,8 +13,11 @@ public interface ToStringContext { /** Returns the name an identifier is bound to, or null if not bound in this context */ String getBinding(String name); - /** Returns another context this wraps, or null if none is wrapped */ - ToStringContext wrapped(); + /** + * Returns the parent context of this (the context we're in scope of when this is created), + * or null if this is the root. + */ + ToStringContext parent(); class EmptyStringContext implements ToStringContext { @@ -22,7 +25,7 @@ public interface ToStringContext { public String getBinding(String name) { return null; } @Override - public ToStringContext wrapped() { return null; } + public ToStringContext parent() { return null; } } |