-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Pipe Valuekind through DoFn and output builders #38490
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
Open
ahmedabu98
wants to merge
12
commits into
apache:master
Choose a base branch
from
ahmedabu98:valuekind_dofn
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
36f5e8b
add valuekind
ahmedabu98 3653244
add tests and DirectRunner support
ahmedabu98 91bd156
add some doc to model
ahmedabu98 2eb20eb
add some doc to model
ahmedabu98 ab406c4
add missing noteOutput
ahmedabu98 821881f
add to ParamWindowedValueCoder
ahmedabu98 684a101
Merge branch 'value_kind' of https://github.com/ahmedabu98/beam into …
ahmedabu98 736d88c
add to windmill keyed work item
ahmedabu98 0074fdb
add missing pieces to Dataflow runner, fnapi, spark
ahmedabu98 55c72d7
Merge branch 'master' of https://github.com/ahmedabu98/beam into valu…
ahmedabu98 a6d0463
remove premature dataflow enabliung
ahmedabu98 803803d
address comments
ahmedabu98 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,6 +61,7 @@ | |
| import org.apache.beam.sdk.values.PCollectionView; | ||
| import org.apache.beam.sdk.values.Row; | ||
| import org.apache.beam.sdk.values.TupleTag; | ||
| import org.apache.beam.sdk.values.ValueKind; | ||
| import org.apache.beam.sdk.values.WindowedValue; | ||
| import org.apache.beam.sdk.values.WindowedValues; | ||
| import org.apache.beam.sdk.values.WindowingStrategy; | ||
|
|
@@ -438,6 +439,11 @@ public void outputWithTimestamp(OutputT output, Instant timestamp) { | |
| outputWithTimestamp(mainOutputTag, output, timestamp); | ||
| } | ||
|
|
||
| @Override | ||
| public void outputWithKind(OutputT output, ValueKind kind) { | ||
| outputWithKind(mainOutputTag, output, kind); | ||
| } | ||
|
|
||
| @Override | ||
| public void outputWindowedValue( | ||
| OutputT output, | ||
|
|
@@ -471,6 +477,22 @@ public <T> void outputWithTimestamp(TupleTag<T> tag, T output, Instant timestamp | |
| outputWindowedValue(tag, output, timestamp, elem.getWindows(), elem.getPaneInfo()); | ||
| } | ||
|
|
||
| @Override | ||
| public <T> void outputWithKind(TupleTag<T> tag, T output, ValueKind kind) { | ||
| builderSupplier | ||
| .builder(output) | ||
| .setTimestamp(elem.getTimestamp()) | ||
| .setWindows(elem.getWindows()) | ||
| .setPaneInfo(elem.getPaneInfo()) | ||
| .setValueKind(kind) | ||
| .setReceiver( | ||
| wv -> { | ||
| checkTimestamp(elem.getTimestamp(), wv.getTimestamp()); | ||
| SimpleDoFnRunner.this.outputWindowedValue(tag, wv); | ||
| }) | ||
| .output(); | ||
| } | ||
|
|
||
| @Override | ||
| public <T> void outputWindowedValue( | ||
| TupleTag<T> tag, | ||
|
|
@@ -506,6 +528,11 @@ public Instant timestamp() { | |
| return elem.getRecordOffset(); | ||
| } | ||
|
|
||
| @Override | ||
| public ValueKind valueKind() { | ||
| return elem.getValueKind(); | ||
| } | ||
|
|
||
| public Collection<? extends BoundedWindow> windows() { | ||
| return elem.getWindows(); | ||
| } | ||
|
|
@@ -597,6 +624,11 @@ public CausedByDrain causedByDrain(DoFn<InputT, OutputT> doFn) { | |
| return elem.causedByDrain(); | ||
| } | ||
|
|
||
| @Override | ||
| public ValueKind valueKind(DoFn<InputT, OutputT> doFn) { | ||
| return elem.getValueKind(); | ||
| } | ||
|
|
||
| @Override | ||
| public String timerId(DoFn<InputT, OutputT> doFn) { | ||
| throw new UnsupportedOperationException( | ||
|
|
@@ -895,6 +927,11 @@ public CausedByDrain causedByDrain(DoFn<InputT, OutputT> doFn) { | |
| return causedByDrain; | ||
| } | ||
|
|
||
| @Override | ||
| public ValueKind valueKind(DoFn<InputT, OutputT> doFn) { | ||
| throw new UnsupportedOperationException("ValueKind parameters are not supported."); | ||
| } | ||
|
|
||
| @Override | ||
| public String timerId(DoFn<InputT, OutputT> doFn) { | ||
| return timerId; | ||
|
|
@@ -1041,6 +1078,11 @@ public void outputWithTimestamp(OutputT output, Instant timestamp) { | |
| outputWithTimestamp(mainOutputTag, output, timestamp); | ||
| } | ||
|
|
||
| @Override | ||
| public void outputWithKind(OutputT output, ValueKind kind) { | ||
| outputWithKind(mainOutputTag, output, kind); | ||
| } | ||
|
|
||
| @Override | ||
| public void outputWindowedValue( | ||
| OutputT output, | ||
|
|
@@ -1063,6 +1105,19 @@ public <T> void outputWithTimestamp(TupleTag<T> tag, T output, Instant timestamp | |
| tag, output, timestamp, Collections.singleton(window()), PaneInfo.NO_FIRING); | ||
| } | ||
|
|
||
| @Override | ||
| public <T> void outputWithKind(TupleTag<T> tag, T output, ValueKind kind) { | ||
| checkTimestamp(timestamp(), timestamp); | ||
| builderSupplier | ||
| .builder(output) | ||
| .setTimestamp(timestamp()) | ||
| .setWindows(Collections.singleton(window())) | ||
| .setPaneInfo(PaneInfo.NO_FIRING) | ||
| .setValueKind(kind) | ||
| .setReceiver(wv -> SimpleDoFnRunner.this.outputWindowedValue(tag, wv)) | ||
| .output(); | ||
| } | ||
|
|
||
|
ahmedabu98 marked this conversation as resolved.
|
||
| @Override | ||
| public <T> void outputWindowedValue( | ||
| TupleTag<T> tag, | ||
|
|
@@ -1228,6 +1283,11 @@ public TimeDomain timeDomain(DoFn<InputT, OutputT> doFn) { | |
| "Cannot access time domain outside of @ProcessTimer method."); | ||
| } | ||
|
|
||
| @Override | ||
| public ValueKind valueKind(DoFn<InputT, OutputT> doFn) { | ||
| throw new UnsupportedOperationException("ValueKind parameters are not supported."); | ||
| } | ||
|
|
||
| @Override | ||
| public KeyT key() { | ||
| return key; | ||
|
|
@@ -1330,6 +1390,11 @@ public void outputWithTimestamp(OutputT output, Instant timestamp) { | |
| outputWithTimestamp(mainOutputTag, output, timestamp); | ||
| } | ||
|
|
||
| @Override | ||
| public void outputWithKind(OutputT output, ValueKind kind) { | ||
| outputWithKind(mainOutputTag, output, kind); | ||
| } | ||
|
|
||
| @Override | ||
| public void outputWindowedValue( | ||
| OutputT output, | ||
|
|
@@ -1352,6 +1417,19 @@ public <T> void outputWithTimestamp(TupleTag<T> tag, T output, Instant timestamp | |
| tag, output, timestamp, Collections.singleton(window()), PaneInfo.NO_FIRING); | ||
| } | ||
|
|
||
| @Override | ||
| public <T> void outputWithKind(TupleTag<T> tag, T output, ValueKind kind) { | ||
| checkTimestamp(this.timestamp, timestamp); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| builderSupplier | ||
| .builder(output) | ||
| .setTimestamp(this.timestamp) | ||
| .setWindows(Collections.singleton(window())) | ||
| .setPaneInfo(PaneInfo.NO_FIRING) | ||
| .setReceiver(wv -> SimpleDoFnRunner.this.outputWindowedValue(tag, wv)) | ||
| .setValueKind(kind) | ||
| .output(); | ||
| } | ||
|
|
||
|
ahmedabu98 marked this conversation as resolved.
|
||
| @Override | ||
| public <T> void outputWindowedValue( | ||
| TupleTag<T> tag, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable
timestampis not defined in the scope of theoutputWithKindmethod, which will lead to a compilation error. This appears to be a copy-paste error from theoutputWithTimestampmethod. Since the output timestamp is implicitly the context's firing timestamp (timestamp()), this check is redundant and should be removed.