Drools RETE algorithm confusion

833 views Asked by At

I am having an issue understanding RETE algorithm Beta node JoinNode and notNode?

enter image description here

Documentation says :

There are two two-input nodes, JoinNode and NotNode, and both are types of BetaNodes. BetaNodes are used to compare 2 objects, and their fields, to each other. The objects may be the same or different types. By convention, we refer to the two inputs as left and right. The left input for a BetaNode is generally a list of objects; in Drools this is a Tuple. The right input is a single object. Two Nodes can be used to implement 'exists' checks. BetaNodes also have memory. The left input is called the Beta Memory and remembers all incoming tuples. The right input is called the Alpha Memory and remembers all incoming objects.

I understood, Alpha Node: Various literal conditions for drl rules but above documentation for BetaNodes is confusing me a bit.

say below is drl condition for above diagram:

$person : Person( favouriteCheese == $cheddar )

Query: 1) what are these left and right inputs to two-input Beta Nodes exactly as explained in above documentation? I believe it's referring to facts and rules where I believe tuples would be facts?

2) notNode would be basically drl condition matching literal condition with not?

Updated question on 6Sep17:

3) I believe above diagram represent joinNode, how would notNode be represented , if above workflow is altered to suit notNode?

1

There are 1 answers

5
laune On

The condition corresponding to the diagram would be

Cheese( $name: name == "Cheddar" )
Person( favouriteCheese == $name )

Once there is a match, a new tuple consisting of the matching Cheese and Person is composed and can act as a new tuple for further matches if there is a third pattern in the condition.

A not-node would be one that asserts the non-existence of some fact. It would fire only once.

You might find a much better description of "rete" on the web.