Search in sources :

Example 6 with CombinerFactory

use of com.hazelcast.mapreduce.CombinerFactory in project hazelcast by hazelcast.

the class ClientMapProxy method aggregate.

@Override
public <SuppliedValue, Result> Result aggregate(Supplier<K, V, SuppliedValue> supplier, Aggregation<K, SuppliedValue, Result> aggregation, JobTracker jobTracker) {
    try {
        Preconditions.isNotNull(jobTracker, "jobTracker");
        KeyValueSource<K, V> keyValueSource = KeyValueSource.fromMap(this);
        Job<K, V> job = jobTracker.newJob(keyValueSource);
        Mapper mapper = aggregation.getMapper(supplier);
        CombinerFactory combinerFactory = aggregation.getCombinerFactory();
        ReducerFactory reducerFactory = aggregation.getReducerFactory();
        Collator collator = aggregation.getCollator();
        MappingJob mappingJob = job.mapper(mapper);
        ReducingSubmittableJob reducingJob;
        if (combinerFactory != null) {
            reducingJob = mappingJob.combiner(combinerFactory).reducer(reducerFactory);
        } else {
            reducingJob = mappingJob.reducer(reducerFactory);
        }
        ICompletableFuture<Result> future = reducingJob.submit(collator);
        return future.get();
    } catch (Exception e) {
        throw new HazelcastException(e);
    }
}
Also used : MappingJob(com.hazelcast.mapreduce.MappingJob) HazelcastException(com.hazelcast.core.HazelcastException) ReducerFactory(com.hazelcast.mapreduce.ReducerFactory) HazelcastException(com.hazelcast.core.HazelcastException) Collator(com.hazelcast.mapreduce.Collator) CombinerFactory(com.hazelcast.mapreduce.CombinerFactory) Mapper(com.hazelcast.mapreduce.Mapper) ReducingSubmittableJob(com.hazelcast.mapreduce.ReducingSubmittableJob)

Aggregations

CombinerFactory (com.hazelcast.mapreduce.CombinerFactory)6 Mapper (com.hazelcast.mapreduce.Mapper)5 ReducerFactory (com.hazelcast.mapreduce.ReducerFactory)5 HazelcastException (com.hazelcast.core.HazelcastException)4 Collator (com.hazelcast.mapreduce.Collator)4 MappingJob (com.hazelcast.mapreduce.MappingJob)4 ReducingSubmittableJob (com.hazelcast.mapreduce.ReducingSubmittableJob)4 JobTrackerConfig (com.hazelcast.config.JobTrackerConfig)1 Member (com.hazelcast.core.Member)1 ClusterService (com.hazelcast.internal.cluster.ClusterService)1 AggregationResult (com.hazelcast.map.impl.query.AggregationResult)1 QueryResult (com.hazelcast.map.impl.query.QueryResult)1 Combiner (com.hazelcast.mapreduce.Combiner)1 KeyPredicate (com.hazelcast.mapreduce.KeyPredicate)1 KeyValueSource (com.hazelcast.mapreduce.KeyValueSource)1 TopologyChangedStrategy (com.hazelcast.mapreduce.TopologyChangedStrategy)1 AbstractJobTracker (com.hazelcast.mapreduce.impl.AbstractJobTracker)1 MapReduceService (com.hazelcast.mapreduce.impl.MapReduceService)1 MapReduceUtil.executeOperation (com.hazelcast.mapreduce.impl.MapReduceUtil.executeOperation)1 KeyValueJobOperation (com.hazelcast.mapreduce.impl.operation.KeyValueJobOperation)1