beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apill...@apache.org
Subject [beam] 01/02: Make it functional
Date Mon, 30 Aug 2021 23:42:40 GMT
This is an automated email from the ASF dual-hosted git repository.

apilloud pushed a commit to branch updatecalcite
in repository https://gitbox.apache.org/repos/asf/beam.git

commit 01101b397b78efa2a21447f7de45231ecb609c9a
Author: Andrew Pilloud <apilloud@google.com>
AuthorDate: Mon Aug 30 15:30:06 2021 -0700

    Make it functional
---
 .../sql/impl/planner/RelMdNodeStats.java           | 27 ++++++++--------------
 1 file changed, 10 insertions(+), 17 deletions(-)

diff --git a/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/planner/RelMdNodeStats.java
b/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/planner/RelMdNodeStats.java
index cfc40e9..ede7586 100644
--- a/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/planner/RelMdNodeStats.java
+++ b/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/planner/RelMdNodeStats.java
@@ -17,9 +17,10 @@
  */
 package org.apache.beam.sdk.extensions.sql.impl.planner;
 
-import java.util.ArrayList;
+import static org.apache.beam.sdk.util.Preconditions.checkArgumentNotNull;
+
 import java.util.List;
-import java.util.Set;
+import java.util.stream.Collectors;
 import org.apache.beam.sdk.extensions.sql.impl.rel.BeamRelNode;
 import org.apache.beam.vendor.calcite.v1_26_0.com.google.common.collect.Table;
 import org.apache.beam.vendor.calcite.v1_26_0.org.apache.calcite.rel.RelNode;
@@ -72,21 +73,13 @@ public class RelMdNodeStats implements MetadataHandler<NodeStatsMetadata>
{
     // wraps the metadata provider with CachingRelMetadataProvider. However,
     // CachingRelMetadataProvider checks timestamp before returning previous results. Therefore,
     // there wouldn't be a problem in that case.
-    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 != null)
+            .filter(entry -> entry.getValue() != null)
+            .filter(entry -> entry.getValue() instanceof NodeStats)
+            .filter(entry -> (checkArgumentNotNull((NodeStats) entry.getValue()).isUnknown())
+            .collect(Collectors.toList());
 
     keys.forEach(cell -> mq.map.remove(cell.getRowKey(), cell.getColumnKey()));
 

Mime
View raw message