aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/main/javacc/RankingExpressionParser.jj
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2021-11-04 00:25:45 +0100
committerGitHub <noreply@github.com>2021-11-04 00:25:45 +0100
commit19113f6da3db1abbe8a3e36f081a0ec03f878f12 (patch)
treeecf3063c4fbde0ef6d2ece92255527aeffa27e53 /searchlib/src/main/javacc/RankingExpressionParser.jj
parent7e43b15f2e427ac08af82e2292e8649328f729e5 (diff)
parent599946ff2d1838914ffbab7d74fdbe6055187189 (diff)
Merge pull request #19855 from vespa-engine/balder/optimize-negative-constantsv7.495.22
Avoid intermediate NegativeNode in the leaf nodes, adding approximate…
Diffstat (limited to 'searchlib/src/main/javacc/RankingExpressionParser.jj')
-rwxr-xr-xsearchlib/src/main/javacc/RankingExpressionParser.jj41
1 files changed, 25 insertions, 16 deletions
diff --git a/searchlib/src/main/javacc/RankingExpressionParser.jj b/searchlib/src/main/javacc/RankingExpressionParser.jj
index 61e35647b89..0d46ab4ddb6 100755
--- a/searchlib/src/main/javacc/RankingExpressionParser.jj
+++ b/searchlib/src/main/javacc/RankingExpressionParser.jj
@@ -246,18 +246,20 @@ ExpressionNode value() :
(
[ <NOT> { not = true; } ]
[ LOOKAHEAD(2) <SUB> { neg = true; } ]
- ( value = constantPrimitive() |
- LOOKAHEAD(2) value = ifExpression() |
- LOOKAHEAD(4) value = function() |
- value = feature() |
- value = legacyQueryFeature() |
- ( <LBRACE> value = expression() <RBRACE> { value = new EmbracedNode(value); } ) )
-
+ ( value = constantPrimitive(neg) |
+ (
+ LOOKAHEAD(2) value = ifExpression() |
+ LOOKAHEAD(4) value = function() |
+ value = feature() |
+ value = legacyQueryFeature() |
+ ( <LBRACE> value = expression() <RBRACE> { value = new EmbracedNode(value); } )
+ ) { value = neg ? new NegativeNode(value) : value; }
)
- [ LOOKAHEAD(2) valueAddress = valueAddress() { value = new TensorFunctionNode(new Slice(TensorFunctionNode.wrap(value), valueAddress)); } ]
+
+ )
+ [ LOOKAHEAD(2) valueAddress = valueAddress() { value = new TensorFunctionNode(new Slice(TensorFunctionNode.wrap(value), valueAddress)); } ]
{
value = not ? new NotNode(value) : value;
- value = neg ? new NegativeNode(value) : value;
return value;
}
}
@@ -841,17 +843,24 @@ List<String> tagCommaLeadingList() :
{ return list; }
}
-ConstantNode constantPrimitive() :
+ExpressionNode constantPrimitive(boolean negate) :
{
- String sign = "";
String value;
+ ExpressionNode node;
}
{
- ( <SUB> { sign = "-";} ) ?
- ( <INTEGER> { value = token.image; } |
- <FLOAT> { value = token.image; } |
- <STRING> { value = token.image; } )
- { return new ConstantNode(Value.parse(sign + value)); }
+ ( <SUB> { negate = !negate; } ) ?
+ (
+ ( <INTEGER> { value = token.image; } |
+ <FLOAT> { value = token.image; }
+ ) { node = new ConstantNode(Value.parse(negate ? ("-" + value) : value)); } |
+ <STRING> {
+ value = token.image;
+ node = new ConstantNode(Value.parse(value));
+ if (negate) node = new NegativeNode(node);
+ }
+ )
+ { return node; }
}
Value primitiveValue() :