for (Map.Entry<String, Map<Integer, Object>> entry : map.entrySet()) {
String metricKey = entry.getKey();
Map<Integer, Object> lines = entry.getValue();
if (shouldSave(lines)) {
String data = KeyValueFormat.format(lines);
Measure measure = new Measure(metricKey)
.setPersistenceMode(PersistenceMode.DATABASE)
.setData(data);
index.addMeasure(resource, measure);
entry.setValue(ImmutableMap.copyOf(lines));
}