Skip to content

Warn unregistered classes option #297

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

Merged
merged 1 commit into from
Jun 7, 2016
Merged

Conversation

timotta
Copy link
Contributor

@timotta timotta commented Apr 1, 2015

With this option, unregistered classes are warned on kryos log instead of raise exception like the option registrationRequired do.

This option is required mostly for processing large amount of data with third vendor libs, to see all classes that are not registered in the first running, instead of have to discover one class for each running. This happens with me using Spark and mlib.ALS

How to use:

kryo.setWarnUnregisteredClasses(true)

@NathanSweet
Copy link
Member

Do we need a setting for this? You could log a message from ClassResolver#registerImplicit.

@brianfromoregon
Copy link

I have a similar feature locally, inside an overridden com.esotericsoftware.kryo.util.DefaultClassResolver#register

        if (warnImplicitRegistration && registration.getId() == NAME) {
            // Implicit registrations make for larger serialized forms.
            log.warn(String.format("Implicit registration: %s (%s)",
                    Util.className(registration.getType()),
                    registration.getSerializer().getClass().getName()));
        }

@timotta
Copy link
Contributor Author

timotta commented Apr 3, 2015

@NathanSweet seems like a very needed feature. Are you suggesting to put this log even without the parameter? For me is even better, i just put the parameter to avoid changing previously behaviour.

@NathanSweet
Copy link
Member

You can use ClassResolver#registerImplicit to log a message. Why do we need a setting on Kryo?

@timotta
Copy link
Contributor Author

timotta commented Apr 18, 2015

I just put the parameter to avoid changing previously behaviour, but if it is not necessary we can put the warn directly. Ok?

@emlyn
Copy link

emlyn commented Nov 20, 2015

👍 for this option. We use Kryo in Spark, it would be nice to be warned of unregistered classes without failing the whole run and only finding one at a time.
I'd rather not have to work out how to implement a different ClassResolver and make Spark use it if possible, an option like this would make it easier to use.

@vidma
Copy link

vidma commented Jan 16, 2016

good stuff.

much useful for both:

  • especially useful in Spark, where Kryo is initialized internally. so I doubt it would be easy to override the DefaultClassResolver#register without lots of copy-paste monkey-patching ;)
    • I checked it a little, and it seems to be rather complex there, one certainly do not want to start copy-paste monkey-patching spark/KryoSerializer + Twitter and other tweaks living together, so this PR would be really useful...
  • more complex (i.e. normal) scala apps, where it's almost impossible to track down missing registrations one-by-one with hundred versions of collection classes like ::, ListOf1Element and whatever else.

a config option would help too, but not necessarily, as e.g. KryoRegistrator in spark gives a reference to kryo instance where we can simply call: kryo.setWarnUnregisteredClasses(true) when needed.

so, dudes, it's sitting here for way too long, just merge it ASAP 👍 :)

@vidma
Copy link

vidma commented Jan 16, 2016

@NathanSweet

@enragedginger
Copy link

enragedginger commented Apr 26, 2016

+1 This would be nice to have for Apache Spark. The current workarounds are painful.

@magro magro merged commit cf253eb into EsotericSoftware:master Jun 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

7 participants