From: <jbo...@li...> - 2006-05-07 23:47:24
|
Author: tirelli Date: 2006-05-07 19:47:05 -0400 (Sun, 07 May 2006) New Revision: 4115 Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/BetaLeftMemory.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/BetaMemoryFactory.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/BetaRightMemory.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/BooleanConstrainedLeftMemory.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/BooleanConstrainedRightMemory.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/DefaultLeftMemory.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/DefaultRightMemory.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/ObjectEqualConstrLeftMemory.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/ObjectEqualConstrRightMemory.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/ObjectNotEqualConstrLeftMemory.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/ObjectNotEqualConstrRightMemory.java labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/beta/BaseBetaLeftMemoryTestClass.java labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/beta/BaseBetaRightMemoryTestClass.java Log: Reversing index order creation Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/BetaLeftMemory.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/BetaLeftMemory.java 2006-05-07 20:39:41 UTC (rev 4114) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/BetaLeftMemory.java 2006-05-07 23:47:05 UTC (rev 4115) @@ -18,6 +18,8 @@ import java.util.Iterator; +import javax.naming.OperationNotSupportedException; + import org.drools.WorkingMemory; import org.drools.common.InternalFactHandle; import org.drools.reteoo.ReteTuple; @@ -136,4 +138,19 @@ * @return */ public boolean isPossibleMatch(MultiLinkedListNodeWrapper tuple); + + /** + * Sets the inner beta left memory in case of a multi-indexed memory + * + * @param innerMemory + */ + public void setInnerMemory(BetaLeftMemory innerMemory) throws OperationNotSupportedException; + + /** + * Returns the inner beta left memory in case of a multi-indexed memory + * + * @return the inner beta left memory or null in case it is not a multi-indexed memory + */ + public BetaLeftMemory getInnerMemory() throws OperationNotSupportedException; + } Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/BetaMemoryFactory.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/BetaMemoryFactory.java 2006-05-07 20:39:41 UTC (rev 4114) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/BetaMemoryFactory.java 2006-05-07 23:47:05 UTC (rev 4115) @@ -16,6 +16,8 @@ package org.drools.reteoo.beta; +import javax.naming.OperationNotSupportedException; + import org.drools.common.BetaNodeBinder; import org.drools.rule.BoundVariableConstraint; import org.drools.spi.Evaluator; @@ -31,6 +33,9 @@ */ public class BetaMemoryFactory { private static final String INDEX_DISABLED = "false"; + + public static final String INDEX_LEFT_BETA_MEMORY = "org.drools.reteoo.beta.index-left"; + public static final String INDEX_RIGHT_BETA_MEMORY = "org.drools.reteoo.beta.index-right"; protected BetaMemoryFactory() { } @@ -46,17 +51,18 @@ */ public static BetaLeftMemory newLeftMemory(BetaNodeBinder binder) { BetaLeftMemory memory = null; + BetaLeftMemory innerMostMemory = null; FieldConstraint[] constraints = (binder != null) ? binder.getConstraints() : null; - if ( (constraints != null) && (!INDEX_DISABLED.equalsIgnoreCase( System.getProperty( "org.drools.beta-indexing" ) )) ) { + if ( (constraints != null) && (!INDEX_DISABLED.equalsIgnoreCase( System.getProperty( INDEX_LEFT_BETA_MEMORY ) )) ) { for ( int i = 0; i < constraints.length; i++ ) { if ( constraints[i] instanceof BoundVariableConstraint ) { BoundVariableConstraint bvc = (BoundVariableConstraint) constraints[i]; + BetaLeftMemory innerMemory = null; switch ( bvc.getEvaluator().getType() ) { case Evaluator.BOOLEAN_TYPE : - memory = new BooleanConstrainedLeftMemory( bvc.getFieldExtractor(), + innerMemory = new BooleanConstrainedLeftMemory( bvc.getFieldExtractor(), bvc.getRequiredDeclarations()[0], - bvc.getEvaluator(), - memory ); + bvc.getEvaluator()); break; case Evaluator.OBJECT_TYPE : case Evaluator.SHORT_TYPE : @@ -65,18 +71,29 @@ case Evaluator.FLOAT_TYPE : case Evaluator.BYTE_TYPE : if ( bvc.getEvaluator().getOperator() == Evaluator.EQUAL ) { - memory = new ObjectEqualConstrLeftMemory( bvc.getFieldExtractor(), + innerMemory = new ObjectEqualConstrLeftMemory( bvc.getFieldExtractor(), bvc.getRequiredDeclarations()[0], - bvc.getEvaluator(), - memory ); + bvc.getEvaluator()); } else if ( bvc.getEvaluator().getOperator() == Evaluator.NOT_EQUAL ) { - memory = new ObjectNotEqualConstrLeftMemory( bvc.getFieldExtractor(), + innerMemory = new ObjectNotEqualConstrLeftMemory( bvc.getFieldExtractor(), bvc.getRequiredDeclarations()[0], - bvc.getEvaluator(), - memory ); + bvc.getEvaluator()); } break; } + if( innerMemory != null ) { + if (innerMostMemory != null) { + try { + innerMostMemory.setInnerMemory( innerMemory ); + innerMostMemory = innerMemory; + } catch ( OperationNotSupportedException e ) { + throw new RuntimeException("BUG: Exception was not supposed to be raised", e); + } + } else { + memory = innerMemory; + innerMostMemory = memory; + } + } } } } @@ -97,17 +114,18 @@ */ public static BetaRightMemory newRightMemory(BetaNodeBinder binder) { BetaRightMemory memory = null; + BetaRightMemory innerMostMemory = null; FieldConstraint[] constraints = (binder != null) ? binder.getConstraints() : null; - if ( (constraints != null) && (!INDEX_DISABLED.equalsIgnoreCase( System.getProperty( "org.drools.beta-indexing" ) )) ) { + if ( (constraints != null) && (!INDEX_DISABLED.equalsIgnoreCase( System.getProperty( INDEX_RIGHT_BETA_MEMORY ) )) ) { for ( int i = 0; i < constraints.length; i++ ) { if ( constraints[i] instanceof BoundVariableConstraint ) { BoundVariableConstraint bvc = (BoundVariableConstraint) constraints[i]; + BetaRightMemory innerMemory = null; switch ( bvc.getEvaluator().getType() ) { case Evaluator.BOOLEAN_TYPE : - memory = new BooleanConstrainedRightMemory( bvc.getFieldExtractor(), + innerMemory = new BooleanConstrainedRightMemory( bvc.getFieldExtractor(), bvc.getRequiredDeclarations()[0], - bvc.getEvaluator(), - memory ); + bvc.getEvaluator()); break; case Evaluator.OBJECT_TYPE : case Evaluator.SHORT_TYPE : @@ -116,18 +134,29 @@ case Evaluator.FLOAT_TYPE : case Evaluator.BYTE_TYPE : if ( bvc.getEvaluator().getOperator() == Evaluator.EQUAL ) { - memory = new ObjectEqualConstrRightMemory( bvc.getFieldExtractor(), + innerMemory = new ObjectEqualConstrRightMemory( bvc.getFieldExtractor(), bvc.getRequiredDeclarations()[0], - bvc.getEvaluator(), - memory ); + bvc.getEvaluator()); } else if ( bvc.getEvaluator().getOperator() == Evaluator.NOT_EQUAL ) { - memory = new ObjectNotEqualConstrRightMemory( bvc.getFieldExtractor(), + innerMemory = new ObjectNotEqualConstrRightMemory( bvc.getFieldExtractor(), bvc.getRequiredDeclarations()[0], - bvc.getEvaluator(), - memory ); + bvc.getEvaluator()); } break; } + if( innerMemory != null ) { + if (innerMostMemory != null) { + try { + innerMostMemory.setInnerMemory( innerMemory ); + innerMostMemory = innerMemory; + } catch ( OperationNotSupportedException e ) { + throw new RuntimeException("BUG: Exception was not supposed to be raised", e); + } + } else { + memory = innerMemory; + innerMostMemory = memory; + } + } } } } Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/BetaRightMemory.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/BetaRightMemory.java 2006-05-07 20:39:41 UTC (rev 4114) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/BetaRightMemory.java 2006-05-07 23:47:05 UTC (rev 4115) @@ -18,6 +18,8 @@ import java.util.Iterator; +import javax.naming.OperationNotSupportedException; + import org.drools.WorkingMemory; import org.drools.reteoo.ObjectMatches; import org.drools.reteoo.ReteTuple; @@ -133,4 +135,18 @@ */ public boolean isPossibleMatch(MultiLinkedListNodeWrapper matches); + /** + * Sets the inner beta right memory in case of a multi-indexed memory + * + * @param innerMemory + */ + public void setInnerMemory(BetaRightMemory innerMemory) throws OperationNotSupportedException; + + /** + * Returns the inner beta right memory in case of a multi-indexed memory + * + * @return the inner beta right memory or null in case it is not a multi-indexed memory + */ + public BetaRightMemory getInnerMemory() throws OperationNotSupportedException; + } Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/BooleanConstrainedLeftMemory.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/BooleanConstrainedLeftMemory.java 2006-05-07 20:39:41 UTC (rev 4114) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/BooleanConstrainedLeftMemory.java 2006-05-07 23:47:05 UTC (rev 4115) @@ -41,7 +41,7 @@ implements BetaLeftMemory { - private BetaLeftMemory childMemory = null; + private BetaLeftMemory innerMemory = null; private MultiLinkedList trueList = null; private MultiLinkedList falseList = null; @@ -69,7 +69,7 @@ this.declaration = declaration; this.column = declaration.getColumn(); this.evaluator = evaluator; - this.childMemory = childMemory; + this.innerMemory = childMemory; this.trueList = new MultiLinkedList(); this.falseList = new MultiLinkedList(); } @@ -87,9 +87,9 @@ } else { falseList.add( tuple ); } - if ( this.childMemory != null ) { + if ( this.innerMemory != null ) { tuple.setChild( new MultiLinkedListNodeWrapper( tuple ) ); - this.childMemory.add( workingMemory, + this.innerMemory.add( workingMemory, ((MultiLinkedListNodeWrapper) tuple.getChild()) ); } } @@ -101,8 +101,8 @@ */ public final void remove(WorkingMemory workingMemory, ReteTuple tuple) { - if ( this.childMemory != null ) { - this.childMemory.remove( workingMemory, + if ( this.innerMemory != null ) { + this.innerMemory.remove( workingMemory, (MultiLinkedListNodeWrapper) tuple.getChild() ); } tuple.getLinkedList().remove( tuple ); @@ -121,9 +121,9 @@ } else { falseList.add( tuple ); } - if ( this.childMemory != null ) { + if ( this.innerMemory != null ) { tuple.setChild( new MultiLinkedListNodeWrapper( tuple.getNode() ) ); - this.childMemory.add( workingMemory, + this.innerMemory.add( workingMemory, ((MultiLinkedListNodeWrapper) tuple.getChild()) ); } } @@ -135,8 +135,8 @@ */ public final void remove(WorkingMemory workingMemory, MultiLinkedListNodeWrapper tuple) { - if ( this.childMemory != null ) { - this.childMemory.remove( workingMemory, + if ( this.innerMemory != null ) { + this.innerMemory.remove( workingMemory, (MultiLinkedListNodeWrapper) tuple.getChild() ); } tuple.getLinkedList().remove( tuple ); @@ -169,7 +169,7 @@ boolean hasnext = false; if ( next == null ) { while ( candidate != null ) { - if ( (childMemory == null) || (childMemory.isPossibleMatch( (MultiLinkedListNodeWrapper) candidate.getChild() )) ) { + if ( (innerMemory == null) || (innerMemory.isPossibleMatch( (MultiLinkedListNodeWrapper) candidate.getChild() )) ) { hasnext = true; next = candidate; candidate = (MultiLinkedListNode) candidate.getNext(); @@ -287,8 +287,8 @@ } else { this.selectedList = falseList; } - if ( this.childMemory != null ) { - this.childMemory.selectPossibleMatches( workingMemory, + if ( this.innerMemory != null ) { + this.innerMemory.selectPossibleMatches( workingMemory, handle ); } } @@ -300,8 +300,8 @@ */ public final boolean isPossibleMatch(MultiLinkedListNodeWrapper tuple) { boolean isPossible = ((this.selectedList != null) && (tuple.getLinkedList() == this.selectedList)); - if ( (isPossible) && (this.childMemory != null) ) { - isPossible = this.childMemory.isPossibleMatch( (MultiLinkedListNodeWrapper) tuple.getChild() ); + if ( (isPossible) && (this.innerMemory != null) ) { + isPossible = this.innerMemory.isPossibleMatch( (MultiLinkedListNodeWrapper) tuple.getChild() ); } return isPossible; } @@ -310,4 +310,18 @@ return this.trueList.size() + this.falseList.size(); } + /** + * @inheritDoc + */ + public BetaLeftMemory getInnerMemory() { + return innerMemory; + } + + /** + * @inheritDoc + */ + public void setInnerMemory(BetaLeftMemory innerMemory) { + this.innerMemory = innerMemory; + } + } Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/BooleanConstrainedRightMemory.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/BooleanConstrainedRightMemory.java 2006-05-07 20:39:41 UTC (rev 4114) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/BooleanConstrainedRightMemory.java 2006-05-07 23:47:05 UTC (rev 4115) @@ -43,7 +43,7 @@ implements BetaRightMemory { - private BetaRightMemory childMemory = null; + private BetaRightMemory innerMemory = null; private MultiLinkedList trueList = null; private MultiLinkedList falseList = null; @@ -71,7 +71,7 @@ this.declaration = declaration; this.column = declaration.getColumn(); this.evaluator = evaluator; - this.childMemory = childMemory; + this.innerMemory = childMemory; this.trueList = new MultiLinkedList(); this.falseList = new MultiLinkedList(); } @@ -87,9 +87,9 @@ matches.getFactHandle() ); list.add( matches ); - if ( this.childMemory != null ) { + if ( this.innerMemory != null ) { matches.setChild( new MultiLinkedListNodeWrapper( matches ) ); - this.childMemory.add( workingMemory, + this.innerMemory.add( workingMemory, (MultiLinkedListNodeWrapper) matches.getChild() ); } @@ -103,8 +103,8 @@ */ public final void remove(WorkingMemory workingMemory, ObjectMatches matches) { - if ( this.childMemory != null ) { - this.childMemory.remove( workingMemory, + if ( this.innerMemory != null ) { + this.innerMemory.remove( workingMemory, (MultiLinkedListNodeWrapper) matches.getChild() ); } matches.getLinkedList().remove( matches ); @@ -123,9 +123,9 @@ matches.getFactHandle() ); list.add( wrapper ); - if ( this.childMemory != null ) { + if ( this.innerMemory != null ) { wrapper.setChild( new MultiLinkedListNodeWrapper( matches ) ); - this.childMemory.add( workingMemory, + this.innerMemory.add( workingMemory, (MultiLinkedListNodeWrapper) wrapper.getChild() ); } } @@ -138,8 +138,8 @@ */ public final void remove(WorkingMemory workingMemory, MultiLinkedListNodeWrapper wrapper) { - if ( this.childMemory != null ) { - this.childMemory.remove( workingMemory, + if ( this.innerMemory != null ) { + this.innerMemory.remove( workingMemory, (MultiLinkedListNodeWrapper) wrapper.getChild() ); } wrapper.getLinkedList().remove( wrapper ); @@ -163,7 +163,7 @@ boolean hasnext = false; if ( next == null ) { while ( candidate != null ) { - if ( (childMemory == null) || (childMemory.isPossibleMatch( (MultiLinkedListNodeWrapper) candidate.getChild() )) ) { + if ( (innerMemory == null) || (innerMemory.isPossibleMatch( (MultiLinkedListNodeWrapper) candidate.getChild() )) ) { hasnext = true; next = candidate; candidate = (ObjectMatches) candidate.getNext(); @@ -218,8 +218,8 @@ select = (evaluator.getOperator()) == Evaluator.EQUAL ? select : !select; this.selectedList = (select == true) ? trueList : falseList; - if ( this.childMemory != null ) { - this.childMemory.selectPossibleMatches( workingMemory, + if ( this.innerMemory != null ) { + this.innerMemory.selectPossibleMatches( workingMemory, tuple ); } } @@ -234,8 +234,8 @@ boolean ret = false; if ( this.selectedList != null ) { ret = matches.getLinkedList() == this.selectedList; - if ( ret && (this.childMemory != null) ) { - ret = this.childMemory.isPossibleMatch( (MultiLinkedListNodeWrapper) matches.getChild() ); + if ( ret && (this.innerMemory != null) ) { + ret = this.innerMemory.isPossibleMatch( (MultiLinkedListNodeWrapper) matches.getChild() ); } } return ret; @@ -288,4 +288,19 @@ return set.iterator(); } + /** + * @inheritDoc + */ + public BetaRightMemory getInnerMemory() { + return innerMemory; + } + + /** + * @inheritDoc + */ + public void setInnerMemory(BetaRightMemory innerMemory) { + this.innerMemory = innerMemory; + } + + } Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/DefaultLeftMemory.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/DefaultLeftMemory.java 2006-05-07 20:39:41 UTC (rev 4114) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/DefaultLeftMemory.java 2006-05-07 23:47:05 UTC (rev 4115) @@ -18,6 +18,8 @@ import java.util.Iterator; +import javax.naming.OperationNotSupportedException; + import org.drools.WorkingMemory; import org.drools.common.InternalFactHandle; import org.drools.reteoo.ReteTuple; @@ -121,5 +123,18 @@ return this.memory.size(); } + /** + * @inheritDoc + */ + public BetaLeftMemory getInnerMemory() throws OperationNotSupportedException { + throw new OperationNotSupportedException("Default left memory does not support inner memory"); + } + /** + * @inheritDoc + */ + public void setInnerMemory(BetaLeftMemory innerMemory) throws OperationNotSupportedException { + throw new OperationNotSupportedException("Default left memory does not support inner memory"); + } + } Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/DefaultRightMemory.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/DefaultRightMemory.java 2006-05-07 20:39:41 UTC (rev 4114) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/DefaultRightMemory.java 2006-05-07 23:47:05 UTC (rev 4115) @@ -18,6 +18,8 @@ import java.util.Iterator; +import javax.naming.OperationNotSupportedException; + import org.drools.WorkingMemory; import org.drools.reteoo.ObjectMatches; import org.drools.reteoo.ReteTuple; @@ -145,4 +147,18 @@ return memory.iterator(); } + /** + * @inheritDoc + */ + public BetaRightMemory getInnerMemory() throws OperationNotSupportedException { + throw new OperationNotSupportedException("Default right memory does not support inner memory"); + } + + /** + * @inheritDoc + */ + public void setInnerMemory(BetaRightMemory innerMemory) throws OperationNotSupportedException { + throw new OperationNotSupportedException("Default right memory does not support inner memory"); + } + } Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/ObjectEqualConstrLeftMemory.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/ObjectEqualConstrLeftMemory.java 2006-05-07 20:39:41 UTC (rev 4114) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/ObjectEqualConstrLeftMemory.java 2006-05-07 23:47:05 UTC (rev 4115) @@ -47,7 +47,7 @@ implements BetaLeftMemory { - private BetaLeftMemory childMemory = null; + private BetaLeftMemory innerMemory = null; private Map memoryMap = null; private int size = 0; @@ -73,7 +73,7 @@ this.extractor = extractor; this.declaration = declaration; this.column = declaration.getColumn(); - this.childMemory = childMemory; + this.innerMemory = childMemory; this.memoryMap = new HashMap(); } @@ -88,9 +88,9 @@ tuple ); list.add( tuple ); this.size++; - if ( this.childMemory != null ) { + if ( this.innerMemory != null ) { tuple.setChild( new MultiLinkedListNodeWrapper( tuple ) ); - this.childMemory.add( workingMemory, + this.innerMemory.add( workingMemory, ((MultiLinkedListNodeWrapper) tuple.getChild()) ); } } @@ -102,8 +102,8 @@ */ public final void remove(WorkingMemory workingMemory, ReteTuple tuple) { - if ( this.childMemory != null ) { - this.childMemory.remove( workingMemory, + if ( this.innerMemory != null ) { + this.innerMemory.remove( workingMemory, (MultiLinkedListNodeWrapper) tuple.getChild() ); } LinkedList list = tuple.getLinkedList(); @@ -128,9 +128,9 @@ list.add( tuple ); this.size++; - if ( this.childMemory != null ) { + if ( this.innerMemory != null ) { tuple.setChild( new MultiLinkedListNodeWrapper( tuple.getNode() ) ); - this.childMemory.add( workingMemory, + this.innerMemory.add( workingMemory, ((MultiLinkedListNodeWrapper) tuple.getChild()) ); } } @@ -142,8 +142,8 @@ */ public final void remove(WorkingMemory workingMemory, MultiLinkedListNodeWrapper tuple) { - if ( this.childMemory != null ) { - this.childMemory.remove( workingMemory, + if ( this.innerMemory != null ) { + this.innerMemory.remove( workingMemory, (MultiLinkedListNodeWrapper) tuple.getChild() ); } @@ -186,7 +186,7 @@ boolean hasnext = false; if ( next == null ) { while ( candidate != null ) { - if ( (childMemory == null) || (childMemory.isPossibleMatch( (MultiLinkedListNodeWrapper) candidate.getChild() )) ) { + if ( (innerMemory == null) || (innerMemory.isPossibleMatch( (MultiLinkedListNodeWrapper) candidate.getChild() )) ) { hasnext = true; next = candidate; candidate = (MultiLinkedListNode) candidate.getNext(); @@ -260,8 +260,8 @@ Integer hash = (select != null) ? new Integer( select.hashCode() ) : new Integer( 0 ); this.selectedList = (MultiLinkedList) this.memoryMap.get( hash ); - if ( this.childMemory != null ) { - this.childMemory.selectPossibleMatches( workingMemory, + if ( this.innerMemory != null ) { + this.innerMemory.selectPossibleMatches( workingMemory, handle ); } } @@ -354,4 +354,17 @@ } } + /** + * @inheritDoc + */ + public BetaLeftMemory getInnerMemory() { + return innerMemory; + } + + /** + * @inheritDoc + */ + public void setInnerMemory(BetaLeftMemory innerMemory) { + this.innerMemory = innerMemory; + } } Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/ObjectEqualConstrRightMemory.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/ObjectEqualConstrRightMemory.java 2006-05-07 20:39:41 UTC (rev 4114) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/ObjectEqualConstrRightMemory.java 2006-05-07 23:47:05 UTC (rev 4115) @@ -47,7 +47,7 @@ implements BetaRightMemory { - private BetaRightMemory childMemory = null; + private BetaRightMemory innerMemory = null; private Map memoryMap = null; private int memorySize = 0; @@ -74,7 +74,7 @@ this.extractor = extractor; this.declaration = declaration; this.column = declaration.getColumn(); - this.childMemory = childMemory; + this.innerMemory = childMemory; this.memoryMap = new HashMap(); } @@ -91,9 +91,9 @@ list.add( matches ); this.memorySize++; - if ( this.childMemory != null ) { + if ( this.innerMemory != null ) { matches.setChild( new MultiLinkedListNodeWrapper( matches ) ); - this.childMemory.add( workingMemory, + this.innerMemory.add( workingMemory, (MultiLinkedListNodeWrapper) matches.getChild() ); } } @@ -106,8 +106,8 @@ */ public final void remove(WorkingMemory workingMemory, ObjectMatches matches) { - if ( this.childMemory != null ) { - this.childMemory.remove( workingMemory, + if ( this.innerMemory != null ) { + this.innerMemory.remove( workingMemory, (MultiLinkedListNodeWrapper) matches.getChild() ); } KeyMultiLinkedList list = (KeyMultiLinkedList) matches.getLinkedList(); @@ -133,9 +133,9 @@ list.add( wrapper ); this.memorySize++; - if ( this.childMemory != null ) { + if ( this.innerMemory != null ) { wrapper.setChild( new MultiLinkedListNodeWrapper( matches ) ); - this.childMemory.add( workingMemory, + this.innerMemory.add( workingMemory, (MultiLinkedListNodeWrapper) wrapper.getChild() ); } } @@ -148,8 +148,8 @@ */ public final void remove(WorkingMemory workingMemory, MultiLinkedListNodeWrapper matches) { - if ( this.childMemory != null ) { - this.childMemory.remove( workingMemory, + if ( this.innerMemory != null ) { + this.innerMemory.remove( workingMemory, (MultiLinkedListNodeWrapper) matches.getChild() ); } KeyMultiLinkedList list = (KeyMultiLinkedList) matches.getLinkedList(); @@ -180,7 +180,7 @@ boolean hasnext = false; if ( next == null ) { while ( candidate != null ) { - if ( (childMemory == null) || (childMemory.isPossibleMatch( (MultiLinkedListNodeWrapper) candidate.getChild() )) ) { + if ( (innerMemory == null) || (innerMemory.isPossibleMatch( (MultiLinkedListNodeWrapper) candidate.getChild() )) ) { hasnext = true; next = candidate; candidate = (ObjectMatches) candidate.getNext(); @@ -236,8 +236,8 @@ Integer hash = (select != null) ? new Integer( select.hashCode() ) : new Integer( 0 ); this.selectedList = (MultiLinkedList) this.memoryMap.get( hash ); - if ( this.childMemory != null ) { - this.childMemory.selectPossibleMatches( workingMemory, + if ( this.innerMemory != null ) { + this.innerMemory.selectPossibleMatches( workingMemory, tuple ); } } @@ -246,8 +246,8 @@ boolean ret = false; if ( this.selectedList != null ) { ret = wrapper.getLinkedList() == this.selectedList; - if ( ret && (this.childMemory != null) ) { - ret = this.childMemory.isPossibleMatch( (MultiLinkedListNodeWrapper) wrapper.getChild() ); + if ( ret && (this.innerMemory != null) ) { + ret = this.innerMemory.isPossibleMatch( (MultiLinkedListNodeWrapper) wrapper.getChild() ); } } return ret; @@ -324,6 +324,20 @@ return set.iterator(); } + /** + * @inheritDoc + */ + public BetaRightMemory getInnerMemory() { + return innerMemory; + } + + /** + * @inheritDoc + */ + public void setInnerMemory(BetaRightMemory innerMemory) { + this.innerMemory = innerMemory; + } + private static class KeyMultiLinkedList extends MultiLinkedList { private final Object key; @@ -335,4 +349,6 @@ return this.key; } } + + } Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/ObjectNotEqualConstrLeftMemory.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/ObjectNotEqualConstrLeftMemory.java 2006-05-07 20:39:41 UTC (rev 4114) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/ObjectNotEqualConstrLeftMemory.java 2006-05-07 23:47:05 UTC (rev 4115) @@ -340,6 +340,20 @@ return ret; } + /** + * @inheritDoc + */ + public BetaLeftMemory getInnerMemory() { + return innerMemory; + } + + /** + * @inheritDoc + */ + public void setInnerMemory(BetaLeftMemory innerMemory) { + this.innerMemory = innerMemory; + } + private static class KeyMultiLinkedList extends MultiLinkedList { private final Object key; Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/ObjectNotEqualConstrRightMemory.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/ObjectNotEqualConstrRightMemory.java 2006-05-07 20:39:41 UTC (rev 4114) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/beta/ObjectNotEqualConstrRightMemory.java 2006-05-07 23:47:05 UTC (rev 4115) @@ -43,7 +43,7 @@ implements BetaRightMemory { - private BetaRightMemory childMemory = null; + private BetaRightMemory innerMemory = null; private Map memoryMap = null; private MultiLinkedList memoryMasterList = null; @@ -69,7 +69,7 @@ this.extractor = extractor; this.declaration = declaration; this.column = declaration.getColumn(); - this.childMemory = childMemory; + this.innerMemory = childMemory; this.memoryMap = new HashMap(); this.memoryMasterList = new MultiLinkedList(); } @@ -94,10 +94,10 @@ matches.getFactHandle() ); list.add( wrapper ); - if ( this.childMemory != null ) { + if ( this.innerMemory != null ) { // Adding to inner indexes wrapper.setChild( new MultiLinkedListNodeWrapper( matches ) ); - this.childMemory.add( workingMemory, + this.innerMemory.add( workingMemory, (MultiLinkedListNodeWrapper) wrapper.getChild() ); } } @@ -110,9 +110,9 @@ */ public final void remove(WorkingMemory workingMemory, ObjectMatches matches) { - if ( this.childMemory != null ) { + if ( this.innerMemory != null ) { // removing from inner indexes - this.childMemory.remove( workingMemory, + this.innerMemory.remove( workingMemory, (MultiLinkedListNodeWrapper) matches.getChild().getChild() ); matches.getChild().setChild( null ); } @@ -152,10 +152,10 @@ om.getFactHandle() ); list.add( wrapper ); - if ( this.childMemory != null ) { + if ( this.innerMemory != null ) { // Adding to inner indexes wrapper.setChild( new MultiLinkedListNodeWrapper( om ) ); - this.childMemory.add( workingMemory, + this.innerMemory.add( workingMemory, (MultiLinkedListNodeWrapper) wrapper.getChild() ); } } @@ -168,9 +168,9 @@ */ public final void remove(WorkingMemory workingMemory, MultiLinkedListNodeWrapper matches) { - if ( this.childMemory != null ) { + if ( this.innerMemory != null ) { // removing from inner indexes - this.childMemory.remove( workingMemory, + this.innerMemory.remove( workingMemory, (MultiLinkedListNodeWrapper) matches.getChild().getChild() ); matches.getChild().setChild( null ); } @@ -208,7 +208,7 @@ if ( next == null ) { while ( candidate != null ) { if ( candidate.getChild().getLinkedList() != noMatchList ) { - if ( (childMemory == null) || (childMemory.isPossibleMatch( (MultiLinkedListNodeWrapper) candidate.getChild().getChild() )) ) { + if ( (innerMemory == null) || (innerMemory.isPossibleMatch( (MultiLinkedListNodeWrapper) candidate.getChild().getChild() )) ) { hasnext = true; next = candidate; candidate = (ObjectMatches) candidate.getNext(); @@ -263,8 +263,8 @@ Integer hash = (select != null) ? new Integer( select.hashCode() ) : new Integer( 0 ); this.noMatchList = (MultiLinkedList) this.memoryMap.get( hash ); - if ( this.childMemory != null ) { - this.childMemory.selectPossibleMatches( workingMemory, + if ( this.innerMemory != null ) { + this.innerMemory.selectPossibleMatches( workingMemory, tuple ); } } @@ -279,8 +279,8 @@ if ( (matches != null) && (matches.getChild() != null) && (matches.getChild().getLinkedList() != null) ) { ret = (matches.getChild().getLinkedList() != noMatchList); - if ( ret && (this.childMemory != null) ) { - ret = this.childMemory.isPossibleMatch( (MultiLinkedListNodeWrapper) matches.getChild().getChild() ); + if ( ret && (this.innerMemory != null) ) { + ret = this.innerMemory.isPossibleMatch( (MultiLinkedListNodeWrapper) matches.getChild().getChild() ); } } return ret; @@ -347,6 +347,20 @@ return this.memoryMasterList.iterator(); } + /** + * @inheritDoc + */ + public BetaRightMemory getInnerMemory() { + return innerMemory; + } + + /** + * @inheritDoc + */ + public void setInnerMemory(BetaRightMemory innerMemory) { + this.innerMemory = innerMemory; + } + private static class KeyMultiLinkedList extends MultiLinkedList { private final Object key; Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/beta/BaseBetaLeftMemoryTestClass.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/beta/BaseBetaLeftMemoryTestClass.java 2006-05-07 20:39:41 UTC (rev 4114) +++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/beta/BaseBetaLeftMemoryTestClass.java 2006-05-07 23:47:05 UTC (rev 4115) @@ -18,6 +18,8 @@ import java.util.Iterator; +import javax.naming.OperationNotSupportedException; + import junit.framework.Assert; import junit.framework.TestCase; @@ -428,6 +430,13 @@ public int getCounter() { return this.callCounter; } + + public BetaLeftMemory getInnerMemory() throws OperationNotSupportedException { + return null; + } + + public void setInnerMemory(BetaLeftMemory innerMemory) throws OperationNotSupportedException { + } }; } Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/beta/BaseBetaRightMemoryTestClass.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/beta/BaseBetaRightMemoryTestClass.java 2006-05-07 20:39:41 UTC (rev 4114) +++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/beta/BaseBetaRightMemoryTestClass.java 2006-05-07 23:47:05 UTC (rev 4115) @@ -18,6 +18,8 @@ import java.util.Iterator; +import javax.naming.OperationNotSupportedException; + import junit.framework.Assert; import junit.framework.TestCase; @@ -424,5 +426,12 @@ public int getCounter() { return this.callCounter; } + + public BetaRightMemory getInnerMemory() throws OperationNotSupportedException { + return null; + } + + public void setInnerMemory(BetaRightMemory innerMemory) throws OperationNotSupportedException { + } } } |