The code is in there, and complete. It's taken some time to make our entire test suite work with the new engine. As all existing tests must pass, as almost all previous behaviour must be matched. I say almost because now the work is only done when fireAllRules is called, and it does not eagerly materialise all activations.
We are almost there. I'm just ironing out some bugs on dynamic add/remove rules. Edson is working on fixing serialisation. Windows are still broken, I'll be doing those next.
To enable our existing test suite to run with the new algorithm, there is a helper method with a static global:
see line 44:
public static PhreakOption preak = PhreakOption.DISABLED;
Changing that to Enabled means all our unit tests run with Phreak - which is the name of the new algorithm. I'd give it a few more days, before running it seriously, as we have some fixes coming in. The bulk of the interesting work goes on in RuleNetworkEvaluator.java and RuleNetworkEvaluatorActivation.java.
The main network evaluation algorithm is set oriented, and processes a single rule:
It propagates LetftTupleSets:
There are now three levels of memory. PathMemory, SegmentMemory and NodeMemory - the later is what we had before with our various nodes. A Segment is 1..n nodes that have the same rule association, i.e. there is no network split between them. A Path is the segments for that rule. This is because we now organise our network into segments, and rules have shared segments. This allows you to evaluate one rule at a time, but share the results via the shared segment. So when you evaluate another rule, that has that same segment in it, the work is already done.
SegmentMemory:
PathMemory:
SegmentMemory's are initialised when their first BetaNode reveives it's input. you can see how the Segment is initialised here. Notice it's calculating the bit masks for the segment, so we can determine if a segment is populated for each of it's right inputs.
BetaNode line 319, asserttObject, you can see that inserted objects are not propagated but added to the staging list of the betanode's memory:
notice:
memory.linkNode( wm );
All rules start of unlinked, there is no beta network evaluation for them. When a segment has a facts for each right input, that segment is linked in. When each of the path memories' segments is linked in, the rule is placed onto the agenda. Notice I said rule, not activation - no beta joins have happened yet. For now I'v called these RuleNetworkEvaluatorActivation, but i could do with a better name.
After a series of inserts/updates/delete the agenda will have 1..n of this rule's on the agenda. It pops one off the RuleNetworkEvaluatorActivation. The first thing it does is cause the rule to be evaluated, line 57:
line 57 will materialise all matches for that rule, in a linked list set. It then attempts to fire each in turn, however notice it checks if another RuleNetworkEvaluatorActivation of a higher salience exists, and yields evaluation and firing to that.
It's very low level tests, but you can get an idea of the segment creation, and linking, from the unit tests (sorry if that's too low level).
Mark
Some time ago I read an email where the end of Rete with Drools was announced: Rete RIP, IIRC. Has this been postponed, and if so, which version will have the new Engine?
Cheers
Wolfgang
_______________________________________________
rules-dev mailing list
rules-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-dev