Skip to content

Commit

Permalink
Add benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
aokolnychyi committed Dec 14, 2023
1 parent 38c0392 commit 6d806be
Showing 1 changed file with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
Expand Down Expand Up @@ -80,6 +81,9 @@ public class DeleteFileIndexBenchmark {

private List<DataFile> dataFiles;

@Param({"true", "false"})
private boolean oneToOneMapping;

@Setup
public void setupBenchmark() throws NoSuchTableException, ParseException {
setupSpark();
Expand All @@ -88,6 +92,14 @@ public void setupBenchmark() throws NoSuchTableException, ParseException {
loadDataFiles();
}

private void initDataAndDeletes() {
if (oneToOneMapping) {
initDataAndFileScopedDeletes();
} else {
initDataAndPartitionScopedDeletes();
}
}

@TearDown
public void tearDownBenchmark() {
dropTable();
Expand Down Expand Up @@ -134,7 +146,7 @@ private DeleteFileIndex buildDeletes() {
.build();
}

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

Expand All @@ -154,6 +166,23 @@ private void initDataAndDeletes() {
}
}

private void initDataAndFileScopedDeletes() {
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 deleteFile = FileGenerationUtil.generatePositionDeleteFile(table, dataFile);
rowDelta.addRows(dataFile);
rowDelta.addDeletes(deleteFile);
}

rowDelta.commit();
}
}

private void setupSpark() {
this.spark =
SparkSession.builder()
Expand Down

0 comments on commit 6d806be

Please sign in to comment.