Reputation: 8495
I want to add special cases to boost performance of any Akka serialization module, i.e. allowing for faster serialization of Array[Double]
or any primitive types wrapped by the user. Is there a canonical way to allow custom serialization on a per-type basis?
My idea is to add a trait CanSerialize[T]
which defines methods serialize(o:T):Array[Byte]
and deserialize(bytes:Array[Byte]):T
. Is there a way to achieve something like this without losing the benefits of Akka like pattern matching?
edit I could also be satisfied with Kryo or something else faster than Java's serializer, but there doesn't seem to be any prepackaged jar files for Kryo and Akka 2.1.
Upvotes: 1
Views: 190
Reputation: 2426
You can register your own serializer for specific types.
akka.actor {
serialization-bindings {
"[D" = doubleBytes
}
serializers {
doubleBytes = "a.b.YourDoubleArraySerializer"
}
}
Note that [D
is the class name for Array[Double]
.
http://doc.akka.io/docs/akka/2.1.2/scala/serialization.html
Upvotes: 2