-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
46cd74b
to
a45c0ac
Compare
d436a7c
to
4f04ed3
Compare
There was a problem hiding this 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.
sdks/java/extensions/kryo/src/main/java/org/apache/beam/sdk/extensions/kryo/KryoCoder.java
Show resolved
Hide resolved
sdks/java/extensions/kryo/src/main/java/org/apache/beam/sdk/extensions/kryo/KryoCoder.java
Show resolved
Hide resolved
final KryoOptions kryoOptions = pipelineOptions.as(KryoOptions.class); | ||
return new KryoCoder<>( | ||
new SerializableOptions( | ||
kryoOptions.getKryoBufferSize(), |
There was a problem hiding this comment.
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.", |
There was a problem hiding this comment.
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."); |
There was a problem hiding this comment.
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")) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
?
...ava/extensions/kryo/src/main/java/org/apache/beam/sdk/extensions/kryo/KryoCoderProvider.java
Show resolved
Hide resolved
*/ | ||
public class KryoCoder<T> extends CustomCoder<T> { | ||
public class KryoCoder<T> extends AtomicCoder<T> { |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed 👍
All the unresolved review comments still holds and should be resolved. |
Please add a meaningful description for your change here
Follow this checklist to help us incorporate your contribution quickly and easily:
[BEAM-XXX] Fixes bug in ApproximateQuantiles
, where you replaceBEAM-XXX
with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.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)