sijie commented on a change in pull request #4211: 
[issue#4155][pulsar-clients]Support key value schema versioning
URL: https://github.com/apache/pulsar/pull/4211#discussion_r281460393
 
 

 ##########
 File path: 
pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/KeyValueSchema.java
 ##########
 @@ -97,6 +103,46 @@ private KeyValueSchema(Schema<K> keySchema,
         this.keySchema = keySchema;
         this.valueSchema = valueSchema;
 
+        if (keySchema instanceof StructSchema) {
+            ((StructSchema) keySchema).setSchemaInfoProvider(new 
SchemaInfoProvider() {
+                @Override
+                public SchemaInfo getSchemaByVersion(byte[] schemaVersion) {
+                    SchemaInfo versionSchemaInfo = 
schemaInfoProvider.getSchemaByVersion(schemaVersion);
+                    return 
decodeKeyValueSchemaInfo(versionSchemaInfo).getKey();
+                }
+
+                @Override
+                public SchemaInfo getLatestSchema() {
+                    return null;
+                }
+
+                @Override
+                public String getTopicName() {
+                    return null;
 
 Review comment:
   it is better to avoid returning `null` when possible. try to return some 
mock name (e.g. "default" or "key-schema")

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


With regards,
Apache Git Services

Reply via email to