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_r281064435
########## File path: pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/KeyValueSchema.java ########## @@ -154,14 +205,52 @@ private KeyValueSchema(Schema<K> keySchema, byte[] valueBytes = new byte[valueLength]; byteBuffer.get(valueBytes); - return decode(keyBytes, valueBytes); + return decode(keyBytes, valueBytes, schemaVersion); } - public KeyValue<K, V> decode(byte[] keyBytes, byte[] valueBytes) { - return new KeyValue<>(keySchema.decode(keyBytes), valueSchema.decode(valueBytes)); + public KeyValue<K, V> decode(byte[] keyBytes, byte[] valueBytes, byte[] schemaVersion) { + K k; + if (keySchema.supportSchemaVersioning() && schemaVersion != null) { + k = keySchema.decode(keyBytes, schemaVersion); + } else { + k = keySchema.decode(keyBytes); + } + V v; + if (valueSchema.supportSchemaVersioning() && schemaVersion != null) { + v = valueSchema.decode(valueBytes, schemaVersion); + } else { + v = valueSchema.decode(valueBytes); + } + return new KeyValue<>(k, v); } public SchemaInfo getSchemaInfo() { return this.schemaInfo; } + + public void setSchemaInfoProvider(SchemaInfoProvider schemaInfoProvider) { + this.schemaInfoProvider = schemaInfoProvider; + } + + private Map<String, SchemaInfo> decodeKeyValueSchemaInfo(SchemaInfo schemaInfo) { Review comment: also this method can be `static`, right? ---------------------------------------------------------------- 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