You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2021/07/10 15:59:20 UTC

[GitHub] [iceberg] southernriver commented on a change in pull request #2800: Spark: Parallelize initializing readTasks when localityPreferred is true

southernriver commented on a change in pull request #2800:
URL: https://github.com/apache/iceberg/pull/2800#discussion_r667355630



##########
File path: spark2/src/main/java/org/apache/iceberg/spark/source/Reader.java
##########
@@ -227,11 +246,17 @@ public StructType readSchema() {
     Broadcast<Table> tableBroadcast = sparkContext.broadcast(SerializableTable.copyOf(table));
 
     List<InputPartition<InternalRow>> readTasks = Lists.newArrayList();
-    for (CombinedScanTask task : tasks()) {
-      readTasks.add(new ReadTask<>(
-          task, tableBroadcast, expectedSchemaString, caseSensitive,
-          localityPreferred, InternalRowReaderFactory.INSTANCE));
-    }
+    Tasks.foreach(tasks())
+        .stopOnFailure()
+        .executeWith(readTasksInitExecutorService)
+        .run(task -> {
+          InputPartition<InternalRow> readTask = new ReadTask<>(
+              task, tableBroadcast, expectedSchemaString, caseSensitive,
+              localityPreferred, InternalRowReaderFactory.INSTANCE);
+          synchronized (readTasks) {
+            readTasks.add(readTask);

Review comment:
       Maybe it‘s better to use array instead of list, and then we can avoid to add lock or temporary var ? 




-- 
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: issues-unsubscribe@iceberg.apache.org

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



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org