You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by GitBox <gi...@apache.org> on 2020/02/25 23:05:37 UTC

[GitHub] [hbase] brfrn169 commented on a change in pull request #1114: HBASE-23146 Support CheckAndMutate with multiple conditions

brfrn169 commented on a change in pull request #1114: HBASE-23146 Support CheckAndMutate with multiple conditions
URL: https://github.com/apache/hbase/pull/1114#discussion_r384181018
 
 

 ##########
 File path: hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncTable.java
 ##########
 @@ -289,6 +290,60 @@ default CheckAndMutateBuilder ifEquals(byte[] value) {
     CompletableFuture<Boolean> thenMutate(RowMutations mutation);
   }
 
+  /**
+   * Atomically checks if a row matches the specified filter. If it does, it adds the
+   * Put/Delete/RowMutations.
+   * <p>
+   * Use the returned {@link CheckAndMutateWithFilterBuilder} to construct your request and then
+   * execute it. This is a fluent style API, the code is like:
+   *
+   * <pre>
+   * <code>
+   * table.checkAndMutate(row, filter).thenPut(put)
+   *     .thenAccept(succ -> {
+   *       if (succ) {
+   *         System.out.println("Check and put succeeded");
+   *       } else {
+   *         System.out.println("Check and put failed");
+   *       }
+   *     });
+   * </code>
+   * </pre>
+   */
+  CheckAndMutateWithFilterBuilder checkAndMutate(byte[] row, Filter filter);
+
+  /**
+   * A helper class for sending checkAndMutate request with a filter.
+   */
+  interface CheckAndMutateWithFilterBuilder {
+
+    /**
+     * @param timeRange time range to check.
+     */
+    CheckAndMutateWithFilterBuilder timeRange(TimeRange timeRange);
 
 Review comment:
   Thank you very much for your review and approval!
   
   > Maybe we could have a CheckAndMutateBuilderBase to palce these methods.
   
   Yes, we can have CheckAndMutateBuilderBase to place the methods.
   
   > Anyway, can be a follow issue as I do not think the change will break compatibility.
   
   Sure. Maybe we can do it at a next time when we add another type of checkAndMutate.
   
   Will commit this. Thank you very much again!

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services