public Map<String, Entity> toEntityMap() {
Map<String, Entity> resultMap = new HashMap<>();
for (Map.Entry<String, Map<String, SortedSet<FeatureValue>>> entity : backingMap.entrySet()) {
String entityId = entity.getKey();
Entity.Builder entityBuilder = Entity.newBuilder();
for (Map.Entry<String, SortedSet<FeatureValue>> feature : entity.getValue().entrySet()) {
String featureId = feature.getKey();
FeatureValueListBuilder featureBuilder = new FeatureValueListBuilder();
for (FeatureValue featureValue : feature.getValue()) {
featureBuilder.addValue(featureValue.getValue(), featureValue.getTimestamp());
}
entityBuilder.putFeatures(featureId, featureBuilder.build());
}
resultMap.put(entityId, entityBuilder.build());
}
return resultMap;
}