You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2017/10/21 05:36:00 UTC
[jira] [Commented] (BEAM-2304) State declared with one class cannot
be accessed as a superclass (applies to BagState|CombiningState <:
GroupingState)
[ https://issues.apache.org/jira/browse/BEAM-2304?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16213747#comment-16213747 ]
ASF GitHub Bot commented on BEAM-2304:
--------------------------------------
GitHub user luke-zhu opened a pull request:
https://github.com/apache/beam/pull/4024
[BEAM-2304] Fixed bug allowing declared state to be accessed as a superclass.
Follow this checklist to help us incorporate your contribution quickly and easily:
- [x] Make sure there is a [JIRA issue](https://issues.apache.org/jira/projects/BEAM/issues/) 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.
- [x] Each commit in the pull request should have a meaningful subject line and body.
- [x] Format the pull request title like `[BEAM-XXX] Fixes bug in ApproximateQuantiles`, where you replace `BEAM-XXX` with the appropriate JIRA issue.
- [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
- [x] Run `mvn clean verify` to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.
- [N/A] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
---
This is a fix to BEAM-2304: State declared with one class cannot be accessed as a superclass (applies to BagState|CombiningState <: GroupingState).
I changed the stateId check in `analyzeExtraParameter` of `DoFnSignatures.java` to check that the initial state declaration is a subtype of the state type of `processElement` instead of equal to.
I updated the corresponding error message and added a test to `DoFnSignaturesTest.java` which makes sure that the example code in the original JIRA issue instantiates a DoFn without a runtime error.
This is my first pull request. I'm excited to learn from everyone!
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/luke-zhu/beam luke
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/beam/pull/4024.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #4024
----
commit ed29adf3de87a8f118316a9e6fb4cf398da135ca
Author: luke-zhu <lu...@brown.edu>
Date: 2017-10-21T05:06:00Z
Allowed for declared state to be accessed as a supertype and updated error messages.
----
> State declared with one class cannot be accessed as a superclass (applies to BagState|CombiningState <: GroupingState)
> ----------------------------------------------------------------------------------------------------------------------
>
> Key: BEAM-2304
> URL: https://issues.apache.org/jira/browse/BEAM-2304
> Project: Beam
> Issue Type: Bug
> Components: sdk-java-core
> Reporter: Reuven Lax
> Labels: starter
>
> The following code:
> {code}
> @StateId("foo")
> private final StateSpec<CombiningState<Integer, int[], Integer>> state =
> StateSpecs.combining(Sum.ofIntegers());
> @ProcessElement
> public void processElement(ProcessContext c,
> @StateId("foo") GroupingState<Integer, Integer> state) {
> }
> {code}
> Fails with:
> {code}
> parameter of type GroupingState<Integer, Integer> at index 1: reference to StateId exists with different type CombiningState<Integer, int[], Integer>
> {code}
> However since GroupingState<Integer, Integer> is the base class, ideally this should work - and would make the API easier to use if it did.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)