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 2019/09/09 19:11:20 UTC

[GitHub] [pulsar] sijie commented on a change in pull request #5123: Modify the schema decode method can decode ByteBuf

sijie commented on a change in pull request #5123: Modify the schema decode method can decode ByteBuf
URL: https://github.com/apache/pulsar/pull/5123#discussion_r322406286
 
 

 ##########
 File path: pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/StructSchema.java
 ##########
 @@ -99,6 +108,37 @@ public T decode(byte[] bytes, byte[] schemaVersion) {
         }
     }
 
+    @Override
+    public T decode(ByteBuf byteBuf) {
+        int size = getCanReadSize(byteBuf);
+        return reader.read(tmpBuffer.get(), 0, size);
+    }
+
+    @Override
+    public T decode(ByteBuf byteBuf, byte[] schemaVersion) {
+        int size = getCanReadSize(byteBuf);
+
+        try {
+            return readerCache.get(BytesSchemaVersion.of(schemaVersion)).read(tmpBuffer.get(), 0, size );
+        } catch (ExecutionException e) {
+            LOG.error("Can't get generic schema for topic {} schema version {}",
+                    schemaInfoProvider.getTopicName(), Hex.encodeHexString(schemaVersion), e);
+            throw new RuntimeException("Can't get generic schema for topic " + schemaInfoProvider.getTopicName());
+        }
+    }
+
+    private int getCanReadSize(ByteBuf byteBuf) {
 
 Review comment:
   enlargeReadBufferSize

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


With regards,
Apache Git Services