Efficiently evaluating Drools for an item in an array or collection
Using Drools 3.0.6 (old I know), which is an efficient estimate for finding a fact in a known, fixed and fairly large array or collection (the inverse contains contains, that is, "is contained in"). Using a series of OR normal "equals" results in a StackOverflowError because the array / collection can contain several thousand entries because the evaluation of the binary Drools operator is recursive.
We have a single fact and an array of values to match. The current "code" looks like this:
$f: Fact(name="TheFact", $data)
eval(!($data.equals("1") || $data.equals("2") || $data.equals("3") ... ))
for a large number of fixed values (1,2,3, ...). I'm looking for something like "$ data in (1,2,3, ...)".
+1
a source to share