public <K, V> void serializeMap(HashGenericRecord rec, String fieldName, String keyTypeName, String valueTypeName, Map<K, V> map) {
if (map == null) {
return;
}
rec.put(null, "{");
NFTypeSerializer keySerializer = (NFTypeSerializer) (framework.getSerializer(keyTypeName));
NFTypeSerializer valueSerializer = (NFTypeSerializer) (framework.getSerializer(valueTypeName));
HashGenericRecord independent = new HashGenericRecord(new HashOrderIndependent());
for (Map.Entry<K, V> entry : map.entrySet()) {
HashGenericRecord dependent = new HashGenericRecord(new HashOrderDependent());
keySerializer.serialize(entry.getKey(), dependent);
valueSerializer.serialize(entry.getValue(), dependent);
independent.put(null, dependent.hash());
}
rec.put(null, independent.hash());
rec.put(null, "}");
}