apilloud commented on a change in pull request #14729:
URL: https://github.com/apache/beam/pull/14729#discussion_r698811973



##########
File path: 
sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/planner/RelMdNodeStats.java
##########
@@ -71,16 +72,34 @@ private NodeStats getBeamNodeStats(BeamRelNode rel, 
RelMetadataQuery mq) {
     // wraps the metadata provider with CachingRelMetadataProvider. However,
     // CachingRelMetadataProvider checks timestamp before returning previous 
results. Therefore,
     // there wouldn't be a problem in that case.
-    List<List> keys =
-        mq.map.entrySet().stream()
-            .filter(entry -> entry.getValue() instanceof NodeStats)
-            .filter(entry -> ((NodeStats) entry.getValue()).isUnknown())
-            .map(Map.Entry::getKey)
-            .collect(Collectors.toList());
-
-    for (List key : keys) {
-      mq.map.remove(key);
+    Set<Table.Cell<RelNode, List, Object>> cells = mq.map.cellSet();
+    List<Table.Cell<RelNode, List, Object>> keys = new 
ArrayList<>(cells.size());
+    for (Table.Cell<RelNode, List, Object> cell : cells) {
+      if (cell == null) {
+        continue;
+      }
+      Object rawValue = cell.getValue();
+      if (!(rawValue instanceof NodeStats)) {
+        continue;
+      }
+      NodeStats nodeStats = (NodeStats) rawValue;
+      if (nodeStats.isUnknown()) {
+        keys.add(cell);
+      }
     }
+    //    List<Table.Cell<RelNode, List, Object>> keys =
+    //        mq.map.cellSet().stream()
+    //            .filter(entry -> entry.getValue() instanceof NodeStats)
+    //            .filter(entry -> ((NodeStats) entry.getValue()).isUnknown())
+    //            .collect(Collectors.toList());
+
+    // === > Task :sdks:java:extensions:sql:compileJava
+    // ===   error: [dereference.of.nullable] dereference of possibly-null 
reference
+    //       ((NodeStats)entry.getValue())
+    // ===   .filter(entry -> ((NodeStats) entry.getValue()).isUnknown())
+    // ===   ^

Review comment:
       Deleted.




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