-
Notifications
You must be signed in to change notification settings - Fork 0
Getting Started
Ali edited this page Nov 27, 2013
·
3 revisions
To be able to use MapAggregator first you have to configure it in Hazelcast Config
final ServiceConfig serviceConfig = new ServiceConfig();
serviceConfig.setEnabled(true);
serviceConfig.setClassName(MapAggregatorService.class.getName());
serviceConfig.setName(MapAggregatorService.SERVICE_NAME);
config.getServicesConfig().addServiceConfig(serviceConfig);
Now we can say Hazelcast give me a MapAggregator like this
MapAggregator mapAggregator = instance.getDistributedObject(MapAggregatorService.SERVICE_NAME, "students");
Now we have a mapAggregator which will perform aggregations on the map named 'students' Here is a built-in aggregator example, we want to get the note average of students who belongs to class B
final Predicate predicate = Predicates.equal("className", "B");
final Number average = mapAggregator.aggregate(predicate, new NumberAverageAggregator("note"));
Here is the Student POJO
public class Student implements Serializable {
public String name;
public String className;
public int note
}