@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + TABLE_NAME_FIELD_NUMBER; hash = (53 * hash) + getTableName().hashCode(); hash = (37 * hash) + APP_PROFILE_ID_FIELD_NUMBER; hash = (53 * hash) + getAppProfileId().hashCode(); hash = (37 * hash) + ROW_KEY_FIELD_NUMBER; hash = (53 * hash) + getRowKey().hashCode(); if (hasPredicateFilter()) { hash = (37 * hash) + PREDICATE_FILTER_FIELD_NUMBER; hash = (53 * hash) + getPredicateFilter().hashCode(); } if (getTrueMutationsCount() > 0) { hash = (37 * hash) + TRUE_MUTATIONS_FIELD_NUMBER; hash = (53 * hash) + getTrueMutationsList().hashCode(); } if (getFalseMutationsCount() > 0) { hash = (37 * hash) + FALSE_MUTATIONS_FIELD_NUMBER; hash = (53 * hash) + getFalseMutationsList().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
@java.lang.Override public Builder newBuilderForType() { return newBuilder(); }
public static Builder newBuilder() { return DEFAULT_INSTANCE.toBuilder(); }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.bigtable.v2.CheckAndMutateRowRequest)) { return super.equals(obj); } com.google.bigtable.v2.CheckAndMutateRowRequest other = (com.google.bigtable.v2.CheckAndMutateRowRequest) obj; boolean result = true; result = result && getTableName().equals(other.getTableName()); result = result && getAppProfileId().equals(other.getAppProfileId()); result = result && getRowKey().equals(other.getRowKey()); result = result && (hasPredicateFilter() == other.hasPredicateFilter()); if (hasPredicateFilter()) { result = result && getPredicateFilter().equals(other.getPredicateFilter()); } result = result && getTrueMutationsList().equals(other.getTrueMutationsList()); result = result && getFalseMutationsList().equals(other.getFalseMutationsList()); result = result && unknownFields.equals(other.unknownFields); return result; }
/** * * * <pre> * The key of the row to which the conditional mutation should be applied. * </pre> * * <code>bytes row_key = 2;</code> */ public Builder clearRowKey() { rowKey_ = getDefaultInstance().getRowKey(); onChanged(); return this; }
/** * * * <pre> * This value specifies routing for replication. If not specified, the * "default" application profile will be used. * </pre> * * <code>string app_profile_id = 7;</code> */ public Builder clearAppProfileId() { appProfileId_ = getDefaultInstance().getAppProfileId(); onChanged(); return this; } /**
public Builder mergeFrom(com.google.bigtable.v2.CheckAndMutateRowRequest other) { if (other == com.google.bigtable.v2.CheckAndMutateRowRequest.getDefaultInstance()) return this; if (!other.getTableName().isEmpty()) { tableName_ = other.tableName_; onChanged(); if (!other.getAppProfileId().isEmpty()) { appProfileId_ = other.appProfileId_; onChanged(); if (other.getRowKey() != com.google.protobuf.ByteString.EMPTY) { setRowKey(other.getRowKey()); if (other.hasPredicateFilter()) { mergePredicateFilter(other.getPredicateFilter());
/** {@inheritDoc} */ @Override public ListenableFuture<CheckAndMutateRowResponse> checkAndMutateRowAsync( CheckAndMutateRowRequest request) { if (shouldOverrideAppProfile(request.getAppProfileId())) { request = request.toBuilder().setAppProfileId(clientDefaultAppProfileId).build(); } return createUnaryListener(request, checkAndMutateRpc, request.getTableName()).getAsyncResult(); }
/** * * * <pre> * The unique name of the table to which the conditional mutation should be * applied. * Values are of the form * `projects/<project>/instances/<instance>/tables/<table>`. * </pre> * * <code>string table_name = 1;</code> */ public Builder clearTableName() { tableName_ = getDefaultInstance().getTableName(); onChanged(); return this; } /**
@java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { if (!getTableNameBytes().isEmpty()) { com.google.protobuf.GeneratedMessageV3.writeString(output, 1, tableName_); } if (!rowKey_.isEmpty()) { output.writeBytes(2, rowKey_); } for (int i = 0; i < trueMutations_.size(); i++) { output.writeMessage(4, trueMutations_.get(i)); } for (int i = 0; i < falseMutations_.size(); i++) { output.writeMessage(5, falseMutations_.get(i)); } if (predicateFilter_ != null) { output.writeMessage(6, getPredicateFilter()); } if (!getAppProfileIdBytes().isEmpty()) { com.google.protobuf.GeneratedMessageV3.writeString(output, 7, appProfileId_); } unknownFields.writeTo(output); }
@Test public void toProtoTest() { Mutation ignoredThenMutation = Mutation.create().deleteRow(); ConditionalRowMutation mutation = ConditionalRowMutation.create(TABLE_ID, TEST_KEY).then(ignoredThenMutation); CheckAndMutateRowRequest actualProto = mutation.toProto(REQUEST_CONTEXT).toBuilder().clearTrueMutations().build(); assertThat(actualProto) .isEqualTo( CheckAndMutateRowRequest.newBuilder() .setTableName(NameUtil.formatTableName(PROJECT_ID, INSTANCE_ID, TABLE_ID)) .setAppProfileId(APP_PROFILE_ID) .setRowKey(TEST_KEY) .build()); }
/** * <p>wasMutationApplied.</p> * * @param request a {@link com.google.bigtable.v2.CheckAndMutateRowRequest} object. * @param response a {@link com.google.bigtable.v2.CheckAndMutateRowResponse} object. * @return a boolean. */ public static boolean wasMutationApplied( CheckAndMutateRowRequest request, CheckAndMutateRowResponse response) { // If we have true mods, we want the predicate to have matched. // If we have false mods, we did not want the predicate to have matched. return (request.getTrueMutationsCount() > 0 && response.getPredicateMatched()) || (request.getFalseMutationsCount() > 0 && !response.getPredicateMatched()); }
@Override public Map<String, String> extract(CheckAndMutateRowRequest request) { ImmutableMap.Builder<String, String> params = ImmutableMap.builder(); params.put("table_name", String.valueOf(request.getTableName())); return params.build(); } })
public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { if (!getTableNameBytes().isEmpty()) { com.google.protobuf.GeneratedMessageV3.writeString(output, 1, tableName_); } if (!rowKey_.isEmpty()) { output.writeBytes(2, rowKey_); } for (int i = 0; i < trueMutations_.size(); i++) { output.writeMessage(4, trueMutations_.get(i)); } for (int i = 0; i < falseMutations_.size(); i++) { output.writeMessage(5, falseMutations_.get(i)); } if (predicateFilter_ != null) { output.writeMessage(6, getPredicateFilter()); } }
@java.lang.Override public com.google.bigtable.v2.CheckAndMutateRowRequest getDefaultInstanceForType() { return com.google.bigtable.v2.CheckAndMutateRowRequest.getDefaultInstance(); }
/** * * * <pre> * The filter to be applied to the contents of the specified row. Depending * on whether or not any results are yielded, either `true_mutations` or * `false_mutations` will be executed. If unset, checks that the row contains * any values at all. * </pre> * * <code>.google.bigtable.v2.RowFilter predicate_filter = 6;</code> */ public com.google.bigtable.v2.RowFilterOrBuilder getPredicateFilterOrBuilder() { return getPredicateFilter(); }
@Test public void otherwiseTest() { ConditionalRowMutation mutation = ConditionalRowMutation.create(TABLE_ID, TEST_KEY) .otherwise(Mutation.create().deleteCells("family1", "qualifier1")) .otherwise(Mutation.create().deleteCells("family2", "qualifier2")); CheckAndMutateRowRequest actualProto = mutation.toProto(REQUEST_CONTEXT); assertThat(actualProto.getFalseMutationsList()) .containsExactly( com.google.bigtable.v2.Mutation.newBuilder() .setDeleteFromColumn( DeleteFromColumn.newBuilder() .setFamilyName("family1") .setColumnQualifier(ByteString.copyFromUtf8("qualifier1"))) .build(), com.google.bigtable.v2.Mutation.newBuilder() .setDeleteFromColumn( DeleteFromColumn.newBuilder() .setFamilyName("family2") .setColumnQualifier(ByteString.copyFromUtf8("qualifier2"))) .build()) .inOrder(); }
@Test public void thenTest() { ConditionalRowMutation mutation = ConditionalRowMutation.create(TABLE_ID, TEST_KEY) .then(Mutation.create().deleteCells("family1", "qualifier1")) .then(Mutation.create().deleteCells("family2", "qualifier2")); CheckAndMutateRowRequest actualProto = mutation.toProto(REQUEST_CONTEXT); assertThat(actualProto.getTrueMutationsList()) .containsExactly( com.google.bigtable.v2.Mutation.newBuilder() .setDeleteFromColumn( DeleteFromColumn.newBuilder() .setFamilyName("family1") .setColumnQualifier(ByteString.copyFromUtf8("qualifier1"))) .build(), com.google.bigtable.v2.Mutation.newBuilder() .setDeleteFromColumn( DeleteFromColumn.newBuilder() .setFamilyName("family2") .setColumnQualifier(ByteString.copyFromUtf8("qualifier2"))) .build()) .inOrder(); }
@Test @SuppressWarnings("all") public void checkAndMutateRowTest() { boolean predicateMatched = true; CheckAndMutateRowResponse expectedResponse = CheckAndMutateRowResponse.newBuilder().setPredicateMatched(predicateMatched).build(); mockBigtable.addResponse(expectedResponse); TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]"); ByteString rowKey = ByteString.copyFromUtf8("122"); RowFilter predicateFilter = RowFilter.newBuilder().build(); List<Mutation> trueMutations = new ArrayList<>(); List<Mutation> falseMutations = new ArrayList<>(); CheckAndMutateRowResponse actualResponse = client.checkAndMutateRow(tableName, rowKey, predicateFilter, trueMutations, falseMutations); Assert.assertEquals(expectedResponse, actualResponse); List<GeneratedMessageV3> actualRequests = mockBigtable.getRequests(); Assert.assertEquals(1, actualRequests.size()); CheckAndMutateRowRequest actualRequest = (CheckAndMutateRowRequest) actualRequests.get(0); Assert.assertEquals(tableName, TableName.parse(actualRequest.getTableName())); Assert.assertEquals(rowKey, actualRequest.getRowKey()); Assert.assertEquals(predicateFilter, actualRequest.getPredicateFilter()); Assert.assertEquals(trueMutations, actualRequest.getTrueMutationsList()); Assert.assertEquals(falseMutations, actualRequest.getFalseMutationsList()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
public Builder mergeFrom(com.google.bigtable.v2.CheckAndMutateRowRequest other) { if (other == com.google.bigtable.v2.CheckAndMutateRowRequest.getDefaultInstance()) return this; if (!other.getTableName().isEmpty()) { tableName_ = other.tableName_; onChanged(); if (other.getRowKey() != com.google.protobuf.ByteString.EMPTY) { setRowKey(other.getRowKey()); if (other.hasPredicateFilter()) { mergePredicateFilter(other.getPredicateFilter());