Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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 @@ -73,6 +73,15 @@ public static Mutation createUnsafe() {
return new Mutation(true);
}


/** Wraps the List of protobuf {@link com.google.bigtable.v2.Mutation}. */
Copy link

@igorbernstein2 igorbernstein2 Feb 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a warning similar to createUnsafe:

It is the callers responsibility to make sure that all of the mutations have a deterministric timestamp. If a mutation has a serverside timestamp, then the mutation will no longer be idempotent, which might cause duplicate values to be stored in Bigtable. This option should only be used for advanced usecases with extreme care.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BetaApi
public static Mutation fromProtoUnsafe(List<com.google.bigtable.v2.Mutation> protos) {
Mutation mutation = new Mutation(true);
mutation.mutations.addAll(protos);
return mutation;
}

private Mutation(boolean allowServersideTimestamp) {
this.allowServersideTimestamp = allowServersideTimestamp;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ public void setCellTest() {
assertThat(actual.get(3).getSetCell().getValue())
.isEqualTo(ByteString.copyFromUtf8("fake-value2"));
assertThat(actual.get(3).getSetCell().getTimestampMicros()).isIn(expectedTimestampRange);

assertThat(Mutation.fromProtoUnsafe(actual).getMutations()).isEqualTo(actual);
}

@Test
Expand Down