Skip to content

Commit

Permalink
remove checks
Browse files Browse the repository at this point in the history
  • Loading branch information
mutianf committed Jul 10, 2023
1 parent aad796d commit d5f5530
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/
package com.google.cloud.bigtable.data.v2.models;

import static com.google.cloud.bigtable.data.v2.models.RowMutationEntry.MAX_MUTATION;

import com.google.api.core.BetaApi;
import com.google.api.core.InternalApi;
import com.google.bigtable.v2.MutateRowsRequest;
Expand All @@ -37,14 +35,11 @@
* <p>This class is meant for manual batching.
*/
public final class BulkMutation implements Serializable, Cloneable {

private static final long serialVersionUID = 3522061250439399088L;

private final String tableId;
private transient MutateRowsRequest.Builder builder;

private long mutationCountSum = 0;

public static BulkMutation create(String tableId) {
return new BulkMutation(tableId);
}
Expand Down Expand Up @@ -86,12 +81,6 @@ public BulkMutation add(@Nonnull ByteString rowKey, @Nonnull Mutation mutation)
Preconditions.checkNotNull(rowKey);
Preconditions.checkNotNull(mutation);

long mutationCount = mutation.getMutations().size();
Preconditions.checkArgument(
mutationCountSum + mutationCount <= MAX_MUTATION,
String.format("Too many mutations, got %s, limit is %s", mutationCountSum, MAX_MUTATION));
this.mutationCountSum += mutationCount;

builder.addEntries(
MutateRowsRequest.Entry.newBuilder()
.setRowKey(rowKey)
Expand All @@ -106,7 +95,6 @@ public BulkMutation add(@Nonnull ByteString rowKey, @Nonnull Mutation mutation)
*/
public BulkMutation add(@Nonnull RowMutationEntry entry) {
Preconditions.checkNotNull(entry, "Row mutation entry can't be null");

builder.addEntries(entry.toProto());
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
public class RowMutationEntry implements MutationApi<RowMutationEntry>, Serializable {
private static final long serialVersionUID = 1974738836742298192L;

static final int MAX_MUTATION = 100000;

private final ByteString key;
private final Mutation mutation;

Expand Down Expand Up @@ -182,11 +180,6 @@ public RowMutationEntry deleteRow() {

@InternalApi
public MutateRowsRequest.Entry toProto() {
Preconditions.checkArgument(
mutation.getMutations().size() <= MAX_MUTATION,
String.format(
"Too many mutations, got %s, limit is %s",
mutation.getMutations().size(), MAX_MUTATION));
return MutateRowsRequest.Entry.newBuilder()
.setRowKey(key)
.addAllMutations(mutation.getMutations())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
Expand Down Expand Up @@ -173,31 +172,4 @@ public void fromProtoTest() {
.matches(NameUtil.formatTableName(projectId, instanceId, TABLE_ID));
assertThat(overriddenRequest.getAppProfileId()).matches(appProfile);
}

@Test
public void testManyMutations() {
BulkMutation bulkMutation = BulkMutation.create(TABLE_ID);

try {
for (int i = 0; i < 3; i++) {
String key = "key" + i;
Mutation mutation = Mutation.create();
for (int j = 0; j < 50000; j++) {
mutation.setCell("f", "q" + j, "value");
}
bulkMutation.add(key, mutation);
}
Assert.fail("Test should fail with IllegalArgumentException");
} catch (IllegalArgumentException e) {
assertThat(e.getMessage()).contains("Too many mutations");
}

// we should be able to add 10000 mutations
bulkMutation = BulkMutation.create(TABLE_ID);
Mutation mutation = Mutation.create();
for (int i = 0; i < 100000; i++) {
mutation.setCell("f", "q" + i, "value");
}
bulkMutation.add("key", mutation);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,6 @@ public Object answer(InvocationOnMock invocation) throws Throwable {
.reserve(any(Long.class), any(Long.class));
when(flowController.getMaxElementCountLimit()).thenReturn(null);
when(flowController.getMaxRequestBytesLimit()).thenReturn(null);
when(batchingDescriptor.countBytes(any())).thenReturn(1l);
when(batchingDescriptor.newRequestBuilder(any())).thenCallRealMethod();

doAnswer(
Expand Down

0 comments on commit d5f5530

Please sign in to comment.