Uploaded image for project: 'HBase'
  1. HBase
  2. HBASE-24602

Add Increment and Append support to CheckAndMutate

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 3.0.0-alpha-1, 2.4.0
    • None
    • None
    • Incompatible change, Reviewed
    • Hide
      Summary of the change of HBASE-24602:
      - Add `build(Increment)` and `build(Append)` methods to the `Builder` class of the `CheckAndMutate` class. After this change, we can perform checkAndIncrement/Append operations as follows:
      ```
      // Build a CheckAndMutate object with a Increment object
      CheckAndMutate checkAndMutate = CheckAndMutate.newBuilder(row)
        .ifEquals(family, qualifier, value)
        .build(increment);

      // Perform a CheckAndIncrement operation
      CheckAndMutateResult checkAndMutateResult = table.checkAndMutate(checkAndMutate);

      // Get whether or not the CheckAndIncrement operation is successful
      boolean success = checkAndMutateResult.isSuccess();

      // Get the result of the increment operation
      Result result = checkAndMutateResult.getResult();
      ```
      - After this change, `HRegion.batchMutate()` is used for increment/append operations.
      - As the side effect of the above change, the following coprocessor methods of RegionObserver are called when increment/append operations are performed:
        - preBatchMutate()
        - postBatchMutate()
        - postBatchMutateIndispensably()
      Show
      Summary of the change of HBASE-24602 : - Add `build(Increment)` and `build(Append)` methods to the `Builder` class of the `CheckAndMutate` class. After this change, we can perform checkAndIncrement/Append operations as follows: ``` // Build a CheckAndMutate object with a Increment object CheckAndMutate checkAndMutate = CheckAndMutate.newBuilder(row)   .ifEquals(family, qualifier, value)   .build(increment); // Perform a CheckAndIncrement operation CheckAndMutateResult checkAndMutateResult = table.checkAndMutate(checkAndMutate); // Get whether or not the CheckAndIncrement operation is successful boolean success = checkAndMutateResult.isSuccess(); // Get the result of the increment operation Result result = checkAndMutateResult.getResult(); ``` - After this change, `HRegion.batchMutate()` is used for increment/append operations. - As the side effect of the above change, the following coprocessor methods of RegionObserver are called when increment/append operations are performed:   - preBatchMutate()   - postBatchMutate()   - postBatchMutateIndispensably()

    Description

      Currently, CheckAndMutate supports only Put and Delete. Supporting Increment and Append would be helpful for some use cases.

      Attachments

        Activity

          People

            brfrn169 Toshihiro Suzuki
            brfrn169 Toshihiro Suzuki
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: