Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add apis for Mutation and RowMutationEntry #1454

Merged
merged 3 commits into from
Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -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
Original file line number Diff line number Diff line change
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