Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -953,9 +953,23 @@ public SpannerWriteResult expand(PCollection<Mutation> input) {
@Override
public void populateDisplayData(DisplayData.Builder builder) {
super.populateDisplayData(builder);
populateDisplayDataWithParamaters(builder);
}

private void populateDisplayDataWithParamaters(DisplayData.Builder builder) {
getSpannerConfig().populateDisplayData(builder);
builder.add(
DisplayData.item("batchSizeBytes", getBatchSizeBytes()).withLabel("Batch Size in Bytes"));
DisplayData.item("batchSizeBytes", getBatchSizeBytes())
.withLabel("Max batch size in bytes"));
builder.add(
DisplayData.item("maxNumMutations", getMaxNumMutations())
.withLabel("Max number of mutated cells in each batch"));
builder.add(
DisplayData.item("maxNumRows", getMaxNumRows())
.withLabel("Max number of rows in each batch"));
builder.add(
DisplayData.item("groupingFactor", getGroupingFactor())
.withLabel("Number of batches to sort over"));
}
}

Expand Down Expand Up @@ -992,6 +1006,12 @@ public WriteGrouped(Write spec) {
this.spec = spec;
}

@Override
public void populateDisplayData(DisplayData.Builder builder) {
super.populateDisplayData(builder);
spec.populateDisplayDataWithParamaters(builder);
}

@Override
public SpannerWriteResult expand(PCollection<MutationGroup> input) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -589,20 +589,50 @@ public void retryOnAbortedAndDeadlineExceeded() throws InterruptedException {
}

@Test
public void displayData() throws Exception {
public void displayDataWrite() throws Exception {
SpannerIO.Write write =
SpannerIO.write()
.withProjectId("test-project")
.withInstanceId("test-instance")
.withDatabaseId("test-database")
.withBatchSizeBytes(123);
.withBatchSizeBytes(123)
.withMaxNumMutations(456)
.withMaxNumRows(789)
.withGroupingFactor(100);

DisplayData data = DisplayData.from(write);
assertThat(data.items(), hasSize(4));
assertThat(data.items(), hasSize(7));
assertThat(data, hasDisplayItem("projectId", "test-project"));
assertThat(data, hasDisplayItem("instanceId", "test-instance"));
assertThat(data, hasDisplayItem("databaseId", "test-database"));
assertThat(data, hasDisplayItem("batchSizeBytes", 123));
assertThat(data, hasDisplayItem("maxNumMutations", 456));
assertThat(data, hasDisplayItem("maxNumRows", 789));
assertThat(data, hasDisplayItem("groupingFactor", 100));
}

@Test
public void displayDataWriteGrouped() throws Exception {
SpannerIO.WriteGrouped writeGrouped =
SpannerIO.write()
.withProjectId("test-project")
.withInstanceId("test-instance")
.withDatabaseId("test-database")
.withBatchSizeBytes(123)
.withMaxNumMutations(456)
.withMaxNumRows(789)
.withGroupingFactor(100)
.grouped();

DisplayData data = DisplayData.from(writeGrouped);
assertThat(data.items(), hasSize(7));
assertThat(data, hasDisplayItem("projectId", "test-project"));
assertThat(data, hasDisplayItem("instanceId", "test-instance"));
assertThat(data, hasDisplayItem("databaseId", "test-database"));
assertThat(data, hasDisplayItem("batchSizeBytes", 123));
assertThat(data, hasDisplayItem("maxNumMutations", 456));
assertThat(data, hasDisplayItem("maxNumRows", 789));
assertThat(data, hasDisplayItem("groupingFactor", 100));
}

@Test
Expand Down