You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/02/24 09:03:02 UTC

[GitHub] [pulsar] sijie commented on pull request #9614: Schema API: expose underlying Schema information for Fields

sijie commented on pull request #9614:
URL: https://github.com/apache/pulsar/pull/9614#issuecomment-784921400


   @eolivelli I shared the same question with @codelipenghui.
   
   Why can't you use a code snippet like the below?
   
   ```
   Record<GenericRecord> record = ....;
   GenericRecord value = record.getValue();
   SchemaInfo schemaInfo = record.getSchema().getSchemaInfo();
   SchemaType type = schemaInfo.getType();
   
   if (SchemaTye.AVRO == avro) {
      // the record is an AVRO record
       org.apache.avro.generic.GenericRecord avroRecord = ((GenericAvroRecord) value).getAvroRecord();
       handleAvroRecord(avro);
   } else if (SchemaType.JSON == avro) {
      // the record is a JSON record
      JsonNode jsonRecord = ((GenericJsonRecord) value).getJsonNode();
      handleJsonRecord(jsonRecord);
   } else if (SchemaType....) {
      ...
   }
   
   ```
   
   


----------------------------------------------------------------
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:
users@infra.apache.org