All,
I have the following Data Structure:
A HashMap that his value is a simple object or another HashMap that can
have as a value object or HashMap.
I create a very deep (many levels) structure this way.
Eventually I need to serialize this object. I get StackOverflow even if
I increase the thread stack size (-XX:ThreadStackSize) to his maximumx
size.
I am working with JDK1.5
It will be very difficult for me to change this data strcture.
Is there any tools that can help me to serialize such object without
changin my data structure ?
Thanks,
Ronen.
Oliver Wong - 01 Aug 2006 18:42 GMT
> All,
>
[quoted text clipped - 13 lines]
> Is there any tools that can help me to serialize such object without
> changin my data structure ?
Did you try implementing the readObject and writeObject methods?
http://java.sun.com/j2se/1.5.0/docs/api/java/io/Serializable.html
- Oliver
ronari - 02 Aug 2006 05:40 GMT
No I did not. I want some black box solution. It will be difficult to
implement it to all our structure.
> > All,
> >
[quoted text clipped - 18 lines]
>
> - Oliver
EJP - 02 Aug 2006 07:46 GMT
> I have the following Data Structure:
> A HashMap that his value is a simple object or another HashMap that can
> have as a value object or HashMap.
> I create a very deep (many levels) structure this way.
How deep? Must be thousands or millions.
Chris Uppal - 02 Aug 2006 09:20 GMT
> I have the following Data Structure:
> A HashMap that his value is a simple object or another HashMap that can
> have as a value object or HashMap.
> I create a very deep (many levels) structure this way.
Your options are:
1) Change your data structure (I know you said you don't want to do that, but
you may have to anyway).
2) Implement a custorm representation within the serialisation framwork (as
Oliver has already suggested). Note that the essential problem is with your
datastructure, so you will still have to find a solution to the underlyng
problem -- perhaps by using an explicit stack rather than the Java thread's
stack.
3) Find/Implement a complete replacement for serialisation. Same caveat
applies as in (2), which makes it unlikely that an existing solution will work
for you without change.
4) Translate the structure into another form and serialise that. Similarly
rebuild your intended structure from the serialised from as you read it in.
This is roughly equivalent to (2) but may be easier to implement depending on
what you are doing.
5) Quit and find another job.
I.e. there are no easy answers -- you are going to have to do quite a lot of
work no matter how you approach it.
-- chris
quetzalcotl@consultant.com - 02 Aug 2006 12:37 GMT
> All,
>
[quoted text clipped - 6 lines]
> I increase the thread stack size (-XX:ThreadStackSize) to his maximumx
> size.
Note that this does NOT work for the initial thread. You may want to
let the serialization code run in a thread with a larger stack (which
you can specify on thread creation time, if I remember correctly.)
> I am working with JDK1.5
>
> It will be very difficult for me to change this data strcture.
>
> Is there any tools that can help me to serialize such object without
> changin my data structure ?
You may want to serialize a somewhat flattened data structure. For
example, a tree could be flattened to a list.