pvary commented on code in PR #16015:
URL: https://github.com/apache/iceberg/pull/16015#discussion_r3130140959
##########
flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/sink/dynamic/DynamicWriter.java:
##########
@@ -172,34 +182,65 @@ public String toString() {
@Override
public Collection<DynamicWriteResult> prepareCommit() throws IOException {
- List<DynamicWriteResult> result = Lists.newArrayList();
- for (Map.Entry<WriteTarget, TaskWriter<RowData>> entry :
writers.entrySet()) {
- long startNano = System.nanoTime();
- WriteResult writeResult = entry.getValue().complete();
- WriteTarget writeTarget = entry.getKey();
- metrics.updateFlushResult(writeTarget.tableName(), writeResult);
- metrics.flushDuration(
- writeTarget.tableName(),
TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startNano));
- LOG.debug(
- "Iceberg writer for table {} subtask {} attempt {} flushed {} data
files and {} delete files",
- writeTarget.tableName(),
- subTaskId,
- attemptId,
- writeResult.dataFiles().length,
- writeResult.deleteFiles().length);
+ List<CompletableFuture<FlushOutcome>> futures =
+ writers.entrySet().stream().map(e -> flushAsync(e.getKey(),
e.getValue())).toList();
+ writers.clear();
+
+ try {
+
CompletableFuture.allOf(futures.toArray(CompletableFuture[]::new)).join();
+ } catch (CompletionException e) {
+ Throwable cause = e.getCause();
+ if (cause instanceof UncheckedIOException uncheckedIOException) {
+ throw uncheckedIOException.getCause();
+ }
+ throw new IOException(cause);
Review Comment:
nit: newline, or else
```suggestion
} else {
throw new IOException(cause);
}
```
--
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]