Skip to content

Commit

Permalink
feat: add apis for Mutation and RowMutationEntry (#1454)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
mutianf and gcf-owl-bot[bot] committed Oct 11, 2022
1 parent c03b8a4 commit a86934f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Expand Up @@ -87,6 +87,19 @@ public static Mutation fromProtoUnsafe(List<com.google.bigtable.v2.Mutation> pro
return mutation;
}

/**
* Wraps the List of protobuf {@link com.google.bigtable.v2.Mutation}. This methods, like {@link
* #createUnsafe()}, allows setCell operation to use server side timestamp. This is dangerous
* because mutations will no longer be idempotent, which might cause multiple duplicate values to
* be stored in Bigtable. This option should only be used for advanced usecases with extreme care.
*/
@BetaApi
public static Mutation fromProtoUnsafe(Iterable<com.google.bigtable.v2.Mutation> protos) {
Mutation mutation = new Mutation(true);
mutation.mutations.addAll(protos);
return mutation;
}

/**
* Constructs a row mutation from an existing protobuf object.
*
Expand Down
Expand Up @@ -15,6 +15,7 @@
*/
package com.google.cloud.bigtable.data.v2.models;

import com.google.api.core.BetaApi;
import com.google.api.core.InternalApi;
import com.google.bigtable.v2.MutateRowsRequest;
import com.google.common.base.Preconditions;
Expand Down Expand Up @@ -54,6 +55,13 @@ public static RowMutationEntry create(@Nonnull ByteString key) {
return new RowMutationEntry(key, Mutation.create());
}

/** Creates a new instance from existing mutation. */
@BetaApi
public static RowMutationEntry createFromMutationUnsafe(
@Nonnull ByteString key, @Nonnull Mutation mutation) {
return new RowMutationEntry(key, mutation);
}

/**
* Creates new instance of mutation builder which allows server timestamp for setCell operations.
*
Expand Down

0 comments on commit a86934f

Please sign in to comment.