Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scala binary serialization library

I'm interested in canvasing opinion about options for Scala data-structure serialization. I'd like to find something which is developed enough to allow (if possible) efficient binary serialization of the Scala collection types (i.e. not using generic Java reflection - I don't want to be serializing all parts of a collection class, including internal book-keeping data) but also allows me to extend functionality for my own purposes/classes: I am more than happy to have to write serialization code for each of our own classes, but would rather not have to do it for collections from the Scala standard libraries. In C++ I get a lot of this functionality from the Boost serialization library.

I've used SBinary in the past and it does some of what I want, but is not getting obvious active maintenance and doesn't seem (afaik) to keep track of objects already serialized (e.g. for DAGs or cyclic datastructures).

Are there other Scala-specific solutions, or if not, what are your recommendations for efficient binary serialization?

like image 760
Alex Wilson Avatar asked Sep 19 '12 19:09

Alex Wilson


2 Answers

Probably, if you only need to serialize data and not whole java objects, best solutions are :

  • msgpack(implementation),
  • BSON (implementation),
  • protocol buffers.

I am using msgpack and bson in several projects and they work pretty well. I really recommend msgpack – has most efficient binary representation (of these three) and is fully JSON compatibile.

like image 105
spinus Avatar answered Nov 13 '22 09:11

spinus


A protocol buffers compiler for Scala: https://github.com/SandroGrzicic/ScalaBuff - perhaps this can help?

There's a couple of other links at the bottom of this page: http://doc.akka.io/docs/akka/snapshot/scala/serialization.html

like image 1
bcolyn Avatar answered Nov 13 '22 11:11

bcolyn