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:
https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test/java/org/drools/compiler/CommonTestMethodBase.java

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:
https://github.com/droolsjbpm/drools/blob/master/drools-core/src/main/java/org/drools/core/phreak/RuleNetworkEvaluator.java

It propagates LetftTupleSets:
https://github.com/droolsjbpm/drools/blob/master/drools-core/src/main/java/org/drools/core/common/LeftTupleSets.java

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:
https://github.com/droolsjbpm/drools/blob/master/drools-core/src/main/java/org/drools/core/reteoo/SegmentMemory.java

PathMemory:
https://github.com/droolsjbpm/drools/blob/master/drools-core/src/main/java/org/drools/core/reteoo/PathMemory.java

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.
https://github.com/droolsjbpm/drools/blob/master/drools-core/src/main/java/org/drools/core/phreak/SegmentUtilities.java

BetaNode line 319, asserttObject, you can see that inserted objects are not propagated but added to the staging list of the betanode's memory:
https://github.com/droolsjbpm/drools/blob/master/drools-core/src/main/java/org/drools/core/reteoo/BetaNode.java

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:
https://github.com/droolsjbpm/drools/blob/master/drools-core/src/main/java/org/drools/core/phreak/RuleNetworkEvaluatorActivation.java

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).
https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test/java/org/drools/compiler/integrationtests/LinkingTest.java
https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test/java/org/drools/compiler/integrationtests/SegmentCreationTest.java
https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test/java/org/drools/compiler/integrationtests/UnlinkingTest.java
https://github.com/droolsjbpm/drools/blob/master/drools-core/src/test/java/org/drools/core/reteoo/RuleUnlinkingWithSegmentMemoryTest.java
https://github.com/droolsjbpm/drools/blob/master/drools-core/src/test/java/org/drools/core/reteoo/RuleUnlinkingTest.java
https://github.com/droolsjbpm/drools/blob/master/drools-core/src/test/java/org/drools/core/reteoo/NodeSegmentUnlinkingTest.java


Mark
On 1 May 2013, at 07:50, Wolfgang Laun <wolfgang.laun@gmail.com> wrote:

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