private List<DataFile> rewriterDataFiles() throws Exception {
    List<DataFile> result = Lists.newArrayList();
    TaskWriter<Record> writer = dataWriter();

    try (CloseableIterator<Record> records = dataReader.readData().iterator()) {
      while (records.hasNext()) {
        Record record = records.next();
        writer.write(record);
      }
    } finally {
      writer.close();
    }

    result.addAll(Arrays.asList(writer.dataFiles()));

    return result;
  }
An abstract OptimizingExecutor implementation that rewrites the rewrittenDataFiles in
RewriteInput and generates new position delete for rePosDeletedDataFiles.
amoro-format-iceberg/src/main/java/org/apache/amoro/optimizing/AbstractRewriteFilesExecutor.java