Using a simple class Request{ String id;... } and an auxiliary class IdCount {String id; int count; ... } and some insertions kSession.insert( new Request( "a" ) ); kSession.insert( new Request( "b" ) ); kSession.insert( new Request( "c" ) ); kSession.insert( new Request( "b" ) ); kSession.insert( new Request( "c" ) ); kSession.insert( new Request( "c" ) ); the rule below
rule countById when $list: List() from accumulate( Request( $id: id ), init( Map id2count = new HashMap() ), action( IdCount ic = (IdCount)id2count.get( $id ); if( ic == null ){ ic = new IdCount( $id, 1 ); } else { ic.setCount( ic.getCount() + 1 ); } id2count.put( $id, ic ); ) reverse( IdCount ic = (IdCount)id2count.get( $id ); ic.setCount( ic.getCount() - 1 ); id2count.put( $id, ic ); ) result( id2count.values() ) ) IdCount( $id: id, $count: count > 1 ) from $list then System.out.println( "Id " + $id + ": " + $count ); end produces Id c: 3 Id b: 2 -W On 7 July 2011 16:55, Andre <morpheusan...@web.de> wrote: > it seems much clearer, thxxxx but im afraid that this was not the last > question... > > -- > View this message in context: > http://drools.46999.n3.nabble.com/sliding-window-combination-tp3132340p3148448.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > _______________________________________________ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users >
_______________________________________________ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users