Xuesen Liang created HBASE-29217:
------------------------------------

             Summary: Enhancement for CheckAndMutate
                 Key: HBASE-29217
                 URL: https://issues.apache.org/jira/browse/HBASE-29217
             Project: HBase
          Issue Type: Improvement
          Components: Client, regionserver
            Reporter: Xuesen Liang
            Assignee: Xuesen Liang


The current implementation of _CheckAndMutate_ operation provides two 
conditional verification modes:
1. Column Non-exists:
{code:java}
ifMatches(family, qualifier, CompareOperator.EQUAL, null)
{code}
Validates that the specified column does not exist.

2. Column Value Comparison/Filter
{code:java}
ifMatches(family, qualifier, CompareOperator, value) 
{code}
OR
{code:java}
ifMatches(Filter)
{code}
Verifies that the column exists and satisfies the defined comparison/filter 
logic.

 

*Limitation:*

The existing API lacks support for composite conditional checks of the form:

_"Column X either does not exist, OR exists and meets comparison condition"._

 

*Current Workaround & Risks:*

To implement this logic, developers must:
{code:java}
// Step 1: Check column absence
checkAndMutate.ifMatches(family, qualifier, CompareOperator.EQUAL, null)
// Step 2: Check value condition if Step 1 fails 
checkAndMutate.ifMatches(family, qualifier, CompareOperator, value)
{code}
This approach introduces following critical issues:
 * Non-atomic Execution: The two-phase check creates race conditions.
 * API Complexity: Forces developers to implement client-side synchronization 
logic.
 * Performance: There are two RPC calls.

 

*Proposed Solution:*

Introduce a composite conditional operator:
{code:java}
ifNotExistsOr(family, qualifier, CompareOperator, value)
{code}
 

*Implementation Benefits:*
 * Atomic Guarantee: Executes the "NOT EXISTS OR SATISFIES" logic in a single 
RPC call.
 * API Simplification: Reduces client-side code complexity.

This enhancement would align HBase's conditional mutation capabilities with 
modern database systems supporting compound atomic predicates, while 
maintaining backward compatibility.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to