use of com.github.wnameless.json.unflattener.JsonUnflattener in project auto-data-tokenize by GoogleCloudPlatform.
the class RecordUnflattener method unflatten.
/**
* Returns an AVRO record by unflattening the FlatRecord through JSON unflattener.
*/
public GenericRecord unflatten(FlatRecord flatRecord) {
Map<String, Object> jsonValueMap = Maps.newHashMap();
for (Map.Entry<String, Value> entry : flatRecord.getValuesMap().entrySet()) {
var valueProcessor = new ValueProcessor(entry);
jsonValueMap.put(valueProcessor.cleanKey(), valueProcessor.convertedValue());
}
String unflattenedRecordJson = new JsonUnflattener(jsonValueMap).unflatten();
return convertJsonToAvro(schema, unflattenedRecordJson);
}
Aggregations