drools - Why does the order of how we specify the variables in a '==' comparison matter? -


what noticed there big performance difference changing order of variables compared '==' operator. example $variable == variable considerably slower variable == $variable. why , there similar cases one?

by way using version of optaplanner github downloaded github uses "7.0.0-snapshot" drools version.

this case in rules cross product try match variables 1 pattern in another. example:

rule "example"    when        class1(... , $var : var)        class2($var == var, ...)    end 

so when changed expression $var == var var == $var spot difference.

when comes benchmarking @ first compared in 1 rule focused on, did type of change in expressions there(the other rules deleted). afterwards applied rules.

i think happens that

class1(... , $var : var) class2(var == $var, ...) 

produces network class1 facts taken, , cartesian product class2 facts identical var field created.

in contrast,

class1(... , $var : var) class2($var == var, ...) 

"rewritten" compiler

class1(... , $var : var) $c2: class2(...) eval( $var == $c2.var ) 

creates cartesian product of class1 facts , (!) class2 facts , thereafter filters eval false.

the traditional syntax (drools 5 , earlier) forced have field name on left-hand side; later on (late 5.x, 6.x), logical expression permitted.

after speaking s.o. drools team, more accurate description might this:- attribute compared else optimization triggered. drools team take , possibly improve checking reversed expression.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -