List of usage examples for java.util.stream DoubleStream max
OptionalDouble max();
From source file:Main.java
public static void main(String[] args) { DoubleStream d = DoubleStream.of(1.2, 2.3, 4.5); OptionalDouble v = d.max(); if (v.isPresent()) { System.out.println(v.getAsDouble()); } else {/*from w w w. java 2s . com*/ System.out.println("no value"); } }
From source file:com.hortonworks.streamline.streams.metrics.storm.ambari.AmbariMetricsServiceWithStormQuerier.java
private Map<Long, Double> aggregateStreamsForMetricsValues(Map<Long, List<Pair<String, Double>>> ret, AggregateFunction aggrFunction) { return ret.entrySet().stream().collect(toMap(e -> e.getKey(), e -> { DoubleStream valueStream = e.getValue().stream().mapToDouble(d -> d.getRight()); switch (aggrFunction) { case SUM: return valueStream.sum(); case AVG: return valueStream.average().orElse(0.0d); case MAX: return valueStream.max().orElse(0.0d); case MIN: return valueStream.min().orElse(0.0d); default:// w w w.j a v a2 s. com throw new IllegalArgumentException("Not supported aggregated function."); } })); }