-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Omit state commits in stateful Dofn #37691
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
LEEKYE
wants to merge
9
commits into
apache:master
Choose a base branch
from
LEEKYE:stateful_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.
+137
−36
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
90d6c96
Propagate 'has_no_state' and 'only_bundle_for_keys' bits from Process…
LEEKYE 4b6d584
Skip StateRequest construction if the bits are true
LEEKYE 708247a
minor fix
LEEKYE 6ef00e8
minor fix
LEEKYE da95d80
minor fix
LEEKYE b4836e6
if has_no_state is true, will not load prefetched response
LEEKYE cfe916c
when has_no_state is true, continuationToken set to null
LEEKYE 1e4fd75
simplify
LEEKYE d5acb6b
Update sdks/java/harness/src/main/java/org/apache/beam/fn/harness/sta…
LEEKYE 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
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
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
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 |
|---|---|---|
|
|
@@ -72,6 +72,8 @@ public class MultimapUserState<K, V> { | |
|
|
||
| private boolean isClosed; | ||
| private boolean isCleared; | ||
| private final boolean hasNoState; | ||
| private final boolean onlyBundleForKeys; | ||
| // Pending updates to persistent storage | ||
| private HashMap<Object, K> pendingRemoves = Maps.newHashMap(); | ||
| private HashMap<Object, KV<K, List<V>>> pendingAdds = Maps.newHashMap(); | ||
|
|
@@ -84,7 +86,9 @@ public MultimapUserState( | |
| String instructionId, | ||
| StateKey stateKey, | ||
| Coder<K> mapKeyCoder, | ||
| Coder<V> valueCoder) { | ||
| Coder<V> valueCoder, | ||
| boolean hasNoState, | ||
| boolean onlyBundleForKeys) { | ||
LEEKYE marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| checkArgument( | ||
| stateKey.hasMultimapKeysUserState(), | ||
| "Expected MultimapKeysUserState StateKey but received %s.", | ||
|
|
@@ -93,14 +97,16 @@ public MultimapUserState( | |
| this.beamFnStateClient = beamFnStateClient; | ||
| this.mapKeyCoder = mapKeyCoder; | ||
| this.valueCoder = valueCoder; | ||
| this.hasNoState = hasNoState; | ||
| this.onlyBundleForKeys = onlyBundleForKeys; | ||
|
|
||
| // Note: These StateRequest protos are constructed even if we never try to read the | ||
| // corresponding state type. Consider constructing them lazily, as needed. | ||
| this.keysStateRequest = | ||
| StateRequest.newBuilder().setInstructionId(instructionId).setStateKey(stateKey).build(); | ||
| this.persistedKeys = | ||
| StateFetchingIterators.readAllAndDecodeStartingFrom( | ||
| cache, beamFnStateClient, keysStateRequest, mapKeyCoder); | ||
| cache, beamFnStateClient, keysStateRequest, mapKeyCoder, hasNoState); | ||
|
|
||
| StateRequest.Builder userStateRequestBuilder = StateRequest.newBuilder(); | ||
| userStateRequestBuilder | ||
|
|
@@ -128,7 +134,8 @@ public MultimapUserState( | |
| Caches.subCache(this.cache, "AllEntries"), | ||
| beamFnStateClient, | ||
| entriesStateRequest, | ||
| KvCoder.of(mapKeyCoder, IterableCoder.of(valueCoder))); | ||
| KvCoder.of(mapKeyCoder, IterableCoder.of(valueCoder)), | ||
| hasNoState); | ||
| } | ||
|
|
||
| public void clear() { | ||
|
|
@@ -438,7 +445,7 @@ private void startStateApiWrites() { | |
| } | ||
|
|
||
| // Persist pending key-values | ||
| if (!pendingAdds.isEmpty()) { | ||
| if (!pendingAdds.isEmpty() && !onlyBundleForKeys) { | ||
|
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. |
||
| for (KV<K, List<V>> entry : pendingAdds.values()) { | ||
| StateRequest request = createUserStateRequest(entry.getKey()); | ||
| beamFnStateClient.handle( | ||
|
|
@@ -542,7 +549,8 @@ private CachingStateIterable<V> getPersistedValues(Object structuralKey, K key) | |
| request.getStateKey().getMultimapUserState().getMapKey()), | ||
| beamFnStateClient, | ||
| request, | ||
| valueCoder)); | ||
| valueCoder, | ||
| hasNoState)); | ||
| }) | ||
| .getValue(); | ||
| } | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.