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-4294] [BEAM-4360] Join translation and ReduceByKey test suite where moved to org.apache.beam.* package. #1

Merged

Conversation

VaclavPlajt
Copy link

@VaclavPlajt VaclavPlajt commented May 21, 2018

This pull requests summaries together all the changes described in:


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

  • Make sure there is a JIRA issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes.
  • Format the pull request title like [BEAM-XXX] Fixes bug in ApproximateQuantiles, where you replace BEAM-XXX with the appropriate JIRA issue.
  • Write a pull request description that is detailed enough to understand:
    • What the pull request does
    • Why it does it
    • How it does it
    • Why this approach
  • Each commit in the pull request should have a meaningful subject line and body.
  • Run ./gradlew build to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

Copy link

@dmvk dmvk left a comment

Choose a reason for hiding this comment

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

Looks good overall! Good job 👍 Please introduce a check whether RBK can be translated using current translator and we're good to go ;)


ListDataSink<Pair<Integer, Pair<String, Integer>>> output = ListDataSink.get();

BinaryFunctor<Optional<Pair<Integer, String>>, Pair<Integer, Integer>, Pair<String, Integer>>
Copy link

Choose a reason for hiding this comment

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

it's usually more readable to apply lambda directly or to create named static function and use it by reference

Copy link
Author

Choose a reason for hiding this comment

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

I agree. Code was changed so the lambda is is used directly.
This case is more specific since the API requires type parameters of BinaryFunctor to be stated explicitly, otherwise parameter to the output() method has inferred arguments type which cannot be assigned from ListDataSink<Pair<Integer, Pair<String, Integer>>> (output variable).

@@ -48,6 +48,10 @@
private static <InputT, K, V, OutputT, W extends Window<W>> PCollection<Pair<K, OutputT>>
doTranslate(ReduceByKey<InputT, K, V, OutputT, W> operator, BeamExecutorContext context) {

if (operator.getValueComparator() != null) { //TODO Could we even do values sorting ?
Copy link

Choose a reason for hiding this comment

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

Preconditions.checkState

Copy link
Author

Choose a reason for hiding this comment

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

Fixed.

@@ -54,6 +55,7 @@
// extended operators
translators.put(ReduceByKey.class, new ReduceByKeyTranslator());
Copy link

Choose a reason for hiding this comment

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

we need to add predicate for reduce by key translator as it can not handle some cases (eg. if it contains value comparator). Predicates also allow us to have more implementations for a single operator (to handle different cases)

Copy link

Choose a reason for hiding this comment

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

I reckon it would be worth adding a boolean canTranslate to the OperatorTranslator interface.

Copy link
Author

Choose a reason for hiding this comment

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

New method boolean canTranslate(operator) added to OperatorTranslator. Now we have ability to explicitly state when given translator cannot translate given Operator. We can also add more specialized translators when needed.

PCollection<ValueT> typedInput = (PCollection<ValueT>) inputPCollection;
typedInput.setCoder(valueCoder);

PCollection<KV<K, ValueT>> leftKvInput =
Copy link

Choose a reason for hiding this comment

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

-> kvInput

Copy link
Author

Choose a reason for hiding this comment

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

Fixed.

private final UnaryFunction<InputT, K> keyExtractor;

public InputToKvDoFn(UnaryFunction<InputT, K> leftKeyExtractor) {
this.keyExtractor = leftKeyExtractor;
Copy link

Choose a reason for hiding this comment

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

leftKeyExtractor -> keyExtractor

Copy link
Author

Choose a reason for hiding this comment

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

Fixed.

… extended to allow more than one translator per operator.
@dmvk
Copy link

dmvk commented May 22, 2018

LGTM 👍 Good job. Can we send a pull request directly to apache/beam repository and than pull the changes to our repo?

@VaclavPlajt VaclavPlajt merged commit 6711c13 into seznam:dsl-euphoria May 22, 2018
@VaclavPlajt VaclavPlajt deleted the vasek/package-change-rebase branch May 22, 2018 07:09
dmvk pushed a commit that referenced this pull request Oct 2, 2018
Fix tests expectations and minor code fix up.
mareksimunek pushed a commit that referenced this pull request Oct 25, 2018
Update forked repository.
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