[2/2] hbase git commit: HBASE-18951 Use Builder pattern to remove nullable parameters for checkAndXXX methods in RawAsyncTable/AsyncTable interface

2017-10-10 Thread zhangduo
HBASE-18951 Use Builder pattern to remove nullable parameters for checkAndXXX 
methods in RawAsyncTable/AsyncTable interface


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/d5b76547
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/d5b76547
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/d5b76547

Branch: refs/heads/branch-2
Commit: d5b76547f088783041212df559bcb08b6c641776
Parents: 294f6b7
Author: zhangduo 
Authored: Tue Oct 10 11:11:19 2017 +0800
Committer: zhangduo 
Committed: Tue Oct 10 14:41:27 2017 +0800

--
 .../hadoop/hbase/client/AsyncTableBase.java | 158 ---
 .../hadoop/hbase/client/AsyncTableImpl.java |  57 +--
 .../hadoop/hbase/client/RawAsyncTableImpl.java  | 123 ++-
 .../hadoop/hbase/client/TestAsyncTable.java |  53 ---
 4 files changed, 219 insertions(+), 172 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/hbase/blob/d5b76547/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncTableBase.java
--
diff --git 
a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncTableBase.java 
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncTableBase.java
index ed4c497..cc9f337 100644
--- 
a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncTableBase.java
+++ 
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncTableBase.java
@@ -191,72 +191,75 @@ public interface AsyncTableBase {
   }
 
   /**
-   * Atomically checks if a row/family/qualifier value equals to the expected 
value. If it does, it
-   * adds the put. If the passed value is null, the check is for the lack of 
column (ie:
-   * non-existence)
-   * @param row to check
-   * @param family column family to check
-   * @param qualifier column qualifier to check
-   * @param value the expected value
-   * @param put data to put if check succeeds
-   * @return true if the new put was executed, false otherwise. The return 
value will be wrapped by
-   * a {@link CompletableFuture}.
-   */
-  default CompletableFuture checkAndPut(byte[] row, byte[] family, 
byte[] qualifier,
-  byte[] value, Put put) {
-return checkAndPut(row, family, qualifier, CompareOperator.EQUAL, value, 
put);
-  }
-
-  /**
* Atomically checks if a row/family/qualifier value matches the expected 
value. If it does, it
-   * adds the put. If the passed value is null, the check is for the lack of 
column (ie:
-   * non-existence)
-   * @param row to check
-   * @param family column family to check
-   * @param qualifier column qualifier to check
-   * @param compareOp comparison operator to use
-   * @param value the expected value
-   * @param put data to put if check succeeds
-   * @return true if the new put was executed, false otherwise. The return 
value will be wrapped by
-   * a {@link CompletableFuture}.
-   */
-  CompletableFuture checkAndPut(byte[] row, byte[] family, byte[] 
qualifier,
- CompareOperator compareOp, byte[] 
value, Put put);
-
-  /**
-   * Atomically checks if a row/family/qualifier value equals to the expected 
value. If it does, it
-   * adds the delete. If the passed value is null, the check is for the lack 
of column (ie:
-   * non-existence)
-   * @param row to check
-   * @param family column family to check
-   * @param qualifier column qualifier to check
-   * @param value the expected value
-   * @param delete data to delete if check succeeds
-   * @return true if the new delete was executed, false otherwise. The return 
value will be wrapped
-   * by a {@link CompletableFuture}.
+   * adds the Put/Delete/RowMutations.
+   * 
+   * Use the returned {@link CheckAndMutateBuilder} to construct your request 
and then execute it.
+   * This is a fluent style API, the code is like:
+   *
+   * 
+   * 
+   * table.checkAndMutate(row, 
family).qualifier(qualifier).ifNotExists().thenPut(put)
+   * .thenAccept(succ -> {
+   *   if (succ) {
+   * System.out.println("Check and put succeeded");
+   *   } else {
+   * System.out.println("Check and put failed");
+   *   }
+   * });
+   * 
+   * 
*/
-  default CompletableFuture checkAndDelete(byte[] row, byte[] family, 
byte[] qualifier,
-  byte[] value, Delete delete) {
-return checkAndDelete(row, family, qualifier, CompareOperator.EQUAL, 
value, delete);
+  CheckAndMutateBuilder checkAndMutate(byte[] row, byte[] family);
+
+  /**
+   * A helper class for sending checkAndMutate request.
+   */
+  interface CheckAndMutateBuilder {
+
+/**
+ * @param qualifier column qualifier to check.
+ */
+CheckAndMutateBuilder qualifier(byte[] 

hbase git commit: HBASE-18951 Use Builder pattern to remove nullable parameters for checkAndXXX methods in RawAsyncTable/AsyncTable interface

2017-10-10 Thread zhangduo
Repository: hbase
Updated Branches:
  refs/heads/master c3b3fd788 -> 8597b19b3


HBASE-18951 Use Builder pattern to remove nullable parameters for checkAndXXX 
methods in RawAsyncTable/AsyncTable interface


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/8597b19b
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/8597b19b
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/8597b19b

Branch: refs/heads/master
Commit: 8597b19b3d7bb2671a6afd7e902aaaea6690a105
Parents: c3b3fd7
Author: zhangduo 
Authored: Tue Oct 10 11:11:19 2017 +0800
Committer: zhangduo 
Committed: Tue Oct 10 14:41:23 2017 +0800

--
 .../hadoop/hbase/client/AsyncTableBase.java | 158 ---
 .../hadoop/hbase/client/AsyncTableImpl.java |  57 +--
 .../hadoop/hbase/client/RawAsyncTableImpl.java  | 123 ++-
 .../hadoop/hbase/client/TestAsyncTable.java |  53 ---
 4 files changed, 219 insertions(+), 172 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/hbase/blob/8597b19b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncTableBase.java
--
diff --git 
a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncTableBase.java 
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncTableBase.java
index ed4c497..cc9f337 100644
--- 
a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncTableBase.java
+++ 
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncTableBase.java
@@ -191,72 +191,75 @@ public interface AsyncTableBase {
   }
 
   /**
-   * Atomically checks if a row/family/qualifier value equals to the expected 
value. If it does, it
-   * adds the put. If the passed value is null, the check is for the lack of 
column (ie:
-   * non-existence)
-   * @param row to check
-   * @param family column family to check
-   * @param qualifier column qualifier to check
-   * @param value the expected value
-   * @param put data to put if check succeeds
-   * @return true if the new put was executed, false otherwise. The return 
value will be wrapped by
-   * a {@link CompletableFuture}.
-   */
-  default CompletableFuture checkAndPut(byte[] row, byte[] family, 
byte[] qualifier,
-  byte[] value, Put put) {
-return checkAndPut(row, family, qualifier, CompareOperator.EQUAL, value, 
put);
-  }
-
-  /**
* Atomically checks if a row/family/qualifier value matches the expected 
value. If it does, it
-   * adds the put. If the passed value is null, the check is for the lack of 
column (ie:
-   * non-existence)
-   * @param row to check
-   * @param family column family to check
-   * @param qualifier column qualifier to check
-   * @param compareOp comparison operator to use
-   * @param value the expected value
-   * @param put data to put if check succeeds
-   * @return true if the new put was executed, false otherwise. The return 
value will be wrapped by
-   * a {@link CompletableFuture}.
-   */
-  CompletableFuture checkAndPut(byte[] row, byte[] family, byte[] 
qualifier,
- CompareOperator compareOp, byte[] 
value, Put put);
-
-  /**
-   * Atomically checks if a row/family/qualifier value equals to the expected 
value. If it does, it
-   * adds the delete. If the passed value is null, the check is for the lack 
of column (ie:
-   * non-existence)
-   * @param row to check
-   * @param family column family to check
-   * @param qualifier column qualifier to check
-   * @param value the expected value
-   * @param delete data to delete if check succeeds
-   * @return true if the new delete was executed, false otherwise. The return 
value will be wrapped
-   * by a {@link CompletableFuture}.
+   * adds the Put/Delete/RowMutations.
+   * 
+   * Use the returned {@link CheckAndMutateBuilder} to construct your request 
and then execute it.
+   * This is a fluent style API, the code is like:
+   *
+   * 
+   * 
+   * table.checkAndMutate(row, 
family).qualifier(qualifier).ifNotExists().thenPut(put)
+   * .thenAccept(succ -> {
+   *   if (succ) {
+   * System.out.println("Check and put succeeded");
+   *   } else {
+   * System.out.println("Check and put failed");
+   *   }
+   * });
+   * 
+   * 
*/
-  default CompletableFuture checkAndDelete(byte[] row, byte[] family, 
byte[] qualifier,
-  byte[] value, Delete delete) {
-return checkAndDelete(row, family, qualifier, CompareOperator.EQUAL, 
value, delete);
+  CheckAndMutateBuilder checkAndMutate(byte[] row, byte[] family);
+
+  /**
+   * A helper class for sending checkAndMutate request.
+   */
+  interface CheckAndMutateBuilder {
+
+/**
+ * @param qualifier column