Yeah definitely a good idea to break the problem down into specific cases.
On 22 Jul 2010, at 10:47, Galder ZamarreƱo wrote:
Ok, dealing with simple types/collections is clear. We delegate to
the corresponding library and that's it.
As far as custom types that are controlled by user, so I've gone and compared 3
different methods to deal with them:
Option 1. User/client code generates the byte[] from a precompiled class. Code example:
http://pastebin.com/iqX9rVqV
Option 2. User/client gives us the Pojo and our marshaller converts it into a byte[] with
the help of the precompiled class methods. Code example:
http://pastebin.com/FTTjcfR4
Option 3. User/client gives us the Pojo and our marshaller converts it into a byte using
client provided serializer/deserializer impl that relies on portable simple type
marshaller. I don't have a code example but it'd be very similar to option 2 with
the following changes: At startup, ids and class names would be mapped from a given
configuration. At writing time, the id would be written and the rest would be delegated to
user provided impl. At reading time, once the id has been determined, the class would be
instantiated and it would delegate to it the rest of the reading part.
With this in mind, I've created a spreadsheet comparing them based on different
factors:
http://spreadsheets.google.com/pub?key=0Ag5RGdzR_GsldEJkUEExX2JPTHdsSF93M...
I'm leaning towards 1 for its simplicity (less code and less configuration in spite
of required precompilation) and performance (no extra bytes, no reflection or class
loading).
I would lean towards 1 as well.
Just to re-cap on the cases here:
1) JVM <--> JVM interaction: just use our default marshallers. Indexing supported.
2) JVM <--> non-JVM interaction, just storing primitives + collections. We provide
a marshaller for this? Indexing supported.
3) JVM <--> non-JVM interaction, storing custom objects. User needs to
serialize/de-serialize, and store byte[]'s. Indexing NOT supported.
Does that sum it up?
Cheers
Manik
--
Manik Surtani
manik(a)jboss.org
Lead, Infinispan
Lead, JBoss Cache
http://www.infinispan.org
http://www.jbosscache.org