reuvenlax commented on code in PR #41540:
URL: https://github.com/apache/beam/pull/41540#discussion_r4762826441
##########
sdks/java/harness/src/main/java/org/apache/beam/fn/harness/state/MultimapUserState.java:
##########
Review Comment:
Javadoc comment added
##########
sdks/java/harness/src/main/java/org/apache/beam/fn/harness/state/MultimapUserState.java:
##########
@@ -419,88 +439,203 @@ public void asyncClose() throws Exception {
return;
}
- startStateApiWrites();
- updateCache();
- }
+ ByteStringOutputStream encodeOut =
+ (pendingRemoves.isEmpty() && pendingAdds.isEmpty()) ? null : new
ByteStringOutputStream();
- @SuppressWarnings("FutureReturnValueIgnored")
- private void startStateApiWrites() {
- // Clear currently persisted key-values
+ // Clear currently persisted key-values, saving encoded requests so each
removed key is only
+ // encoded once across the clear RPC and cache update.
+ Map<Object, StateRequest> encodedRemoves = Collections.emptyMap();
if (isCleared) {
beamFnStateClient.handle(
keysStateRequest.toBuilder().setClear(StateClearRequest.getDefaultInstance()));
} else if (!pendingRemoves.isEmpty()) {
- for (K key : pendingRemoves.values()) {
- StateRequest request = createUserStateRequest(key);
+ encodedRemoves = Maps.newHashMapWithExpectedSize(pendingRemoves.size());
+ for (Map.Entry<Object, K> entry : pendingRemoves.entrySet()) {
+ StateRequest request = createUserStateRequest(entry.getValue(),
encodeOut);
+ encodedRemoves.put(entry.getKey(), request);
beamFnStateClient.handle(
request.toBuilder().setClear(StateClearRequest.getDefaultInstance()));
}
}
- // Persist pending key-values
+ List<K> pendingAddsKeys =
+ pendingAdds.isEmpty() ? Collections.emptyList() : new
ArrayList<>(pendingAdds.size());
+ long pendingAddsKeysBytes = 0;
+ List<PendingCacheUpdate<V>> pendingCacheUpdates = null;
Review Comment:
done
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]