Thanks for your suggestions.
Edson Tirelli-3 wrote: > > Not really... all solutions are variations of this. :( > > We do intent to develop things equivalent to SQL group by, unique, etc > clauses... but no such feature today. > > []s > Edson > > 2008/1/29, cfili <[EMAIL PROTECTED]>: >> >> >> Yeah I tried your first suggestion and ran into the duplication. I'd >> rather >> not create a new fact for each one of these... any other way of avoiding >> it? >> >> >> Edson Tirelli-3 wrote: >> > >> > Sorry, my previous suggestion will count the same process name >> multiple >> > times. There are a few ways to avoid it. I would probably use a helper >> > fact: >> > >> > rule XYZ >> > when >> > $p : Process( $name : name ) >> > not( ProcessCount( name == $name ) ) >> > Number( $count : intValue) from accumulate( >> > $i : Process( name == $name, this != $p ), >> > count( $i ) ) >> > then >> > System.out.println( "There are "+$count+" instances of processes >> > named "+$name ); >> > insert( new ProcessCount( $name, $count ) ); >> > end >> > >> > >> > Hope it helps, >> > Edson >> > >> > 2008/1/29, Edson Tirelli <[EMAIL PROTECTED]>: >> >> >> >> >> >> Try that: >> >> >> >> rule XYZ >> >> when >> >> $p : Process( $name : name ) >> >> Number( $count : intValue) from accumulate( >> >> $i : Process( name == $name, this != $p ), >> >> count( $i ) ) >> >> then >> >> System.out.println( "There are "+$count+" instances of processes >> named >> >> "+$name ); >> >> end >> >> >> >> []s >> >> Edson >> >> >> >> >> >> 2008/1/29, cfili <[EMAIL PROTECTED]>: >> >> > >> >> > >> >> > I am having a hard time finding an example of what I am trying to >> do, >> >> so >> >> > maybe someone here could help me. What I am trying to do is >> determine >> >> > how >> >> > many facts fall into the same category. >> >> > >> >> > My facts are 'processes' and one of their attributes is a 'name'. >> My >> >> > goal >> >> > is to determine how many processes with the same name are >> running. The >> >> > problem is I do not know ahead of time the process names available, >> I >> >> > want >> >> > to determine that set at runtime. Also, once I determine the count >> for >> >> > a >> >> > given name, I do not want to run it again for the other processes >> that >> >> > fall >> >> > in that name category. >> >> > >> >> > I think "from collect" is probably what I want to use here, but I am >> >> not >> >> > sure how to grab the names in my Pattern from the fact I am >> currently >> >> > iterating on. >> >> > >> >> > Thanks. >> >> > -- >> >> > View this message in context: >> >> > http://www.nabble.com/Count-matching-facts-tp15160392p15160392.html >> >> > Sent from the drools - user mailing list archive at Nabble.com. >> >> > >> >> > _______________________________________________ >> >> > rules-users mailing list >> >> > [email protected] >> >> > https://lists.jboss.org/mailman/listinfo/rules-users >> >> > >> >> >> >> >> >> >> >> -- >> >> Edson Tirelli >> >> JBoss Drools Core Development >> >> Office: +55 11 3529-6000 >> >> Mobile: +55 11 9287-5646 >> >> JBoss, a division of Red Hat @ www.jboss.com >> > >> > >> > >> > >> > -- >> > Edson Tirelli >> > JBoss Drools Core Development >> > Office: +55 11 3529-6000 >> > Mobile: +55 11 9287-5646 >> > JBoss, a division of Red Hat @ www.jboss.com >> > >> > _______________________________________________ >> > rules-users mailing list >> > [email protected] >> > https://lists.jboss.org/mailman/listinfo/rules-users >> > >> > >> >> -- >> View this message in context: >> http://www.nabble.com/Count-matching-facts-tp15160392p15163614.html >> Sent from the drools - user mailing list archive at Nabble.com. >> >> _______________________________________________ >> rules-users mailing list >> [email protected] >> https://lists.jboss.org/mailman/listinfo/rules-users >> > > > > -- > Edson Tirelli > JBoss Drools Core Development > Office: +55 11 3529-6000 > Mobile: +55 11 9287-5646 > JBoss, a division of Red Hat @ www.jboss.com > > _______________________________________________ > rules-users mailing list > [email protected] > https://lists.jboss.org/mailman/listinfo/rules-users > > -- View this message in context: http://www.nabble.com/Count-matching-facts-tp15160392p15165595.html Sent from the drools - user mailing list archive at Nabble.com. _______________________________________________ rules-users mailing list [email protected] https://lists.jboss.org/mailman/listinfo/rules-users
