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 2018/12/08 23:54:24 UTC

[GitHub] merlimat commented on a change in pull request #3146: Use raw message when manually parsing messages from topic storage

merlimat commented on a change in pull request #3146: Use raw message when manually parsing messages from topic storage
URL: https://github.com/apache/pulsar/pull/3146#discussion_r240019946
 
 

 ##########
 File path: pulsar-sql/presto-pulsar/src/main/java/org/apache/pulsar/sql/presto/JSONSchemaHandler.java
 ##########
 @@ -35,24 +39,43 @@
 
     private final DslJson<Object> dslJson = new DslJson<>();
 
+    private static final FastThreadLocal<byte[]> tmpBuffer = new FastThreadLocal<byte[]>() {
+        @Override
+        protected byte[] initialValue() {
+            return new byte[1024];
+        }
+    };
+
     public JSONSchemaHandler(List<PulsarColumnHandle> columnHandles) {
         this.columnHandles = columnHandles;
     }
 
     @Override
-    public Object deserialize(byte[] bytes) {
+    public Object deserialize(ByteBuf payload) {
+        // Since JSON deserializer only works on a byte[] we need to convert a direct mem buffer into
+        // a byte[].
+        int size = payload.readableBytes();
 
 Review comment:
   dsl-json doesn't take an offset into the byte[] argument. When we get a pooled `HeapByteBuf` it will be specific to only a portion of a bigger `byte[]` from the allocator.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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