Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fastutil serializers #76

Open
shevek opened this issue Aug 4, 2017 · 5 comments
Open

Add fastutil serializers #76

shevek opened this issue Aug 4, 2017 · 5 comments

Comments

@shevek
Copy link

shevek commented Aug 4, 2017

I should test to figure out whether this is actually required or not. If fastutil serializes by default, then this ticket was a waste of your time.

https://github.com/apache/giraph/blob/4f9c6c24a8b4b03e2836c77fe2e53e38b6519420/giraph-core/src/main/java/org/apache/giraph/writable/kryo/serializers/FastUtilSerializer.java

interesting strategy, but works.

@magro
Copy link
Owner

magro commented Aug 7, 2017

Looking forward to the results of your test ;-)

@shevek
Copy link
Author

shevek commented Aug 8, 2017

snerk nicely played. I'll get there.

@robertvazan
Copy link

robertvazan commented Jul 19, 2021

Vanilla kryo 5.1.1 selects MapSerializer for fastutil's Object2IntOpenHashMap (fastutil 8.5.2), which fails with this exception:

com.esotericsoftware.kryo.KryoException: java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
Serialization trace:
testField (com.test.Test)
	at com.esotericsoftware.kryo.serializers.ReflectField.write(ReflectField.java:101)
	at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:107)
	at com.esotericsoftware.kryo.Kryo.writeClassAndObject(Kryo.java:711)
	at ...
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
	at com.esotericsoftware.kryo.serializers.MapSerializer.write(MapSerializer.java:140)
	at com.esotericsoftware.kryo.serializers.MapSerializer.write(MapSerializer.java:42)
	at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:642)
	at com.esotericsoftware.kryo.serializers.ReflectField.write(ReflectField.java:70)

Serialized class contains:

private final Object2IntMap<String> testField;
public Test(String someParam) {
    testField = new Object2IntOpenHashMap<String>();
    // fill in some data
}

I guess fastutil needs custom serializer that takes precedence over default collection serializers.

How is everyone dealing with this? Are people adding the entire Apache Giraph core as a dependency? Or is everyone adding an override for all fastutil classes/interfaces that forces use of FieldSerializer JavaSerializer?

BTW, is this project alive? There have been no commits for 2 years.

@robertvazan
Copy link

My current workaround is this:

kryo.addDefaultSerializer(Object2IntMap.class, new JavaSerializer();

This has to be done for every top-level interface in fastutil. This could be added to kryo-serializers.

@robertvazan
Copy link

I could do a quick pull request copying Giraph code if there is someone around to merge it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants