carbonite icon indicating copy to clipboard operation
carbonite copied to clipboard

Perform references when reading collections & maps

Open trptcolin opened this issue 13 years ago • 2 comments

This is the stuff we talked about on twitter/IRC. Maps ended up more complex than I thought - possibly something wrong with Kryo, but it's hard to say. Without the custom reference resolver, the first map reference would get lost somehow - further nested ones seemed to work fine, the reference objects being read always seemed to fetch the second entry. And this was only with maps - vectors seemed to work fine, and seqs also didn't seem to need anything special.

So this gets all the tests passing that I could think of, but it's certainly possible there are cases I'm not thinking of. I did also hack around with test cases that complicated the nesting + repeating, but threw them away since they already seemed to work.

trptcolin avatar Jul 12 '12 13:07 trptcolin

Welp, there's at least one more problem here when I run my real data, though this gets me further. I'll have to see if I can shrink it down to a reasonable test case.

trptcolin avatar Jul 12 '12 14:07 trptcolin

Feel free to toss this PR out. Our performance after just defining useReferences to return false is enough better than plain Java serialization (and I'm frustrated enough by not being able to track down a smaller failure case) that I'm out of ideas for now.

But I am wondering if there's something inherently problematic about doing this with immutable data structures. The reference() calls in the Kryo project's collection serializers all look to be called after constructing the collection, and populating them afterwards.

trptcolin avatar Jul 17 '12 01:07 trptcolin