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-310] Refactor BundleFactory methods #1019

Closed
wants to merge 4 commits into from

Conversation

tgroh
Copy link
Member

@tgroh tgroh commented Sep 27, 2016

Be sure to do all of the following to help us incorporate your contribution
quickly and easily:

  • Make sure the PR title is formatted like:
    [BEAM-<Jira issue #>] Description of pull request
  • Make sure tests pass via mvn clean verify. (Even better, enable
    Travis-CI on your fork and ensure the whole test matrix passes).
  • Replace <Jira issue #> in the title with the actual Jira issue
    number, if there is one.
  • If this contribution is large, please file an Apache
    Individual Contributor License Agreement.

Remove the inputBundle parameter to createBundle and createKeyedBundle.
This parameter is unless the model is capable of propagating keys
between PTransforms.

Remove the PCollection parameter to createRootBundle. createRootBundle
should be a par

Make [Un]CommmittedBundle#getPCollection nullable. Bundles are utilized
by the runner to control the processing of elements, but may not always
belong to a PCollection. Update ImmutabilityCheckingBundleFactory to
return an underlying bundle as the result of createRootBundle.

Use createBundle in Root transform evaluators.

Remove the inputBundle parameter to createBundle and createKeyedBundle.
This parameter is unless the model is capable of propagating keys
between PTransforms.

Remove the PCollection parameter to createRootBundle. createRootBundle
should be a par

Make [Un]CommmittedBundle#getPCollection nullable. Bundles are utilized
by the runner to control the processing of elements, but may not always
belong to a PCollection. Update ImmutabilityCheckingBundleFactory to
return an underlying bundle as the result of createRootBundle.

Use createBundle in Root transform evaluators.
@tgroh tgroh changed the title Refactor BundleFactory methods [BEAM-310] Refactor BundleFactory methods Sep 27, 2016
@tgroh
Copy link
Member Author

tgroh commented Sep 27, 2016

R: @lukecwik

This is an underlying change to modify how root transforms are exercised in order to support splitting. createRootBundle is currently unused in the DirectRunner, but a follow-up PR will use it.

/**
* Returns the PCollection that the elements of this {@link UncommittedBundle} belong to.
*/
@Nullable
Copy link
Member

@lukecwik lukecwik Sep 27, 2016

Choose a reason for hiding this comment

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

It would be nice if these bundles weren't associated with the pcollection cause having nulls here will need to have people understand the special case of the bundle being the input to a root transform. Ditto on CommittedBundle

Copy link
Member Author

Choose a reason for hiding this comment

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

abstract class StructuralKey<K> {

private StructuralKey() {
// Do not extend outside of this class
Copy link
Member

Choose a reason for hiding this comment

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

You can prevent people extending the class by requiring a class to be given to the constructor which has private class visibility and is final.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's what this is; Updated comment

}

public abstract K getKey();
/**
Copy link
Member

Choose a reason for hiding this comment

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

add new line to separate getKey

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.


public abstract K getKey();
/**
* Get the empty {@link StructuralKey}. All instances of the empty key are considered equal.
Copy link
Member

Choose a reason for hiding this comment

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

I was under the impression that all instances of the empty key should be considered distinct

Copy link
Member Author

Choose a reason for hiding this comment

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

That's correct. Done.

if (other == this) {
return true;
@Override
public K getKey() {
Copy link
Member

Choose a reason for hiding this comment

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

Do we need a unique instance of the key to be decoded each time getKey is returned?
Is this to prevent mutations of K?

Copy link
Member Author

Choose a reason for hiding this comment

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

It means that the runner only ever provides keys that have been deserialized from the initial representation it received. We only use it to deliver timers, but it means that timer deliveries are independent from the original key (as is appropriate).

public void emptyKeysNotEqual() {
StructuralKey<?> empty = StructuralKey.empty();

assertThat(empty, not(Matchers.<StructuralKey<?>>equalTo(StructuralKey.empty())));
Copy link
Member

Choose a reason for hiding this comment

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

Looks good but overly verbose when compared to assertEquals and assertNotEquals found in org.junit.Assert

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but this is the general pattern used in (almost) all of the other DirectRunner tests.

Copy link
Member

Choose a reason for hiding this comment

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

SGTM

@lukecwik
Copy link
Member

Minor comment and then LGTM

@tgroh
Copy link
Member Author

tgroh commented Sep 29, 2016

Closed in 759b6ca

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.

None yet

2 participants