aokolnychyi commented on a change in pull request #3287:
URL: https://github.com/apache/iceberg/pull/3287#discussion_r736834925
##########
File path:
spark/v3.0/spark3/src/jmh/java/org/apache/iceberg/spark/source/IcebergSourceBenchmark.java
##########
@@ -187,4 +201,45 @@ protected void withTableProperties(Map<String, String>
props, Action action) {
restoreProperties.commit();
}
}
+
+ protected void writePosDeletes(CharSequence path, long numRows, double
percentage) throws IOException {
+ OutputFileFactory fileFactory = newFileFactory();
+ SparkFileWriterFactory writerFactory =
SparkFileWriterFactory.builderFor(table())
+ .dataFileFormat(fileFormat())
+ .build();
+
+ ClusteredPositionDeleteWriter<InternalRow> writer = new
ClusteredPositionDeleteWriter<>(
+ writerFactory, fileFactory, table().io(),
+ fileFormat(), TARGET_FILE_SIZE_IN_BYTES);
+
+ PartitionSpec unpartitionedSpec = table().specs().get(0);
+ Set<Long> deletedPos = Sets.newHashSet();
+ while (deletedPos.size() < numRows * percentage) {
+ deletedPos.add(ThreadLocalRandom.current().nextLong(numRows));
+ }
+
+ LOG.info("pos delete row count: {}", deletedPos.size());
+
+ PositionDelete<InternalRow> positionDelete = PositionDelete.create();
+ try (ClusteredPositionDeleteWriter<InternalRow> closeableWriter = writer) {
+ for (Long pos : deletedPos) {
+ positionDelete.set(path, pos, null);
+ closeableWriter.write(positionDelete, unpartitionedSpec, null);
+ }
+ }
+
+ RowDelta rowDelta = table().newRowDelta();
+ writer.result().deleteFiles().forEach(deleteFile ->
rowDelta.addDeletes(deleteFile));
Review comment:
nit: `rowDelta::addDeletes`
--
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]