use of org.apache.flink.api.common.aggregators.Aggregator in project flink-mirror by flink-ci.
the class IterationSynchronizationSinkTask method checkForConvergence.
private boolean checkForConvergence() {
if (maxNumberOfIterations == currentIteration) {
if (log.isInfoEnabled()) {
log.info(formatLogString("maximum number of iterations [" + currentIteration + "] reached, terminating..."));
}
return true;
}
if (convergenceAggregatorName != null) {
@SuppressWarnings("unchecked") Aggregator<Value> aggregator = (Aggregator<Value>) aggregators.get(convergenceAggregatorName);
if (aggregator == null) {
throw new RuntimeException("Error: Aggregator for convergence criterion was null.");
}
Value aggregate = aggregator.getAggregate();
if (convergenceCriterion.isConverged(currentIteration, aggregate)) {
if (log.isInfoEnabled()) {
log.info(formatLogString("convergence reached after [" + currentIteration + "] iterations, terminating..."));
}
return true;
}
}
if (implicitConvergenceAggregatorName != null) {
@SuppressWarnings("unchecked") Aggregator<Value> aggregator = (Aggregator<Value>) aggregators.get(implicitConvergenceAggregatorName);
if (aggregator == null) {
throw new RuntimeException("Error: Aggregator for default convergence criterion was null.");
}
Value aggregate = aggregator.getAggregate();
if (implicitConvergenceCriterion.isConverged(currentIteration, aggregate)) {
if (log.isInfoEnabled()) {
log.info(formatLogString("empty workset convergence reached after [" + currentIteration + "] iterations, terminating..."));
}
return true;
}
}
return false;
}
Aggregations