[rules-users] How to use global hashmap in drools

Wolfgang Laun wolfgang.laun at gmail.com
Wed Oct 30 15:22:48 EDT 2013


If all what you need is the number of distinct key values, a Set would
be sufficient.

Wrapping the access to hashMap into a function doesn't really have any
merits - you can use hashMap.put(a,b); and hashMap.size() directly.

If you do want to use a global in a DRL function, you'll have to pass
it to the function as a parameter.

function setValue(Set set, String a){
   set.add(a);
}

-W

On 30/10/2013, bbarani <bbarani at gmail.com> wrote:
> Sorry for the confusion.
>
> I am just trying to store the value in to a global hashmap (more like a
> counter) and get back the total size of the hashmap after all the data is
> processed.
>
> function setValue(String a, String b){
>     hashValue.put(a,b);
> }
>
> function int getValue(){
>     return hashValue.size();
> }
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/How-to-use-global-hashmap-in-drools-tp4026555p4026557.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>


More information about the rules-users mailing list