tkobayas commented on code in PR #6354:
URL:
https://github.com/apache/incubator-kie-drools/pull/6354#discussion_r2102111811
##########
drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/execmodel/generator/operatorspec/CustomOperatorWrapper.java:
##########
@@ -35,7 +35,8 @@ public CustomOperatorWrapper( Evaluator evaluator, String
name ) {
@Override
public boolean eval( Object o1, Object o2 ) {
- return evaluator.evaluate(null, null, dummyFactHandleOf(o2), null,
dummyFactHandleOf(o1));
+ // o1 and o2 are the left and right operands of the expression, so
this order. (See Evaluator.evaluate)
+ return evaluator.evaluate(null, null, dummyFactHandleOf(o1), null,
dummyFactHandleOf(o2));
Review Comment:
This is an important change. I had to fix this order to pass both exec-model
and non-exec-model custom operator tests.
The tricky part is that we often use the words `left` and `right` for "left
input" and "right input" to a JoinNode, where "left input" becomes "right
operand" of an expression and "right input" becomes "left operand" of the
expression. However, in this case, `o1` and `o2` are "left operand" and "right
operand" of the expression. Then, the method `Evaluator.evaluate(ValueResolver,
ReadAccessor, FactHandle, ReadAccessor, FactHandle)` expects such "operand"
order. Other impl classes follow the order (e.g. `ObjectContainsEvaluator`). So
I changed this `CustomOperatorWrapper` accordingly. Now the javadoc for the
`Evaluator.evaluate` method looks inconsistent (explains left/right "input"),
so I changed the javadoc, too (changed to left/right "operand"). I fixed the
unit tests' custom operators in the same way.
@mariofusco Does this change make sense? Please share your thoughts. Thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]