diff options
author | Arne Juul <arnej@verizonmedia.com> | 2021-05-11 13:33:45 +0000 |
---|---|---|
committer | Arne Juul <arnej@verizonmedia.com> | 2021-05-11 13:33:45 +0000 |
commit | 188de4702809b4bb8180c9d7045559e3eae5c8fe (patch) | |
tree | a80d9dd228c78858a2115eedfb44b823b502cfa9 /config-model/src/main | |
parent | 737e1e172389288bd28b3286d49601a60e306bb8 (diff) |
also add rank properties for "constant(foo)"
* ConstantTensorTransformer was trying to handle both "foo" and "constant(foo)",
but the latter would lookup "constant" not "foo" in the map.
* add unit test for this variation also.
Diffstat (limited to 'config-model/src/main')
-rw-r--r-- | config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/ConstantTensorTransformer.java | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/ConstantTensorTransformer.java b/config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/ConstantTensorTransformer.java index 6991e2b978b..c8b4c9f7e15 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/ConstantTensorTransformer.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/ConstantTensorTransformer.java @@ -49,11 +49,17 @@ public class ConstantTensorTransformer extends ExpressionTransformer<RankProfile } private ExpressionNode transformConstantReference(ReferenceNode node, RankProfileTransformContext context) { + String constantName = node.getName(); Reference constantReference = node.reference(); - if ( ! FeatureNames.isConstantFeature(constantReference) && constantReference.isIdentifier()) - constantReference = FeatureNames.asConstantFeature(node.getName()); - - Value value = context.constants().get(node.getName()); + if (FeatureNames.isConstantFeature(constantReference)) { + constantName = constantReference.simpleArgument().orElse(null); + } else if (constantReference.isIdentifier()) { + constantReference = FeatureNames.asConstantFeature(constantName); + } else { + return node; + } + Value value = context.constants().get(constantName); + System.err.println("lookup constant: "+constantName+" -> "+value); if (value == null || value.type().rank() == 0) return node; TensorValue tensorValue = (TensorValue)value; |