Skip to content

Commit 8f2cf2c

Browse files
authored
---
yaml --- r: 17209 b: refs/heads/autosynth-spanner c: 1baa602 h: refs/heads/master i: 17207: 52741cf
1 parent 4a860b5 commit 8f2cf2c

3 files changed

Lines changed: 16 additions & 1 deletion

File tree

  • branches/autosynth-spanner/google-cloud-clients/google-cloud-bigtable/src

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ refs/heads/autosynth-os-login: a88a337797996a205873040a63abe1d3116f5789
140140
refs/heads/autosynth-redis: 0cdb2e47359d51b73763bcea8af3de62aa99119b
141141
refs/heads/autosynth-scheduler: d97f8743ba965c7d5e492c8dc1f51d023104e260
142142
refs/heads/autosynth-securitycenter: 8e95447ccb176c3648880ee0cb926cd1f4065156
143-
refs/heads/autosynth-spanner: 81bdd008363130086ab4a328e28bfbe13ede8ed3
143+
refs/heads/autosynth-spanner: 1baa6023966a694c1ccd8ed8d5b47ece662b4fce
144144
refs/heads/autosynth-speech: 878243784f42771467d7cf52bd59e4a6a7950ee9
145145
refs/heads/autosynth-tasks: afc9f4da54964dea5e7f3a9b164db282fc35db5c
146146
refs/heads/autosynth-texttospeech: 0e26ec9b0ed5bbedc038dea32bbb44bae0883668

branches/autosynth-spanner/google-cloud-clients/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/Mutation.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,19 @@ public static Mutation createUnsafe() {
7373
return new Mutation(true);
7474
}
7575

76+
/**
77+
* Wraps the List of protobuf {@link com.google.bigtable.v2.Mutation}. This methods, like {@link
78+
* #createUnsafe()}, allows setCell operation to use server side timestamp. This is dangerous
79+
* because mutations will no longer be idempotent, which might cause multiple duplicate values to
80+
* be stored in Bigtable. This option should only be used for advanced usecases with extreme care.
81+
*/
82+
@BetaApi
83+
public static Mutation fromProtoUnsafe(List<com.google.bigtable.v2.Mutation> protos) {
84+
Mutation mutation = new Mutation(true);
85+
mutation.mutations.addAll(protos);
86+
return mutation;
87+
}
88+
7689
private Mutation(boolean allowServersideTimestamp) {
7790
this.allowServersideTimestamp = allowServersideTimestamp;
7891
}

branches/autosynth-spanner/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/models/MutationTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ public void setCellTest() {
9595
assertThat(actual.get(3).getSetCell().getValue())
9696
.isEqualTo(ByteString.copyFromUtf8("fake-value2"));
9797
assertThat(actual.get(3).getSetCell().getTimestampMicros()).isIn(expectedTimestampRange);
98+
99+
assertThat(Mutation.fromProtoUnsafe(actual).getMutations()).isEqualTo(actual);
98100
}
99101

100102
@Test

0 commit comments

Comments
 (0)