Created
August 25, 2014 04:47
-
-
Save pdeva/0b34e766590e43e3d000 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static List<MultiDataPoint> convertValueResults(DruidValueResult[] results) | |
{ | |
Map<DateTime, List<DruidValueResult>> timeStampToResults = Arrays.stream(results) | |
.collect(groupingBy(r -> DateTime.parse(r.timestamp))); | |
List<MultiDataPoint> multiDataPoints = timeStampToResults.entrySet() | |
.stream() | |
.map(e -> new MultiDataPoint(e.getKey(), e.getValue().stream() | |
.collect(toMap(r -> r.event.name, r -> r.event.value)))) | |
.collect(toList()); | |
Collections.sort(multiDataPoints, (o1, o2) -> o1.getTimestamp().compareTo(o2.getTimestamp())); | |
return multiDataPoints; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment