Uploaded image for project: 'HBase'
  1. HBase
  2. HBASE-24602 Add Increment and Append support to CheckAndMutate
  3. HBASE-24650

Change the return types of the new checkAndMutate methods introduced in HBASE-8458

    XMLWordPrintableJSON

    Details

    • Type: Sub-task
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.0.0-alpha-1, 2.4.0
    • Component/s: Client
    • Labels:
      None
    • Hadoop Flags:
      Incompatible change, Reviewed
    • Release Note:
      Hide
      HBASE-24650 introduced CheckAndMutateResult class and changed the return type of checkAndMutate methods to this class in order to support CheckAndMutate with Increment/Append. CheckAndMutateResult class has two fields, one is *success* that indicates whether the operation is successful or not, and the other one is *result* that's the result of the operation and is used for CheckAndMutate with Increment/Append.

      The new APIs for the Table interface:
      ```
      /**
       * checkAndMutate that atomically checks if a row matches the specified condition. If it does,
       * it performs the specified action.
       *
       * @param checkAndMutate The CheckAndMutate object.
       * @return A CheckAndMutateResult object that represents the result for the CheckAndMutate.
       * @throws IOException if a remote or network exception occurs.
       */
      default CheckAndMutateResult checkAndMutate(CheckAndMutate checkAndMutate) throws IOException {
        return checkAndMutate(Collections.singletonList(checkAndMutate)).get(0);
      }

      /**
       * Batch version of checkAndMutate. The specified CheckAndMutates are batched only in the sense
       * that they are sent to a RS in one RPC, but each CheckAndMutate operation is still executed
       * atomically (and thus, each may fail independently of others).
       *
       * @param checkAndMutates The list of CheckAndMutate.
       * @return A list of CheckAndMutateResult objects that represents the result for each
       * CheckAndMutate.
       * @throws IOException if a remote or network exception occurs.
       */
      default List<CheckAndMutateResult> checkAndMutate(List<CheckAndMutate> checkAndMutates)
        throws IOException {
        throw new NotImplementedException("Add an implementation!");
      }
      {code}

      The new APIs for the AsyncTable interface:
      {code}
      /**
       * checkAndMutate that atomically checks if a row matches the specified condition. If it does,
       * it performs the specified action.
       *
       * @param checkAndMutate The CheckAndMutate object.
       * @return A {@link CompletableFuture}s that represent the result for the CheckAndMutate.
       */
      CompletableFuture<CheckAndMutateResult> checkAndMutate(CheckAndMutate checkAndMutate);

      /**
       * Batch version of checkAndMutate. The specified CheckAndMutates are batched only in the sense
       * that they are sent to a RS in one RPC, but each CheckAndMutate operation is still executed
       * atomically (and thus, each may fail independently of others).
       *
       * @param checkAndMutates The list of CheckAndMutate.
       * @return A list of {@link CompletableFuture}s that represent the result for each
       * CheckAndMutate.
       */
      List<CompletableFuture<CheckAndMutateResult>> checkAndMutate(
        List<CheckAndMutate> checkAndMutates);

      /**
       * A simple version of batch checkAndMutate. It will fail if there are any failures.
       *
       * @param checkAndMutates The list of rows to apply.
       * @return A {@link CompletableFuture} that wrapper the result list.
       */
      default CompletableFuture<List<CheckAndMutateResult>> checkAndMutateAll(
        List<CheckAndMutate> checkAndMutates) {
        return allOf(checkAndMutate(checkAndMutates));
      }
      ```
      Show
      HBASE-24650 introduced CheckAndMutateResult class and changed the return type of checkAndMutate methods to this class in order to support CheckAndMutate with Increment/Append. CheckAndMutateResult class has two fields, one is *success* that indicates whether the operation is successful or not, and the other one is *result* that's the result of the operation and is used for CheckAndMutate with Increment/Append. The new APIs for the Table interface: ``` /**  * checkAndMutate that atomically checks if a row matches the specified condition. If it does,  * it performs the specified action.  *  * @param checkAndMutate The CheckAndMutate object.  * @return A CheckAndMutateResult object that represents the result for the CheckAndMutate.  * @throws IOException if a remote or network exception occurs.  */ default CheckAndMutateResult checkAndMutate(CheckAndMutate checkAndMutate) throws IOException {   return checkAndMutate(Collections.singletonList(checkAndMutate)).get(0); } /**  * Batch version of checkAndMutate. The specified CheckAndMutates are batched only in the sense  * that they are sent to a RS in one RPC, but each CheckAndMutate operation is still executed  * atomically (and thus, each may fail independently of others).  *  * @param checkAndMutates The list of CheckAndMutate.  * @return A list of CheckAndMutateResult objects that represents the result for each  * CheckAndMutate.  * @throws IOException if a remote or network exception occurs.  */ default List<CheckAndMutateResult> checkAndMutate(List<CheckAndMutate> checkAndMutates)   throws IOException {   throw new NotImplementedException("Add an implementation!"); } {code} The new APIs for the AsyncTable interface: {code} /**  * checkAndMutate that atomically checks if a row matches the specified condition. If it does,  * it performs the specified action.  *  * @param checkAndMutate The CheckAndMutate object.  * @return A {@link CompletableFuture}s that represent the result for the CheckAndMutate.  */ CompletableFuture<CheckAndMutateResult> checkAndMutate(CheckAndMutate checkAndMutate); /**  * Batch version of checkAndMutate. The specified CheckAndMutates are batched only in the sense  * that they are sent to a RS in one RPC, but each CheckAndMutate operation is still executed  * atomically (and thus, each may fail independently of others).  *  * @param checkAndMutates The list of CheckAndMutate.  * @return A list of {@link CompletableFuture}s that represent the result for each  * CheckAndMutate.  */ List<CompletableFuture<CheckAndMutateResult>> checkAndMutate(   List<CheckAndMutate> checkAndMutates); /**  * A simple version of batch checkAndMutate. It will fail if there are any failures.  *  * @param checkAndMutates The list of rows to apply.  * @return A {@link CompletableFuture} that wrapper the result list.  */ default CompletableFuture<List<CheckAndMutateResult>> checkAndMutateAll(   List<CheckAndMutate> checkAndMutates) {   return allOf(checkAndMutate(checkAndMutates)); } ```

      Description

      To support CheckAndMutate with Increment/Append, the new checkAndMutate methods introduced in HBASE-8458 need to return the result of the specified Increment/Append operation in addition to a boolean value represents whether it's successful or not. Currently, the methods return only boolean value(s), so we need to change the return types of the methods. The methods are unreleased yet currently, so I think it's no problem to change the return types of the methods.

        Attachments

          Activity

            People

            • Assignee:
              brfrn169 Toshihiro Suzuki
              Reporter:
              brfrn169 Toshihiro Suzuki
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: