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/01/09 16:44:14 UTC

[GitHub] ivankelly commented on a change in pull request #1039: Serialization and Deserialization for RawMessage

ivankelly commented on a change in pull request #1039: Serialization and Deserialization for RawMessage
URL: https://github.com/apache/incubator-pulsar/pull/1039#discussion_r160460345
 
 

 ##########
 File path: pulsar-broker/src/main/java/org/apache/pulsar/client/impl/RawMessageImpl.java
 ##########
 @@ -53,4 +60,47 @@ public ByteBuf getHeadersAndPayload() {
     public void close() {
         headersAndPayload.release();
     }
+
+    @Override
+    public ByteBuf serialize() {
+        // Format: [IdSize][Id][PayloadAndMetadataSize][PayloadAndMetadata]
+        int idSize = id.getSerializedSize();
+        int headerSize = 4 /* IdSize */ + idSize + 4 /* PayloadAndMetadataSize */;
+
+        ByteBuf headers = PooledByteBufAllocator.DEFAULT.buffer(headerSize);
+        headers.writeInt(idSize);
+        try {
+            ByteBufCodedOutputStream outStream = ByteBufCodedOutputStream.get(headers);
+            id.writeTo(outStream);
+            outStream.recycle();
+        } catch (IOException e) {
+            // This is in-memory serialization, should not fail
 
 Review comment:
   done

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