[rules-users] 'from accumulate' doesn't work on multiple columns?..

Edson Tirelli tirelli at post.com
Fri Mar 9 06:05:39 EST 2007


   Vlad,

   Not sure if we are talking about the same thing here. In the current 
issue, we are not talking about "nesting" elements, but simply about 
"telling the engine" what is the domain for each of the fields you want 
to reason over. That is usually not a problem at all.
   Also, constraints that use "==" are indexed and performance is really 
good for them, those not matter how many asserted facts you have.

   I'm not the best person to discuss the implications of a "distinct" 
keyword. Maybe Mark can help on this one?

   []s
   Edson

Olenin, Vladimir (MOH) wrote:

>>Edson wrote:
>>    
>>
>-------------
>3. Regarding the distinct, I'm not sure if it would be good to have such 
>"feature". Need further discussion I guess. But on of the ways to work 
>around that is just to have a "driver" fact. I mean, if "f1" means a 
>financial account, for instance, have a Financial Account fact:
>-- End of quote
>
>Yes, that's how I'm dealing with it right now... But you (or Mark?)
>mentioned some time ago regarding similar issue ("Convert logic to DRL
>rules") that it's better to aviod this kind of 'indexing' and keep the data
>model 'flattened' since it'd allow for more optimizations on DROOLS side. In
>my case 'Record' fact has 6-7 fields and the type of rules I have would
>require to have such index on almost all these fields (which means I'd have
>to assert 'unique value' facts for each of the fields). So, I thought this
>kind of problem (as well as combination of unique fields) can be solved
>easily with having such keyword ('distinct' or 'unique' or smth like that).
>I think that even implementation should not be very difficult, since it
>would just require to get all facts of particular type and assert a new set
>of 'unique value' facts for each of the fields used in the constraint...
>Kind of preprocessing step. But I think such index (index of all fields
>within particular fact type) might already being created as part of other
>algorithms?...
>
>Vlad
>
>
>
>
>-----Original Message-----
>From: rules-users-bounces at lists.jboss.org
>[mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Edson Tirelli
>Sent: 07 March 2007 17:43
>To: Rules Users List
>Subject: Re: [rules-users] 'from accumulate' doesn't work on multiple
>columns?..
>
>  Vlad,
>
>Trying to answer both of your e-mails in this one.
>
>1. Right now, accumulate supports only a single Pattern (column), as you 
>already realized. That is a limitation we want to remove before the next 
>final release, but it is not done yet. I already know how to fix that, 
>but didn't had the time to do it yet. We are working hard in the BRMS 
>side now. If anyone is willing to help with that, I can provide the 
>instructions on how to do the implementation for that feature.
>
>2. Regarding matching the same fact multiple times in a single tuple, 
>this is a configuration. In 3.0.x, the default is to not allow the same 
>fact to be matched multiple times in a single tuple. In 3.1, the default 
>was changed to allow multiple matches. That is why your tested matched 
>multiple times. This is one of the BIG warnings we need to add to the 
>upgrade documentation.
>
>3. Regarding the distinct, I'm not sure if it would be good to have such 
>"feature". Need further discussion I guess. But on of the ways to work 
>around that is just to have a "driver" fact. I mean, if "f1" means a 
>financial account, for instance, have a Financial Account fact:
>
>rule ...
>when
>FinancialAccount( $id : id )
>Double( doubleValue > 0 ) from accumulate(
>Record( finId == $id, $f2 : f2, $val : value )
>init( double sum = 0; )
>action( sum += ( $f2 < 10 ) ? $val : -$val; )
>result( new Double( sum ) ) )
>then
>// do something
>end
>
>Hope it helps.
>
>[]s
>Edson
>
>Olenin, Vladimir (MOH) wrote:
>
>  
>
>>This is as a follow up for the previous question.... It looks like I 
>>made a wrong assumption that 'accumulate' can work on multiple columns:
>>
>>Integer ( intValue > 0) from accumulate (
>>
>>Record ( f1 == $f1, f2 < 10, $value1 : value )
>>
>>Record ( f1 == $f1, f2 >= 10, $value2 : value )
>>
>>Init ( int sum = 0; ),
>>
>>Action ( sum += $value1 - $value2 ),
>>
>>Result ( new Integer (sum) )
>>
>>)
>>
>>I'm getting an error ('then' is expected or smth like that at the 
>>point where the second 'Record' is defined) and the only way to remove 
>>the error is to declare one and only one Column constraint... So, it is 
>>not possible then to use multiple columns in 'accumulate'? If not, 
>>then it would be even more interesting to get some idea on how to 
>>approach the kind of problem I mentioned in the previous post.....
>>
>>Thanks,
>>
>>Vlad
>>
>>------------------------------------------------------------------------
>>
>>_______________________________________________
>>rules-users mailing list
>>rules-users at lists.jboss.org
>>https://lists.jboss.org/mailman/listinfo/rules-users
>> 
>>
>>    
>>
>
>
>  
>


-- 
 Edson Tirelli
 Software Engineer - JBoss Rules Core Developer
 Office: +55 11 3124-6000
 Mobile: +55 11 9218-4151
 JBoss, a division of Red Hat @ www.jboss.com





More information about the rules-users mailing list