You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/09/11 16:27:14 UTC

[GitHub] [spark] srowen commented on a diff in pull request #37843: [SPARK-40398][CORE][SQL] Use Loop instead of Arrays.stream api

srowen commented on code in PR #37843:
URL: https://github.com/apache/spark/pull/37843#discussion_r967854269


##########
sql/catalyst/src/main/java/org/apache/spark/sql/connector/expressions/Expression.java:
##########
@@ -44,7 +44,16 @@ public interface Expression {
    * List of fields or columns that are referenced by this expression.
    */
   default NamedReference[] references() {
-    return Arrays.stream(children()).map(e -> e.references())
-      .flatMap(Arrays::stream).distinct().toArray(NamedReference[]::new);
+    List<NamedReference> list = new ArrayList<>();
+    Set<NamedReference> uniqueValues = new HashSet<>();
+    for (Expression e : children()) {
+      NamedReference[] references = e.references();
+      for (NamedReference reference : references) {
+        if (uniqueValues.add(reference)) {
+          list.add(reference);
+        }
+      }
+    }
+    return list.toArray(new NamedReference[0]);

Review Comment:
   OK that's fine, thanks for checking. Whatever seems most efficient



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org