Why don't you use the thrift based serialization that all TBase objects
already support?

I'm referencing thrift 0.6.1 since that's the version we're using, but
something along these lines should work.


TSerializer jsonSerializer = new TSerializer(new TJSONProtocol.Factory());
TDeserializer jsonDeserializer = new TDeserializer(new TJSONProtocol
.Factory());
String encoded = serializer.toString(tbase);  // tbase is an instance of
the thrift object.

naturally if you're using a binary format that you'll get a byte[] array
rather then a string.
//replace TJSONProtocol with any implementation of TProtocol. I think the
choices are JSON, Compact, Binary and maybe one more variation.

If you just want to serialize/deserialize the object, why not take
advantage of thrift existing encoding/decoding mechanism.

Just note, the encoding/decoding is not thread safe, so if you share the
serializer instance you'll have some issues.






On Wed, Mar 26, 2014 at 2:46 PM, Jens Geyer <[email protected]> wrote:

>
> The binary type should do.
>
>
> -----Ursprüngliche Nachricht----- From: Jules Cisek
> Sent: Wednesday, March 26, 2014 10:11 PM
> To: [email protected]
> Subject: serializing thrift objects
>
>
> is there any clever way to control the serialVersionUID of thrift objects
> in Java?
>
> the output of the compiler doesn't specify a serialVersionUID and i end up
> with objects that when serialized in various ways are not compatible
> between builds, compilers, architecture, etc.
>
> in fact the compiler just tosses this into each class file:
> @SuppressWarnings("all")
>
> ouch...
>
> ~j
>
> --
> jules cisek | [email protected]
>



-- 
Samir Faci
*insert title*
fortune | cowsay -f /usr/share/cows/tux.cow

Sent from my non-iphone laptop.

Reply via email to