Skip to content

Commit a86934f

Browse files
feat: add apis for Mutation and RowMutationEntry (#1454)
* feat: add apis for Mutation and RowMutationEntry * use iterable instead of iterator * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent c03b8a4 commit a86934f

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/Mutation.java

+13
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,19 @@ public static Mutation fromProtoUnsafe(List<com.google.bigtable.v2.Mutation> pro
8787
return mutation;
8888
}
8989

90+
/**
91+
* Wraps the List of protobuf {@link com.google.bigtable.v2.Mutation}. This methods, like {@link
92+
* #createUnsafe()}, allows setCell operation to use server side timestamp. This is dangerous
93+
* because mutations will no longer be idempotent, which might cause multiple duplicate values to
94+
* be stored in Bigtable. This option should only be used for advanced usecases with extreme care.
95+
*/
96+
@BetaApi
97+
public static Mutation fromProtoUnsafe(Iterable<com.google.bigtable.v2.Mutation> protos) {
98+
Mutation mutation = new Mutation(true);
99+
mutation.mutations.addAll(protos);
100+
return mutation;
101+
}
102+
90103
/**
91104
* Constructs a row mutation from an existing protobuf object.
92105
*

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/RowMutationEntry.java

+8
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package com.google.cloud.bigtable.data.v2.models;
1717

18+
import com.google.api.core.BetaApi;
1819
import com.google.api.core.InternalApi;
1920
import com.google.bigtable.v2.MutateRowsRequest;
2021
import com.google.common.base.Preconditions;
@@ -54,6 +55,13 @@ public static RowMutationEntry create(@Nonnull ByteString key) {
5455
return new RowMutationEntry(key, Mutation.create());
5556
}
5657

58+
/** Creates a new instance from existing mutation. */
59+
@BetaApi
60+
public static RowMutationEntry createFromMutationUnsafe(
61+
@Nonnull ByteString key, @Nonnull Mutation mutation) {
62+
return new RowMutationEntry(key, mutation);
63+
}
64+
5765
/**
5866
* Creates new instance of mutation builder which allows server timestamp for setCell operations.
5967
*

0 commit comments

Comments
 (0)