Created
July 2, 2014 18:11
-
-
Save pdeva/67a914b5d0318f7d306f 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
private static Map<Long, Long> multiDataPointsToPerTxnSummedValue(List<MultiDataPoint> countsList) | |
{ | |
Map<DateTime, Map<Long, Long>> timeStampToTxnIdToCountsMap = new HashMap<>(); | |
for (MultiDataPoint multiDataPoint : countsList) | |
{ | |
timeStampToTxnIdToCountsMap.put(multiDataPoint.getTimestamp(), convertToPerTxnData(multiDataPoint.getData())); | |
} | |
return timeStampToTxnIdToCountsMap.entrySet().stream() | |
.flatMap(e -> e.getValue().entrySet().stream().map(ex -> | |
new Object() | |
{ | |
Long txId = ex.getKey(); | |
DataPoint dataPoint = new DataPoint(e.getKey(), ex.getValue()); | |
} | |
)) | |
.collect( | |
groupingBy(t -> t.txId, mapping(t -> t.dataPoint, Collectors.summingLong(dataPoint -> dataPoint.getValue().longValue()))) | |
); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment