Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-1010

AlphNode sharing fails to propagate match to BetaNode when match is defined separate rule package

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 6.4.0.Beta2
    • 6.3.0.Final
    • core engine
    • None
    • Medium
    • NEW
    • NEW

    Description

      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();
      }

      Attachments

        Activity

          People

            mfusco@redhat.com Mario Fusco
            Anantjot.Anand Anantjot Anand (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: