merlimat commented on a change in pull request #1743: ByteBuffer schema
URL: https://github.com/apache/incubator-pulsar/pull/1743#discussion_r186576324
 
 

 ##########
 File path: 
pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/StringSchema.java
 ##########
 @@ -37,19 +37,16 @@ public StringSchema(Charset charset) {
         this.charset = charset;
     }
 
-    public byte[] encode(String message) {
-        return message.getBytes(charset);
+    public ByteBuffer encode(String message) {
+        byte[] bytes = message.getBytes(charset);
+        return ByteBuffer.allocateDirect(bytes.length).put(bytes);
     }
 
-    public String decode(byte[] bytes) {
-        return new String(bytes, charset);
+    public String decode(ByteBuffer buf) {
+        return new String(buf.array(), charset);
 
 Review comment:
   `return StandardCharsets.UTF_8.decode(byteBuffer).toString();`

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


With regards,
Apache Git Services

Reply via email to