From f55c0dc91b1655d6d69433e3368de7bbd5d052d4 Mon Sep 17 00:00:00 2001 From: David Rabinowitz Date: Tue, 15 Aug 2023 17:46:51 -0700 Subject: [PATCH] Code simplification (#1041) --- .../com/google/cloud/spark/bigquery/SparkBigQueryUtil.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/spark-bigquery-connector-common/src/main/java/com/google/cloud/spark/bigquery/SparkBigQueryUtil.java b/spark-bigquery-connector-common/src/main/java/com/google/cloud/spark/bigquery/SparkBigQueryUtil.java index d7012cdc8..25e5032ae 100644 --- a/spark-bigquery-connector-common/src/main/java/com/google/cloud/spark/bigquery/SparkBigQueryUtil.java +++ b/spark-bigquery-connector-common/src/main/java/com/google/cloud/spark/bigquery/SparkBigQueryUtil.java @@ -43,7 +43,6 @@ import org.apache.spark.sql.internal.SQLConf; import org.apache.spark.sql.sources.Filter; import org.apache.spark.sql.types.Metadata; -import scala.collection.Iterator; /** Spark related utilities */ public class SparkBigQueryUtil { @@ -203,11 +202,7 @@ public static String getTableNameFromOptions(Map options) { public static ImmutableMap scalaMapToJavaMap( scala.collection.immutable.Map map) { ImmutableMap.Builder result = ImmutableMap.builder(); - Iterator keysIterator = map.keys().iterator(); - while (keysIterator.hasNext()) { - K key = keysIterator.next(); - result.put(key, map.get(key).get()); - } + map.foreach(entry -> result.put(entry._1(), entry._2())); return result.build(); }