use of com.hazelcast.mapreduce.Collator in project hazelcast by hazelcast.
the class BigDecimalMaxAggregation method getCollator.
@Override
public Collator<Map.Entry<Key, BigDecimal>, BigDecimal> getCollator() {
return new Collator<Map.Entry<Key, BigDecimal>, BigDecimal>() {
@Override
public BigDecimal collate(Iterable<Map.Entry<Key, BigDecimal>> values) {
BigDecimal max = null;
for (Map.Entry<Key, BigDecimal> entry : values) {
BigDecimal value = entry.getValue();
max = max == null ? value : value.max(max);
}
return max;
}
};
}
use of com.hazelcast.mapreduce.Collator in project hazelcast by hazelcast.
the class BigDecimalMinAggregation method getCollator.
@Override
public Collator<Map.Entry<Key, BigDecimal>, BigDecimal> getCollator() {
return new Collator<Map.Entry<Key, BigDecimal>, BigDecimal>() {
@Override
public BigDecimal collate(Iterable<Map.Entry<Key, BigDecimal>> values) {
BigDecimal min = null;
for (Map.Entry<Key, BigDecimal> entry : values) {
BigDecimal value = entry.getValue();
min = min == null ? value : value.min(min);
}
return min;
}
};
}
use of com.hazelcast.mapreduce.Collator in project hazelcast by hazelcast.
the class BigIntegerMaxAggregation method getCollator.
@Override
public Collator<Map.Entry<Key, BigInteger>, BigInteger> getCollator() {
return new Collator<Map.Entry<Key, BigInteger>, BigInteger>() {
@Override
public BigInteger collate(Iterable<Map.Entry<Key, BigInteger>> values) {
BigInteger max = null;
for (Map.Entry<Key, BigInteger> entry : values) {
BigInteger value = entry.getValue();
max = max == null ? value : value.max(max);
}
return max;
}
};
}
use of com.hazelcast.mapreduce.Collator in project hazelcast by hazelcast.
the class BigIntegerMinAggregation method getCollator.
@Override
public Collator<Map.Entry<Key, BigInteger>, BigInteger> getCollator() {
return new Collator<Map.Entry<Key, BigInteger>, BigInteger>() {
@Override
public BigInteger collate(Iterable<Map.Entry<Key, BigInteger>> values) {
BigInteger min = null;
for (Map.Entry<Key, BigInteger> entry : values) {
BigInteger value = entry.getValue();
min = min == null ? value : value.min(min);
}
return min;
}
};
}
use of com.hazelcast.mapreduce.Collator 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);
}
}
Aggregations