Hi Prasad,
On Fri, Apr 16, 2010 at 4:28 PM, Vootla <
vvo...@gmail.com> wrote:
> Nate and others,
>
> I'm trying to serialize a large object graph (running into GBs on the
> disk with current Java serialization) and encounter stack overflows.
> I'm wondering if this could be due to any circularity (cycles) in the
> object graph.
Cycles are handled by java serialization, at least I haven't seen any
that were not detected. Perhaps the stack trace might help here.
> Does kryo and its serializers handle this already or do
> we need to do do something to ensure that objects are serialized only
> once in the graph.
Kryo comes with the ReferenceFieldSerializer that you need to return
in newDefaultSerializer:
Kryo kryo = new Kryo() {
protected Serializer newDefaultSerializer( final Class type ) {
return new ReferenceFieldSerializer( this, type );
}
};
Additionally it might make sense to write custom serializers for some
objects if they'd pull in stuff that you actually don't need.
I just wrote some custom serializer, you might have a look at
http://github.com/magro/kryo-serializers/tree/master/src/main/java/de/javakaffee/kryoserializers/
Cheers,
Martin
--
Martin Grotzke
http://www.javakaffee.de/blog/