Skip to content

Instantly share code, notes, and snippets.

@pdeva
Created August 25, 2014 04:47
Show Gist options
  • Save pdeva/0b34e766590e43e3d000 to your computer and use it in GitHub Desktop.
Save pdeva/0b34e766590e43e3d000 to your computer and use it in GitHub Desktop.
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