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/05/12 01:27:50 UTC

[GitHub] [pulsar] congbobo184 commented on a change in pull request #10476: PIP-85 Add Schema Information to Message in Java Client API

congbobo184 commented on a change in pull request #10476:
URL: https://github.com/apache/pulsar/pull/10476#discussion_r630230777



##########
File path: pulsar-client/src/main/java/org/apache/pulsar/client/impl/MessageImpl.java
##########
@@ -384,10 +385,29 @@ public int size() {
         return payload.readableBytes();
     }
 
-    public Schema<T> getSchema() {
+    public Schema<T> getSchemaInternal() {
         return this.schema;
     }
 
+    @Override
+    public Optional<Schema<?>> getReaderSchema() {
+        ensureSchemaIsLoaded();
+        if (schema == null) {
+            return Optional.empty();
+        }
+        if (schema instanceof AutoConsumeSchema) {

Review comment:
       why `AutoConsumeSchema` cant extend `AbstractSchema`?

##########
File path: pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/AbstractSchema.java
##########
@@ -67,4 +69,20 @@ public T decode(ByteBuf byteBuf, byte[] schemaVersion) {
     public Schema<T> clone() {
         return this;
     }
+
+    /**
+     * Return an instance of this schema at the given version.
+     * @param schemaVersion the version
+     * @return the schema at that specific version
+     * @throws SchemaSerializationException in case of unknown schema version
+     * @throws NullPointerException in case of null schemaVersion
+     */
+    public Schema<?> atSchemaVersion(byte[] schemaVersion) throws SchemaSerializationException {

Review comment:
       why named `atSchemaVersion`? may `getSchemaByVersion` is easy to understand?




-- 
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