for (int i = 0; i < result.length; i++) {
Field field = readSchema.getField(i);
if (field.getObjectSerialization() == null) {
continue;
}
Serialization serialization = ReflectionUtils.newInstance(field.getObjectSerialization(), conf);
if (serialization instanceof FieldConfigurable) {
Map<String, String> targetSchemaMetadata = null;
// Look if this field is also in the target Schema, so we extract both metadata
if(targetSchema.containsField(field.getName())) {
Field targetSchemaField = targetSchema.getField(field.getName());
if(targetSchemaField.getObjectSerialization() == null ||
!targetSchemaField.getObjectSerialization().equals(field.getObjectSerialization())) {
// Error: field in target schema with same name but different serialization mechanism!
throw new RuntimeException("Target schema has field [" + field.getName() + "] with different serialization than read schema field with same name.");
}
targetSchemaMetadata = targetSchemaField.getProps();
}
((FieldConfigurable) serialization).setFieldProperties(field.getProps(), targetSchemaMetadata);
}
result[i] = serialization.getDeserializer(field.getObjectClass());
}
return result;
}