stankiewicz commented on code in PR #41303:
URL: https://github.com/apache/beam/pull/41303#discussion_r4585576414


##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/windmill/state/WindmillMultimap.java:
##########
@@ -115,15 +115,31 @@ public void put(K key, V value) {
   // Initiates a backend state read to fetch all entries if necessary.
   private Future<Iterable<Map.Entry<ByteString, Iterable<V>>>> 
necessaryEntriesFromStorageFuture(
       boolean omitValues) {
-    if (complete) {
-      // Since we're complete, even if there are entries in storage we don't 
need to read them.
+    if (complete || (omitValues && allKeysKnown)) {
+      // Since we're complete (or all keys are known when only keys are 
requested), even if there
+      // are entries in storage we don't need to read them.
       return Futures.immediateFuture(Collections.emptyList());
     } else {
       return reader.multimapFetchAllFuture(
           omitValues, stateKey.byteString(), stateFamily, valueCoder);
     }
   }
 
+  private boolean isKeyValuesCached(Object structuralKey) {
+    if (complete) {
+      return true;
+    }
+    KeyState keyState = keyStateMap.get(structuralKey);
+    if (allKeysKnown
+        && (keyState == null || keyState.existence == 
KeyExistence.UNKNOWN_EXISTENCE)) {

Review Comment:
   it's short circuilt, similar to what is already implemented in read():
   
   ```
   if (allKeysKnown) {
           keyState = keyStateMap.get(structuralKey);
           if (keyState == null || keyState.existence == 
KeyExistence.UNKNOWN_EXISTENCE) {
             if (keyState != null) keyStateMap.remove(structuralKey);
             return Collections.emptyList();
           }
   ```
   It looks counterintuitive by name, but allKeysKnown == true changes 
UNKNOWN_EXISTENCE meaning.
   
   Could replace it with:
   
   ```
   if (allKeysKnown && (keyState == null || keyState.existence != 
KeyExistence.KNOWN_EXIST)) { return true; } ```
   
   



-- 
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]

Reply via email to