You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by Eugene Dzhurinsky <jd...@gmail.com> on 2012/02/04 08:14:12 UTC

Parent/child relations and serialization issues

Hi all!

I need to pass structure A, which has structure B as children. And in
structure B there is the reference to structure A in 'parent' field.
Obviously, when trying to serialize the object of type A - Thrift fails with
exception (StackOverflow in java) because of infinite calls :)

The question - is there any way to 'instruct' thrift to not try walk down the
tree of objects it has serialized yet? Or there is some workaround (maps with
keys and holding keys as references in objects or something like that)?

Thank you all in advance!

-- 
Eugene N Dzhurinsky

Re: Parent/child relations and serialization issues

Posted by Richard Salz <rs...@us.ibm.com>.
> I need to pass structure A, which has structure B as children. And in
> structure B there is the reference to structure A in 'parent' field.

You cannot do it.  Thrift does not support any kind of circular structure 
definition.  You will have to "flatten" out the structure yourself.  For 
example, add a unique-id field to all structures, and then pass an array 
of ID's followed by all the structures. On the receiving side, reconstruct 
the tree.

        /r$

--
STSM, WebSphere Appliance Architect
https://www.ibm.com/developerworks/mydeveloperworks/blogs/soma/