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

[BEAM-5437] Allow kryo provider to use multiple registrars. #40

Merged
merged 5 commits into from
Oct 4, 2018

Conversation

dmvk
Copy link

@dmvk dmvk commented Sep 22, 2018

Please add a meaningful description for your change here


Follow this checklist to help us incorporate your contribution quickly and easily:

  • Format the pull request title like [BEAM-XXX] Fixes bug in ApproximateQuantiles, where you replace BEAM-XXX with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

It will help us expedite review of your Pull Request if you tag someone (e.g. @username) to look at it.

Post-Commit Tests Status (on master branch)

Lang SDK Apex Dataflow Flink Gearpump Samza Spark
Go Build Status --- --- --- --- --- ---
Java Build Status Build Status Build Status Build Status Build Status Build Status Build Status
Python Build Status --- Build Status
Build Status
--- --- --- ---

@dmvk dmvk force-pushed the dejv/kryo_with_multiple_registrars branch from 46cd74b to a45c0ac Compare September 22, 2018 14:53
@dmvk dmvk force-pushed the dejv/kryo_with_multiple_registrars branch from d436a7c to 4f04ed3 Compare September 22, 2018 22:13
Copy link

@VaclavPlajt VaclavPlajt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like most of the changes. Good work 👍.

I do not see why we need multiple registrars, it is nice features. But complicates it. And it is not exercised in tests. Please consider adding such a test.

Checkstyle have some complains. lease run whole module build.

final KryoOptions kryoOptions = pipelineOptions.as(KryoOptions.class);
return new KryoCoder<>(
new SerializableOptions(
kryoOptions.getKryoBufferSize(),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do consider these to be user input. And as such, they should be checked for validity. Please consider to add at least basic range checks.

return KryoCoder.of(kryoRegistrar);
throw new CannotProvideCoderException(
String.format(
"Cannot provide [%s], given type descriptor's [%s] raw type is not registered in Kryo.",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should settle whenever we want o use "'%s'" or "[%s]" when formatting nested string. :-)

public void encode(T value, OutputStream outStream) throws IOException {
final KryoState kryoState = KryoState.get(this);
if (value == null) {
throw new CoderException("Cannot encode a null value.");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not? Kryo can do that. Should it be a configuration option?

+ "Forgotten kryo registration is possible explanation. Kryo registrations where done by '%s'.",
(value == null) ? null : value.getClass().getSimpleName(), registrarWithId),
e);
if (e.getMessage().startsWith("Class is not registered")) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works (tests are exercising that). But it may easily breaks without notice when Kryo version is updated. Could we check this explicitly, maybe?

outputChunked.flush();
} catch (KryoException e) {
outputChunked.clear();
if (e.getCause() instanceof EOFException) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why only EOFException and to all IOExceptions ?

*/
public class KryoCoder<T> extends CustomCoder<T> {
public class KryoCoder<T> extends AtomicCoder<T> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure that 'KryoCoder' is an AtomicCoder since docs states:

All atomic coders of the same class are considered to be equal to each other. As a result, an {@link AtomicCoder} should have no associated configuration (instance variables, etc).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed 👍

@VaclavPlajt VaclavPlajt merged commit 5875038 into dsl-euphoria Oct 4, 2018
@VaclavPlajt
Copy link

All the unresolved review comments still holds and should be resolved.

dmvk pushed a commit that referenced this pull request Oct 5, 2018
* #! - eclipse compilation

* #40 - Sort operator with in-memory RSBK sorting

* #40 - Spark SortTranslator

* #40 - Flink SortTranslator

* #40 - RangePartitioning

* #40 - PR#99
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

Successfully merging this pull request may close these issues.

2 participants