.addEntries(Entry.newBuilder().setRowKey(ByteString.copyFromUtf8("0-ok"))) .addEntries(Entry.newBuilder().setRowKey(ByteString.copyFromUtf8("1-unavailable"))) .addEntries(Entry.newBuilder().setRowKey(ByteString.copyFromUtf8("2-invalid"))) .build(); assertThat(innerCallable.lastRequest.getEntries(0).getRowKey()) .isEqualTo(ByteString.copyFromUtf8("1-unavailable"));
.addEntries(Entry.getDefaultInstance()) .addEntries(Entry.getDefaultInstance()) .addEntries(Entry.getDefaultInstance()) .build();
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + ROW_KEY_FIELD_NUMBER; hash = (53 * hash) + getRowKey().hashCode(); if (getMutationsCount() > 0) { hash = (37 * hash) + MUTATIONS_FIELD_NUMBER; hash = (53 * hash) + getMutationsList().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
Preconditions.checkArgument(!entry.getRowKey().isEmpty(), "Request has an empty rowkey"); if (entry.getMutationsCount() >= MAX_NUMBER_OF_MUTATIONS) { entry.getRowKey().toStringUtf8(), entry.getMutationsCount(), MAX_NUMBER_OF_MUTATIONS)); };
public Builder mergeFrom(com.google.bigtable.v2.MutateRowsRequest.Entry other) { if (other == com.google.bigtable.v2.MutateRowsRequest.Entry.getDefaultInstance()) return this; if (other.getRowKey() != com.google.protobuf.ByteString.EMPTY) { setRowKey(other.getRowKey());
public Builder mergeFrom(com.google.bigtable.v2.MutateRowsRequest.Entry other) { if (other == com.google.bigtable.v2.MutateRowsRequest.Entry.getDefaultInstance()) return this; if (other.getRowKey() != com.google.protobuf.ByteString.EMPTY) { setRowKey(other.getRowKey());
/** * This test ensures that protobuf creation and interactions with {@link BulkMutation} work as * expected. * * @throws IOException * @throws InterruptedException */ @Test public void testWrite() throws IOException, InterruptedException { BigtableService.Writer underTest = new BigtableServiceImpl.BigtableWriterImpl(mockSession, TABLE_NAME); Mutation mutation = Mutation.newBuilder() .setSetCell(SetCell.newBuilder().setFamilyName("Family").build()) .build(); ByteString key = ByteString.copyFromUtf8("key"); SettableFuture<MutateRowResponse> fakeResponse = SettableFuture.create(); when(mockBulkMutation.add(any(MutateRowsRequest.Entry.class))).thenReturn(fakeResponse); underTest.writeRecord(KV.of(key, ImmutableList.of(mutation))); Entry expected = MutateRowsRequest.Entry.newBuilder().setRowKey(key).addMutations(mutation).build(); verify(mockBulkMutation, times(1)).add(expected); underTest.close(); verify(mockBulkMutation, times(1)).flush(); } }
@Override public CompletionStage<MutateRowResponse> writeRecord(KV<ByteString, Iterable<Mutation>> record) throws IOException { MutateRowsRequest.Entry request = MutateRowsRequest.Entry.newBuilder() .setRowKey(record.getKey()) .addAllMutations(record.getValue()) .build(); CompletableFuture<MutateRowResponse> result = new CompletableFuture<>(); Futures.addCallback( bulkMutation.add(request), new FutureCallback<MutateRowResponse>() { @Override public void onSuccess(MutateRowResponse mutateRowResponse) { result.complete(mutateRowResponse); } @Override public void onFailure(Throwable throwable) { result.completeExceptionally(throwable); } }); return result; } }
/** * Adds a {@link com.google.bigtable.v2.MutateRowsRequest.Entry} to the {@link * com.google.bigtable.v2.MutateRowsRequest.Builder}. NOTE: Users have to make sure that this * gets called in a thread safe way. * * @param entry The {@link com.google.bigtable.v2.MutateRowsRequest.Entry} to add * @return a {@link SettableFuture} that will be populated when the {@link MutateRowsResponse} * returns from the server. See {@link #addCallback(ListenableFuture)} for more * information about how the SettableFuture is set. */ private ListenableFuture<MutateRowResponse> add(MutateRowsRequest.Entry entry) { Preconditions.checkNotNull(entry); SettableFuture<MutateRowResponse> future = SettableFuture.create(); mutationMeter.mark(); futures.add(future); builder.addEntries(entry); approximateByteSize += entry.getSerializedSize(); numberOfMutations += entry.getMutationsCount(); return future; }
@java.lang.Override public com.google.bigtable.v2.MutateRowsRequest.Entry buildPartial() { com.google.bigtable.v2.MutateRowsRequest.Entry result = new com.google.bigtable.v2.MutateRowsRequest.Entry(this); int from_bitField0_ = bitField0_; int to_bitField0_ = 0; result.rowKey_ = rowKey_; if (mutationsBuilder_ == null) { if (((bitField0_ & 0x00000002) == 0x00000002)) { mutations_ = java.util.Collections.unmodifiableList(mutations_); bitField0_ = (bitField0_ & ~0x00000002); } result.mutations_ = mutations_; } else { result.mutations_ = mutationsBuilder_.build(); } result.bitField0_ = to_bitField0_; onBuilt(); return result; }
/** * * * <pre> * The row keys and corresponding mutations to be applied in bulk. * Each entry is applied as an atomic mutation, but the entries may be * applied in arbitrary order (even between entries for the same row). * At least one entry must be specified, and in total the entries can * contain at most 100000 mutations. * </pre> * * <code>repeated .google.bigtable.v2.MutateRowsRequest.Entry entries = 2;</code> */ public com.google.bigtable.v2.MutateRowsRequest.Entry.Builder addEntriesBuilder() { return getEntriesFieldBuilder() .addBuilder(com.google.bigtable.v2.MutateRowsRequest.Entry.getDefaultInstance()); } /**
/** * Creates a single entry bulk {@link com.google.bigtable.v2.MutateRowsRequest}, which will be * merged by the batching logic in the callable chain. */ @InternalApi public MutateRowsRequest toBulkProto(RequestContext requestContext) { String tableName = NameUtil.formatTableName( requestContext.getProjectId(), requestContext.getInstanceId(), tableId); return MutateRowsRequest.newBuilder() .setAppProfileId(requestContext.getAppProfileId()) .setTableName(tableName) .addEntries( Entry.newBuilder().setRowKey(key).addAllMutations(mutation.getMutations()).build()) .build(); } }
public com.google.bigtable.v2.MutateRowsRequest.Entry buildPartial() { com.google.bigtable.v2.MutateRowsRequest.Entry result = new com.google.bigtable.v2.MutateRowsRequest.Entry(this); int from_bitField0_ = bitField0_; int to_bitField0_ = 0; result.rowKey_ = rowKey_; if (mutationsBuilder_ == null) { if (((bitField0_ & 0x00000002) == 0x00000002)) { mutations_ = java.util.Collections.unmodifiableList(mutations_); bitField0_ = (bitField0_ & ~0x00000002); } result.mutations_ = mutations_; } else { result.mutations_ = mutationsBuilder_.build(); } result.bitField0_ = to_bitField0_; onBuilt(); return result; }
/** * * * <pre> * The row keys and corresponding mutations to be applied in bulk. * Each entry is applied as an atomic mutation, but the entries may be * applied in arbitrary order (even between entries for the same row). * At least one entry must be specified, and in total the entries can * contain at most 100000 mutations. * </pre> * * <code>repeated .google.bigtable.v2.MutateRowsRequest.Entry entries = 2;</code> */ public com.google.bigtable.v2.MutateRowsRequest.Entry.Builder addEntriesBuilder(int index) { return getEntriesFieldBuilder() .addBuilder(index, com.google.bigtable.v2.MutateRowsRequest.Entry.getDefaultInstance()); } /**
/** * <pre> * The row keys and corresponding mutations to be applied in bulk. * Each entry is applied as an atomic mutation, but the entries may be * applied in arbitrary order (even between entries for the same row). * At least one entry must be specified, and in total the entries can * contain at most 100000 mutations. * </pre> * * <code>repeated .google.bigtable.v2.MutateRowsRequest.Entry entries = 2;</code> */ public com.google.bigtable.v2.MutateRowsRequest.Entry.Builder addEntriesBuilder( int index) { return getEntriesFieldBuilder().addBuilder( index, com.google.bigtable.v2.MutateRowsRequest.Entry.getDefaultInstance()); } /**
/** * <pre> * The row keys and corresponding mutations to be applied in bulk. * Each entry is applied as an atomic mutation, but the entries may be * applied in arbitrary order (even between entries for the same row). * At least one entry must be specified, and in total the entries can * contain at most 100000 mutations. * </pre> * * <code>repeated .google.bigtable.v2.MutateRowsRequest.Entry entries = 2;</code> */ public com.google.bigtable.v2.MutateRowsRequest.Entry.Builder addEntriesBuilder() { return getEntriesFieldBuilder().addBuilder( com.google.bigtable.v2.MutateRowsRequest.Entry.getDefaultInstance()); } /**
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + ROW_KEY_FIELD_NUMBER; hash = (53 * hash) + getRowKey().hashCode(); if (getMutationsCount() > 0) { hash = (37 * hash) + MUTATIONS_FIELD_NUMBER; hash = (53 * hash) + getMutationsList().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + ROW_KEY_FIELD_NUMBER; hash = (53 * hash) + getRowKey().hashCode(); if (getMutationsCount() > 0) { hash = (37 * hash) + MUTATIONS_FIELD_NUMBER; hash = (53 * hash) + getMutationsList().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.bigtable.v2.MutateRowsRequest.Entry)) { return super.equals(obj); } com.google.bigtable.v2.MutateRowsRequest.Entry other = (com.google.bigtable.v2.MutateRowsRequest.Entry) obj; boolean result = true; result = result && getRowKey() .equals(other.getRowKey()); result = result && getMutationsList() .equals(other.getMutationsList()); return result; }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.bigtable.v2.MutateRowsRequest.Entry)) { return super.equals(obj); } com.google.bigtable.v2.MutateRowsRequest.Entry other = (com.google.bigtable.v2.MutateRowsRequest.Entry) obj; boolean result = true; result = result && getRowKey().equals(other.getRowKey()); result = result && getMutationsList().equals(other.getMutationsList()); result = result && unknownFields.equals(other.unknownFields); return result; }