private void padPresentation(Bucket toPresent) { Map<String, List<Entry<Point, UntypedMetric>>> currentMetricNames = toPresent.getValuesByMetricName(); for (Map.Entry<String, List<Entry<Point, UntypedMetric>>> metric : currentMetricNames.entrySet()) { final int currentDataPoints = metric.getValue().size(); if (currentDataPoints < pointsToKeep) { padMetric(metric.getKey(), toPresent, currentDataPoints); } } Set<String> keysMissingFromPresentation = new HashSet<>(persistentData.keySet()); keysMissingFromPresentation.removeAll(currentMetricNames.keySet()); for (String cachedMetric : keysMissingFromPresentation) { padMetric(cachedMetric, toPresent, 0); } }