in grpc-gcp-benchmarks/src/main/SpannerClientTestCases.java [77:111]
public void prepareTestData() throws InterruptedException {
Spanner spanner = spannerOptions.getService();
DatabaseClient db = getDbClient(spanner);
try {
long start = System.currentTimeMillis();
// Clean the existing data.
List<Mutation> deletes = new ArrayList<>();
deletes.add(Mutation.delete(LARGE_TABLE, KeySet.all()));
db.write(deletes);
System.out.println(
String.format(
"\nDeleted the previous large_table in %d ms.", System.currentTimeMillis() - start));
List<Mutation> mutations = new ArrayList<>();
for (int j = 1; j <= numOfThreads; j++) {
for (int k = 1; k <= numOfRpcs; k++) {
mutations.add(
Mutation.newInsertBuilder(LARGE_TABLE)
.set("id")
.to("SpannerClient-rpc" + k + "thread" + j)
.set("data")
.to(colContent)
.build());
}
}
start = System.currentTimeMillis();
db.write(mutations);
System.out.println(
String.format(
"\nLarge test table generated in %d ms.", System.currentTimeMillis() - start));
} finally {
spanner.close();
}
}