public void add(SegmentStatistics segmentStatistics, Long segmentId) { stdDevCache = null; hourStdDevCache = null; double segmentCount = 0; double segmentSum = 0; for(ShortLongCursor cursor : segmentStatistics.hourSpeedMap) { short bin = cursor.key; int hour = SegmentStatistics.getHourFromBin(bin); if(hours != null && !hours.contains(hour)) continue; long binCount = cursor.value; if(normalize) hourSpeedMap.putOrAdd(bin, (double)binCount / (double)segmentStatistics.getCount(), (double)binCount / (double)segmentStatistics.getCount()); else hourSpeedMap.putOrAdd(bin, (double)binCount, (double)binCount); int speedBin = SegmentStatistics.getSpeedBinFromBin(bin); double speed = SegmentStatistics.getBinMean(speedBin); hourCount.putOrAdd(hour, (double)binCount, (double)binCount); hourSum.putOrAdd(hour, speed * (double)binCount, speed * (double)binCount); count += binCount; sum += speed * binCount; segmentCount += binCount; segmentSum += speed * binCount; } }