Bigtable: Introducing new Batching API for Bigtable by rahulKQL · Pull Request #6133 · googleapis/google-cloud-java · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -34,7 +34,7 @@
* <p>This class is meant for manual batching, while {@link BulkMutationBatcher} is meant for
* automatic batching with flow control.
*/
public final class BulkMutation implements Serializable {
public final class BulkMutation implements Serializable, Cloneable {
private static final long serialVersionUID = 3522061250439399088L;

private final String tableId;
Expand Down Expand Up @@ -89,6 +89,16 @@ public BulkMutation add(@Nonnull ByteString rowKey, @Nonnull Mutation mutation)
return this;
}

/**
* Add mutation for a particular row. The changes in the mutation will be applied atomic. However
* there is no guarantees about the relative ordering between mutations affecting different rows.
*/
public BulkMutation add(@Nonnull RowMutationEntry entry) {
Preconditions.checkNotNull(entry, "Row mutation entry can't be null");
builder.addEntries(entry.toProto());
return this;
}

@InternalApi
public MutateRowsRequest toProto(RequestContext requestContext) {
String tableName =
Expand All @@ -100,4 +110,12 @@ public MutateRowsRequest toProto(RequestContext requestContext) {
.setAppProfileId(requestContext.getAppProfileId())
.build();
}

/** Creates a copy of {@link BulkMutation}. */
@Override
public BulkMutation clone() {
BulkMutation bulkMutation = BulkMutation.create(tableId);
bulkMutation.builder = this.builder.clone();
return bulkMutation;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,10 @@
import org.threeten.bp.Duration;

/**
* Tracker for outstanding bulk mutations. Allows for the caller to wait for all of the outstanding
* mutations to complete.
*
* @see com.google.cloud.bigtable.data.v2.BigtableDataClient#newBulkMutationBatcher() for example
* usage.
* @deprecated Please use {@link
* com.google.cloud.bigtable.data.v2.BigtableDataClient#newBulkMutationBatcher(String)} API.
*/
@Deprecated
@BetaApi("This surface is likely to change as the batching surface evolves.")
public final class BulkMutationBatcher implements AutoCloseable {
private final UnaryCallable<RowMutation, Void> callable;
Expand Down
Loading