southernriver commented on a change in pull request #2800:
URL: https://github.com/apache/iceberg/pull/2800#discussion_r667416653
##########
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:
Yeap! But another reason is we can keep the style consistent with spark3
module, a little bit of optimization with array as follow
[:R153](https://github.com/apache/iceberg/pull/2800/files#diff-47b9fbed0d32a8f8ec128a4f78cd93f238e65c38f93e9a10d257eb83838563ffR153),
how do you think?
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]