You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2020/06/18 04:20:57 UTC
[GitHub] [beam] y1chi opened a new pull request #12029: [BEAM-10153] Fix VoidCoder with FnApiDoFnRunner
y1chi opened a new pull request #12029:
URL: https://github.com/apache/beam/pull/12029
Fix NPE in FnApiStateAccessor.java when using VoidCoder, this is because currentArg for VoidCoder will always to null, and the underneath function will never be applied, which leads to null
memoizedResult.
Also adds length prefix to VoidCoder since it is treated as non-standard coder in FnApi.
------------------------
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
- [ ] [**Choose reviewer(s)**](https://beam.apache.org/contribute/#make-your-change) and mention them in a comment (`R: @username`).
- [ ] 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.
- [ ] Update `CHANGES.md` with noteworthy changes.
- [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
See the [Contributor Guide](https://beam.apache.org/contribute) for more tips on [how to make review process smoother](https://beam.apache.org/contribute/#make-reviewers-job-easier).
Post-Commit Tests Status (on master branch)
------------------------------------------------------------------------------------------------
Lang | SDK | Apex | Dataflow | Flink | Samza | Spark
--- | --- | --- | --- | --- | --- | ---
Go | [](https://ci-beam.apache.org/job/beam_PostCommit_Go/lastCompletedBuild/) | --- | --- | [](https://ci-beam.apache.org/job/beam_PostCommit_Go_VR_Flink/lastCompletedBuild/) | --- | [](https://ci-beam.apache.org/job/beam_PostCommit_Go_VR_Spark/lastCompletedBuild/)
Java | [](https://ci-beam.apache.org/job/beam_PostCommit_Java/lastCompletedBuild/) | [](https://ci-beam.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Apex/lastCompletedBuild/) | [](https://ci-beam.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Dataflow/lastCompletedBuild/)<br>[](https://ci-beam.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Dataflow_Java11/lastCompletedBuild/) | [](https://ci-beam.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Flink/lastCompletedBuild/)<br>[](https://ci-beam.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Flink_Java11/lastCompletedBuild/)<br>[](https://ci-beam.apache.org/job/beam_PostCommit_Java_PVR_Flink_Batch/lastCompletedBuild/)<br>[](https://ci-beam.apache.org/job/beam_PostCommit_Java_PVR_Flink_Streaming/lastCompletedBuild/) | [](https://ci-beam.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Samza/lastCompletedBuild/) | [](https://ci-beam.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Spark/lastCompletedBuild/)<br>[](https://ci-beam.apache.org/job/beam_PostCommit_Java_PVR_Spark_Batch/lastCompletedBuild/)<br>[](https://ci-beam.apache.org/job/beam_PostCommit_Java_ValidatesRunner_SparkStructuredStreaming/lastCompletedBuild/)
Python | [](https://ci-beam.apache.org/job/beam_PostCommit_Python2/lastCompletedBuild/)<br>[](https://ci-beam.apache.org/job/beam_PostCommit_Python35/lastCompletedBuild/)<br>[](https://ci-beam.apache.org/job/beam_PostCommit_Python36/lastCompletedBuild/)<br>[](https://ci-beam.apache.org/job/beam_PostCommit_Python37/lastCompletedBuild/) | --- | [](https://ci-beam.apache.org/job/beam_PostCommit_Py_VR_Dataflow/lastCompletedBuild/)<br>[](https://ci-beam.apache.org/job/beam_PostCommit_Py_VR_Dataflow_V2/lastCompletedBuild/)<br>[](https://ci-beam.apache.org/job/beam_PostCommit_Py_ValCont/lastCompletedBuild/) | [](https://ci-beam.apache.org/job/beam_PreCommit_Python2_PVR_Flink_Cron/lastCompletedBuild/)<br>[](https://ci-beam.apache.org/job/beam_PostCommit_Python35_VR_Flink/lastCompletedBuild/) | --- | [](https://ci-beam.apache.org/job/beam_PostCommit_Python_VR_Spark/lastCompletedBuild/)
XLang | --- | --- | --- | [](https://ci-beam.apache.org/job/beam_PostCommit_XVR_Flink/lastCompletedBuild/) | --- | --- | [](https://ci-beam.apache.org/job/beam_PostCommit_XVR_Spark/lastCompletedBuild/)
Pre-Commit Tests Status (on master branch)
------------------------------------------------------------------------------------------------
--- |Java | Python | Go | Website
--- | --- | --- | --- | ---
Non-portable | [](https://ci-beam.apache.org/job/beam_PreCommit_Java_Cron/lastCompletedBuild/) | [](https://ci-beam.apache.org/job/beam_PreCommit_Python_Cron/lastCompletedBuild/)<br>[](https://ci-beam.apache.org/job/beam_PreCommit_PythonLint_Cron/lastCompletedBuild/) | [](https://ci-beam.apache.org/job/beam_PreCommit_Go_Cron/lastCompletedBuild/) | [](https://ci-beam.apache.org/job/beam_PreCommit_Website_Cron/lastCompletedBuild/)
Portable | --- | [](https://ci-beam.apache.org/job/beam_PreCommit_Portable_Python_Cron/lastCompletedBuild/) | --- | ---
See [.test-infra/jenkins/README](https://github.com/apache/beam/blob/master/.test-infra/jenkins/README.md) for trigger phrase, status and link of all Jenkins jobs.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] lukecwik commented on a change in pull request #12029: [BEAM-10153] Fix VoidCoder with FnApiDoFnRunner
Posted by GitBox <gi...@apache.org>.
lukecwik commented on a change in pull request #12029:
URL: https://github.com/apache/beam/pull/12029#discussion_r442342688
##########
File path: sdks/java/harness/src/main/java/org/apache/beam/fn/harness/state/FnApiStateAccessor.java
##########
@@ -128,7 +128,7 @@ public FnApiStateAccessor(
@Override
public ResultT get() {
ArgT currentArg = arg.get();
- if (currentArg != memoizedArg) {
+ if (currentArg != memoizedArg || currentArg == null) {
Review comment:
I realized this and updated my comment just after posting to use a boolean.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] lukecwik commented on a change in pull request #12029: [BEAM-10153] Fix VoidCoder with FnApiDoFnRunner
Posted by GitBox <gi...@apache.org>.
lukecwik commented on a change in pull request #12029:
URL: https://github.com/apache/beam/pull/12029#discussion_r442363272
##########
File path: sdks/java/harness/src/main/java/org/apache/beam/fn/harness/state/FnApiStateAccessor.java
##########
@@ -124,12 +124,14 @@ public FnApiStateAccessor(
return new Supplier<ResultT>() {
private ArgT memoizedArg;
private ResultT memoizedResult;
+ private boolean initialized;
@Override
public ResultT get() {
ArgT currentArg = arg.get();
- if (currentArg != memoizedArg) {
+ if (currentArg != memoizedArg || (currentArg == null && !initialized)) {
Review comment:
The initialized will become true and will stay true so checking `currentArg == null` won't do anything.
```suggestion
if (currentArg != memoizedArg || !initialized) {
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] y1chi commented on pull request #12029: [BEAM-10153] Fix VoidCoder with FnApiDoFnRunner
Posted by GitBox <gi...@apache.org>.
y1chi commented on pull request #12029:
URL: https://github.com/apache/beam/pull/12029#issuecomment-646073504
R: @boyuanzz
Boyuan could you take a look?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] boyuanzz merged pull request #12029: [BEAM-10153] Fix VoidCoder with FnApiDoFnRunner
Posted by GitBox <gi...@apache.org>.
boyuanzz merged pull request #12029:
URL: https://github.com/apache/beam/pull/12029
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] lukecwik commented on a change in pull request #12029: [BEAM-10153] Fix VoidCoder with FnApiDoFnRunner
Posted by GitBox <gi...@apache.org>.
lukecwik commented on a change in pull request #12029:
URL: https://github.com/apache/beam/pull/12029#discussion_r442337367
##########
File path: sdks/java/harness/src/main/java/org/apache/beam/fn/harness/state/FnApiStateAccessor.java
##########
@@ -128,7 +128,7 @@ public FnApiStateAccessor(
@Override
public ResultT get() {
ArgT currentArg = arg.get();
- if (currentArg != memoizedArg) {
+ if (currentArg != memoizedArg || currentArg == null) {
Review comment:
This will require calling the function everytime when it is null.
You should use a boolean and update the check to be something like: `(currentArg != memoizedArg || !initialized)`.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] y1chi commented on a change in pull request #12029: [BEAM-10153] Fix VoidCoder with FnApiDoFnRunner
Posted by GitBox <gi...@apache.org>.
y1chi commented on a change in pull request #12029:
URL: https://github.com/apache/beam/pull/12029#discussion_r442339948
##########
File path: sdks/java/harness/src/main/java/org/apache/beam/fn/harness/state/FnApiStateAccessor.java
##########
@@ -128,7 +128,7 @@ public FnApiStateAccessor(
@Override
public ResultT get() {
ArgT currentArg = arg.get();
- if (currentArg != memoizedArg) {
+ if (currentArg != memoizedArg || currentArg == null) {
Review comment:
For VoidCoder the arg.get() returns null, which means the currentArg != memoizedArg will evaluate to false.
This leaves the memoizedResult to null(underneath function never applied), and for VoidCoder key coder we need to set the key to ByteString.EMPTY instead of null(generated proto class doesn't allow setting to null) I believe.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] y1chi commented on pull request #12029: [BEAM-10153] Fix VoidCoder with FnApiDoFnRunner
Posted by GitBox <gi...@apache.org>.
y1chi commented on pull request #12029:
URL: https://github.com/apache/beam/pull/12029#issuecomment-645833227
Run Java PreCommit
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] lukecwik commented on a change in pull request #12029: [BEAM-10153] Fix VoidCoder with FnApiDoFnRunner
Posted by GitBox <gi...@apache.org>.
lukecwik commented on a change in pull request #12029:
URL: https://github.com/apache/beam/pull/12029#discussion_r442337367
##########
File path: sdks/java/harness/src/main/java/org/apache/beam/fn/harness/state/FnApiStateAccessor.java
##########
@@ -128,7 +128,7 @@ public FnApiStateAccessor(
@Override
public ResultT get() {
ArgT currentArg = arg.get();
- if (currentArg != memoizedArg) {
+ if (currentArg != memoizedArg || currentArg == null) {
Review comment:
Why do you need to check if it is null?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org