eolivelli opened a new pull request #9614:
URL: https://github.com/apache/pulsar/pull/9614
### Motivation
GenericRecord API exposes the list of `Fields` but you do not have type
information.
### Modifications
This is patch introduces support for retrieving such metadata for each Field.
The approach is to allow the user to access the underlying metadata using
the native library that actually encoded the value.
```
Consumer<GenericRecord> consumer = client.newConsumer(Schema.AUTO_CONSUME());
GenericRecord value = consumer.receive().getValue();
value.getFields().forEach( f -> {
org.apache.avro.Schema.Field avroField =
f.unwrap(org.apache.avro.Schema.Field.class);
org.apache.avro.Schema fieldSchema = avroField.schema();
log.info("Field {} unwrapped as {} schema {}", f, avroField,
fieldSchema);
});
``
### Verifying this change
(I will add unit tests in case the approach is accepted by the community)
### Does this pull request potentially affect one of the following parts:
This change introduces a new API `Field#unwrap`
### Documentation
- Does this pull request introduce a new feature? yes
- If yes, how is the feature documented? JavaDocs
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]