@Override
public CharSequence deserializeKeyAsColumnKeyFromBytes(String fieldName,
byte[] columnKeyBytes) {
Field field = avroSchema.getAvroSchema().getField(fieldName);
if (field == null) {
throw new ValidationException("Invalid field name " + fieldName
+ " for schema " + avroSchema.toString());
}
Schema.Type schemaType = field.schema().getType();
if (schemaType == Schema.Type.MAP) {
String stringProp = field.schema().getProp("avro.java.string");
if (stringProp != null && stringProp.equals("String")) {
return new String(columnKeyBytes);
} else {
return new Utf8(columnKeyBytes);
}
} else if (schemaType == Schema.Type.RECORD) {
return new String(columnKeyBytes);
} else {
throw new ValidationException("Unsupported type for keyAsColumn: "
+ schemaType);
}
}