[jboss-jira] [JBoss JIRA] Closed: (JBRULES-2108) Iterator only returns first bucket for shared table elements

Mark Proctor (JIRA) jira-events at lists.jboss.org
Tue Apr 6 22:39:38 EDT 2010


     [ https://jira.jboss.org/jira/browse/JBRULES-2108?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mark Proctor closed JBRULES-2108.
---------------------------------

    Resolution: Done


The patch doesn't quite work either, but I've applied something that should do the job. I've also added two unit tests that for this specific problem that should be easy to update should we find any more corner cases.
LeftTupleIndexedHasthTableIteratorTest
RightTupleIndexedHasthTableIteratorTest

> Iterator only returns first bucket for shared table elements
> ------------------------------------------------------------
>
>                 Key: JBRULES-2108
>                 URL: https://jira.jboss.org/jira/browse/JBRULES-2108
>             Project: Drools
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: drools-core
>    Affects Versions: 4.0.7
>            Reporter: Andrey Nechaev
>            Assignee: Mark Proctor
>             Fix For: 5.1.0.M2
>
>         Attachments: patch
>
>
> The following code shows the problem:
> public class DroolsTest {
> 	private final static int NUM_FACTS = 20;
> 	private final static String rule = "" + 
> 		"package test\n" + 
> 		"import com.test.DroolsTest;\n" + 
> 		"import com.test.DroolsTest.Foo;\n" +
> 		"import com.test.DroolsTest.Bar;\n" +
> 		"rule test\n" + 
> 			"\twhen\n" + 
> 				"\t\tFoo($p : id < " + Integer.toString(NUM_FACTS) + ") && Bar(id == $p)\n" +
> 			"\tthen\n" +
> 				"\t\tDroolsTest.incCounter();\n" +
> 		"end";
> 	
> 	private static int counter;
> 	
> 	public static class Foo {
> 		private final int id;
> 		
> 		Foo(int id) {
> 			this.id = id;
> 		}
> 		
> 		public int getId() {
> 			return id;
> 		}
> 	}
> 	
> 	public static class Bar {
> 		private final int id;
> 		
> 		Bar(int id) {
> 			this.id = id;
> 		}
> 		
> 		public int getId() {
> 			return id;
> 		}
> 	}
> 	
> 	public static void main(String[] args) throws Exception {
> 		RuleBase rb;
> 		WorkingMemory wm;
> 		counter = 0;
> 		
> 		rb = RuleBaseFactory.newRuleBase();
> 		wm = rb.newStatefulSession();
> 				
> 		for(int i = 0; i < NUM_FACTS; i++) {
> 			wm.insert(new Foo(i));
> 			wm.insert(new Bar(i));
> 		}
> 		PackageBuilder bld = new PackageBuilder();
> 		bld.addPackageFromDrl(new StringReader(rule));
> 		
> 		rb.addPackage(bld.getPackage());
> 		System.out.println(counter == NUM_FACTS ? "passed" : "failed");
> 	}
> 	
> 	public static void incCounter() {
> 		++counter;
> 	}
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the jboss-jira mailing list