[jboss-jira] [JBoss JIRA] (DROOLS-1010) AlphNode sharing fails to propagate match to BetaNode when match is defined separate rule package

Anantjot Anand (JIRA) issues at jboss.org
Sat Dec 19 11:24:00 EST 2015


Anantjot Anand created DROOLS-1010:
--------------------------------------

             Summary: AlphNode sharing fails to propagate match to BetaNode when match is defined separate rule package
                 Key: DROOLS-1010
                 URL: https://issues.jboss.org/browse/DROOLS-1010
             Project: Drools
          Issue Type: Bug
          Components: core engine
    Affects Versions: 6.3.0.Final
            Reporter: Anantjot Anand
            Assignee: Mario Fusco
         Attachments: AlphaNodeSharingWithDiffPackageName.java

The issue was happening for us when LHS matches for some rules with thousands of rules in rulebase  only one rule would fire in PHREAK algo however all matches will fire in REETO. 

It turns out the root cause was that the two rules that had LHS matching criteria are defined in separate rule package name and was stemming from AlphaNode.equals returning false when it should return true. I believe underlying issue is further in MevelConstraint.equals compares the package name.

This can be reproduce using attached unit testcase.

I am not sure of the reasoning behind for the MevelConstraint.equals implementation...if it is important to keep that logic same way...following workaround has worked for me.

In class org.drools.core.reteoo.CompositeObjectSinkAdapter following function definitions..
org.drools.core.reteoo.CompositeObjectSinkAdapter.propagateModifyObject(InternalFactHandle, ModifyPreviousTuples, PropagationContext, InternalWorkingMemory)

org.drools.core.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(InternalFactHandle, PropagationContext, InternalWorkingMemory)

org.drools.core.reteoo.CompositeObjectSinkAdapter.byPassModifyToBetaNode(InternalFactHandle, ModifyPreviousTuples, PropagationContext, InternalWorkingMemory)

I changed the call from this.hashedSinkMap.get( hashKey ) to this.hashedSinkMap.getAll( hashKey ) and defined a new function as following to retrieve all alpha nodes that have same HashKey.

    public Object[] getAll(final Object key) {
        final int hashCode = this.comparator.hashCodeOf( key );
        final int index = indexOf( hashCode,
                                   this.table.length );

        List arr = new ArrayList();
        ObjectEntry current = (ObjectEntry) this.table[index];
        while ( current != null ) {
            if ( hashCode == current.cachedHashCode && this.comparator.equal( key,
                                                                        current.key ) ) {
                arr.add(current.value);
            }
            current = (ObjectEntry) current.getNext();
        }
        return arr.toArray();
    }






--
This message was sent by Atlassian JIRA
(v6.4.11#64026)


More information about the jboss-jira mailing list