Java object serialization handles cycles based on object identity.

On Tue, Aug 11, 2009 at 6:17 AM, fft1976<fft1...@gmail.com> wrote:
>
> On Aug 10, 8:19 pm, "Kyle R. Burton" <kyle.bur...@gmail.com> wrote:
>> > Does all this work with cycles, Java arrays, etc.?
>>
>> It will work with anything that implements the Serializable interface
>> in Java.  Arrays do implement that interface, as do all the
>> primitives.  With respect to cycles, I'd suspect it does, but would
>> test it.  If you have a repl handy it should be pretty easy to test
>> those functions out on your data structures.
>>
>> What class has the cycle?  Is it a standard collection?
>>
>
> Cycles are a special case of substructure sharing. Let's talk about
> that instead.
>
> (def common [1 2 3 4 5])
> (def a [6 common])
> (def b [7 common])
> (def c [a b])
>
> If you are serializing c, I want "common" to get copied only once.
>
> I don't know JVM too well, but I think no efficient user-level
> solution is possible. Why? To take care of substructure sharing, you
> need to remember a set of shareable values that have already been
> serialized, and do "reference equality" comparisons when new new
> substructures are serialized.
>
> This comparison and a set implementation can easily be done with
> pointers (because you have "<"), but there are no pointers in the JVM,
> and no "reference inequality", so you must use linear seeks, making
> the time complexity of serialization quadratic, where in C/C++ it
> could be O(N log N)
> >
>



-- 
Venlig hilsen / Kind regards,
Christian Vest Hansen.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to