Is it possible to get hold of the direct byte buffer in a custom serializer?

90 views
Skip to first unread message

Rajiv Kurian

unread,
Jan 17, 2014, 3:04:29 PM1/17/14
to akka...@googlegroups.com
The current serialization has the following signature:

  1. // "toBinary" serializes the given object to an Array of Bytes
  2. def toBinary(obj: AnyRef): Array[Byte] = {
  3. // Put the code that serializes the object here
  4. // ... ...
  5. }
  6.  
  7. // "fromBinary" deserializes the given array,
  8. // using the type hint (if any, see "includeManifest" above)
  9. // into the optionally provided classLoader.
  10. def fromBinary(bytes: Array[Byte],
  11. clazz: Option[Class[_]]): AnyRef = {
  12. // Put your code that deserializes here
  13. // ... ...
  14. }

Is it possible to actually to get a reference to the underlying direct byte buffer instead? Conversely would it be possible to output a direct byte buffer too. Motivation: I am trying to write an Akka serializer for my own classes that are generated by the Simple Binary Encoding project. Simple Binary protocol uses a flyweight pattern on top of byte buffers avoiding a serialization/deserialization step. The benefit is lost a bit if I need to convert direct byte buffers to/from byte arrays.

Thanks,
Rajiv

√iktor Ҡlang

unread,
Jan 20, 2014, 5:32:06 AM1/20/14
to Akka User List

The Akka remote protocol is based on Protobuf where the user message is a byte(s) payload, so there is no bytebuffer to get ahold of.

Cheers,

--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://akka.io/faq/
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/groups/opt_out.

Akka Team

unread,
Jan 20, 2014, 7:47:01 AM1/20/14
to Akka User List
Hi Rajiv,

As Viktor pointed out, the Akka container format is protobuf based, and carries the user layer message as bytes -- so there must be a protobuf deserialization step.

-Endre
--
Akka Team
Typesafe - The software stack for applications that scale
Blog: letitcrash.com
Twitter: @akkateam

Rajiv Kurian

unread,
Jan 20, 2014, 10:34:43 AM1/20/14
to akka...@googlegroups.com
Aah, thanks - got it.


On Monday, January 20, 2014, Akka Team <akka.o...@gmail.com> wrote:
Hi Rajiv,

As Viktor pointed out, the Akka container format is protobuf based, and carries the user layer message as bytes -- so there must be a protobuf deserialization step.

-Endre


On Mon, Jan 20, 2014 at 11:32 AM, √iktor Ҡlang <viktor...@gmail.com> wrote:

The Akka remote protocol is based on Protobuf where the user message is a byte(s) payload, so there is no bytebuffer to get ahold of.

Cheers,

On Jan 17, 2014 9:04 PM, "Rajiv Kurian" <geet...@gmail.com> wrote:
The current serialization has the following signature:

  1. // "toBinary" serializes the given object to an Array of Bytes
  2. def toBinary(obj: AnyRef): Array[Byte] = {
  3. // Put the code that serializes the object here
  4. // ... ...
  5. }
  6.  
  7. // "fromBinary" deserializes the given array,
  8. // using the type hint (if any, see "includeManifest" above)
  9. // into the optionally provided classLoader.
  10. def fromBinary(bytes: Array
Akka Team
Typesafe - The software stack for applications that scale
Blog: letitcrash.com
Twitter: @akkateam

--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://akka.io/faq/
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to a topic in the Google Groups "Akka User List" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/akka-user/UQLopnRMHAc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to akka-user+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages