Skip to content

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

Merged
VaclavPlajt merged 5 commits intodsl-euphoriafrom
dejv/kryo_with_multiple_registrars
Oct 4, 2018
Merged

[BEAM-5437] Allow kryo provider to use multiple registrars.#40
VaclavPlajt merged 5 commits intodsl-euphoriafrom
dejv/kryo_with_multiple_registrars

Conversation

@dmvk
Copy link
Copy Markdown

@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 requested a review from VaclavPlajt September 22, 2018 12:12
@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
Copy Markdown

@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(),
Copy link
Copy Markdown

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.",
Copy link
Copy Markdown

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.");
Copy link
Copy Markdown

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")) {
Copy link
Copy Markdown

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) {
Copy link
Copy Markdown

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 ?

* @param <T> type of element coder can handle
*/
public class KryoCoder<T> extends CustomCoder<T> {
public class KryoCoder<T> extends AtomicCoder<T> {
Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown

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