Skip to content

Commit 761d384

Browse files
authored
---
yaml --- r: 18143 b: refs/heads/pubsub-ordering-keys c: 1baa602 h: refs/heads/master i: 18141: a859960 18139: bef4033 18135: 603cae8 18127: 7905725 18111: 1cbd452
1 parent 0a5303f commit 761d384

3 files changed

Lines changed: 16 additions & 1 deletion

File tree

  • branches/pubsub-ordering-keys/google-cloud-clients/google-cloud-bigtable/src

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ refs/tags/v0.72.0: a7703f2593ba312c0b2dde6fdfd4f5c764bb55ac
159159
refs/tags/v0.73.0: 21241ea8be9439cc5764c4944cdce21d34ce4f9e
160160
refs/tags/v0.74.0: 9d1f733dbbf790de7b494418523b69c4a9a57638
161161
refs/heads/ignoretest: 23c412ae07af3d0ab1caa2d44d5bc5c0ccb8b31d
162-
refs/heads/pubsub-ordering-keys: 81bdd008363130086ab4a328e28bfbe13ede8ed3
162+
refs/heads/pubsub-ordering-keys: 1baa6023966a694c1ccd8ed8d5b47ece662b4fce
163163
"refs/heads/update_mvn_badge": ae2d773814db0f71197ccf5a8612ee1d8056f8de
164164
refs/tags/v0.75.0: c3673089ae09a897c1b4cf7dfe167fe4f8ab32fb
165165
refs/tags/v0.76.0: 395b016826d3ddf9cb8b34919636df15a4dbd032

branches/pubsub-ordering-keys/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/pubsub-ordering-keys/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)