[jboss-jira] [JBoss JIRA] Commented: (JBRULES-812) Indexing failing when more than 3 indexable constraints are specified

Pierre Paysant-Le Roux (JIRA) jira-events at lists.jboss.org
Mon Apr 23 13:09:30 EDT 2007


    [ http://jira.jboss.com/jira/browse/JBRULES-812?page=comments#action_12360244 ] 
            
Pierre Paysant-Le Roux commented on JBRULES-812:
------------------------------------------------

The revision #11167 introduced a bug. Skipping indexed constraints in DefaultBetaConstaints is not complete. If I understoud, you have to skip the contexts of indexed constaints to. Else, the "isAllowedCachedRight" (line 141) is made with the wrong context.
Here is a patch with the changes I made, that fixes the problem in my case :

Index: drools-core/src/main/java/org/drools/common/DefaultBetaConstraints.java
===================================================================
--- drools-core/src/main/java/org/drools/common/DefaultBetaConstraints.java	(revision 11243)
+++ drools-core/src/main/java/org/drools/common/DefaultBetaConstraints.java	(working copy)
@@ -105,6 +105,14 @@
         }
         return current;
     }
+    
+    private ContextEntry findContext(final int pos) {
+    	ContextEntry current = this.contexts;
+    	for( int i = 0 ; i < pos ; i++) {
+    		current = current.getNext();
+    	}
+    	return current;
+    }

     private boolean isIndexable(final BetaNodeFieldConstraint constraint) {
         if ( constraint instanceof VariableConstraint ) {
@@ -144,7 +152,7 @@
         // skip the indexed constraints
         LinkedListEntry entry = (LinkedListEntry) findNode( this.indexed );
         
-        ContextEntry context = this.contexts;
+        ContextEntry context = findContext(this.indexed);
         while ( entry != null ) {
             if ( !((BetaNodeFieldConstraint) entry.getObject()).isAllowedCachedLeft( context,
                                                                                      object ) ) {

@@ -163,7 +171,7 @@
         // skip the indexed constraints
         LinkedListEntry entry = (LinkedListEntry) findNode( this.indexed );
         
-        ContextEntry context = this.contexts;
+        ContextEntry context = findContext( this.indexed );
         while ( entry != null ) {
             if ( !((BetaNodeFieldConstraint) entry.getObject()).isAllowedCachedRight( tuple,
                                                                                       context ) ) {

There is also a problem with the DefaultBetaConstraints constructor. If the first constraint is indexable, it is inserted in the empty LinkedList with the insertAfter method. That throws a NullPointerException (See ticket 722).

> Indexing failing when more than 3 indexable constraints are specified
> ---------------------------------------------------------------------
>
>                 Key: JBRULES-812
>                 URL: http://jira.jboss.com/jira/browse/JBRULES-812
>             Project: JBoss Rules
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: Reteoo
>    Affects Versions: 3.1-m1
>            Reporter: Edson Tirelli
>         Assigned To: Edson Tirelli
>             Fix For: 3.1-m2
>
>
> Guys, repeating a query from someone who perhaps didn't write it that clearly (chinese):
> If they try the following condition:
> varclu : cluster(clusterid==v_cluster
> _id, transitionid==v_transition, stateid==v_state,ruleid==v_rule_id, v_evtid : evtid, v_evttype : evttype, v_srcaddress : srcaddress, v_destaddress : destaddress, v_timestamp : timestamp, v_alertid : alertid)" .
> It blows up with "There cannot be more than 3 indexes"
> Which is due to QuadroupleBetaConstraints not dealing with that many indexes.
> When he deletes one equality ,such as "ruleid==v_rule_id", and then add "eval(varclu.getRuleid()==v_rule_id)", it works - so it looks like a bug/limitation to the current approach. 

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

        



More information about the jboss-jira mailing list