Skip to content

Commit

Permalink
Spark 3.5: Adapt DeleteFileIndexBenchmark for DVs (apache#11529)
Browse files Browse the repository at this point in the history
  • Loading branch information
aokolnychyi authored and zachdisc committed Dec 12, 2024
1 parent 9d95e62 commit a0eec4e
Showing 1 changed file with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ public class DeleteFileIndexBenchmark {

private List<DataFile> dataFiles;

@Param({"true", "false"})
private boolean oneToOneMapping;
@Param({"partition", "file", "dv"})
private String type;

@Setup
public void setupBenchmark() throws NoSuchTableException, ParseException {
Expand All @@ -93,10 +93,12 @@ public void setupBenchmark() throws NoSuchTableException, ParseException {
}

private void initDataAndDeletes() {
if (oneToOneMapping) {
if (type.equals("partition")) {
initDataAndPartitionScopedDeletes();
} else if (type.equals("file")) {
initDataAndFileScopedDeletes();
} else {
initDataAndPartitionScopedDeletes();
initDataAndDVs();
}
}

Expand Down Expand Up @@ -183,6 +185,23 @@ private void initDataAndFileScopedDeletes() {
}
}

private void initDataAndDVs() {
for (int partitionOrdinal = 0; partitionOrdinal < NUM_PARTITIONS; partitionOrdinal++) {
StructLike partition = TestHelpers.Row.of(partitionOrdinal);

RowDelta rowDelta = table.newRowDelta();

for (int fileOrdinal = 0; fileOrdinal < NUM_DATA_FILES_PER_PARTITION; fileOrdinal++) {
DataFile dataFile = FileGenerationUtil.generateDataFile(table, partition);
DeleteFile dv = FileGenerationUtil.generateDV(table, dataFile);
rowDelta.addRows(dataFile);
rowDelta.addDeletes(dv);
}

rowDelta.commit();
}
}

private void setupSpark() {
this.spark =
SparkSession.builder()
Expand Down Expand Up @@ -240,7 +259,7 @@ private void initTable() throws NoSuchTableException, ParseException {
TableProperties.DELETE_MODE,
RowLevelOperationMode.MERGE_ON_READ.modeName(),
TableProperties.FORMAT_VERSION,
2);
type.equals("dv") ? 3 : 2);

this.table = Spark3Util.loadIcebergTable(spark, TABLE_NAME);
}
Expand Down

0 comments on commit a0eec4e

Please sign in to comment.