The suggested workaround (before this was fixed) is to use
count(1)
which achieves the same effect.
-W
On 11 November 2010 19:30, <rouvas(a)di.uoa.gr> wrote:
> Hi List,
>
> I'm trying to count the number of objects I have in the Working Memory
> using accumulate, but I'm having a ClassCastException thrown at me.
>
> Using a variant with collect, everything work OK.
>
> Can someone shed some light on this issue?
> Is it related to
https://jira.jboss.org/browse/JBRULES-2202 ?
>
> I'm using Drools.5.0.1 and the fact is a declared one, as follows:
>
> declare t_1
> regRowId : String
> versionId : String
> c_7 : String
> c_1 : String
> c_2 : String
> c_3 : String
> c_4 : String
> c_5 : String
> c_6 : Double
> end
>
> trying with :
>
> v945 : Number ( doubleValue >= 1 ) from accumulate ( p : t_1 ( c_6 >=
> 20100511 && c_7 == "5" ) , count(p) )
>
> I'm getting a ClassCastException:t_1, while using :
>
> v945 : ArrayList ( size >= 1 ) from collect ( t_1 ( c_6 >= 20100511
> &&
> c_7 == "5" ) )
>
> works OK.
>
> The reason I'm preferring accumulate over collect, is that I'm not
> really
> interested in constructing an ArrayList of the matched facts (worries
> about memory consumption), all I want is how many of them are there.
>
> The actual rule I'm using (although I don't think it matters) for the
> accumulate variant, is:
>
> rule "r95944.6"
> dialect "mvel"
> when
> gnId : GoodNumbers()
> LogicalValue : Trader( gnId.goodNo==goodNo )
> v945 : Number ( doubleValue >= 1 ) from accumulate ( p
> : t_1 ( c_6
>>= 20100511 && c_7 == "5" ) , count(p) )
> then
> RaResultCode rrc = new RaResultCode();
> rrc.setResultRuleId("95944");
> rrc.setResultRuleVersionId("6");
> rrc.setResultColor("R");
> rrc.setResultRuleCode("01");
> rrc.setResultAction("1");
> rrc.setResultGoodNo(gnId.goodNo);
> insertLogical(rrc);
> end
>
> Thank you for your time.
>
> -Stathis
>
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/rules-users
>