virajjasani commented on code in PR #1884:
URL: https://github.com/apache/phoenix/pull/1884#discussion_r1618041568


##########
phoenix-core-server/src/main/java/org/apache/phoenix/hbase/index/IndexRegionObserver.java:
##########
@@ -1308,6 +1345,19 @@ public void 
postBatchMutateIndispensably(ObserverContext<RegionCoprocessorEnviro
       try {
           if (success) {
               context.currentPhase = BatchMutatePhase.POST;
+              for (int i = 0; i < miniBatchOp.size(); i++) {
+                  BatchMutateContext.UpdateStatus updateStatus = 
context.getUpdateStatus(i);
+                  if 
(BatchMutateContext.UpdateStatus.UPDATE.equals(updateStatus)) {
+                      byte[] retVal = PInteger.INSTANCE.toBytes(1);
+                      Cell cell = PhoenixKeyValueUtil.newKeyValue(
+                              miniBatchOp.getOperation(i).getRow(),
+                              EMPTY_BYTE_ARRAY, EMPTY_BYTE_ARRAY, 0, retVal, 0,
+                              retVal.length);
+                      Result result = Result.create(new 
ArrayList<>(Arrays.asList(cell)));
+                      miniBatchOp.setOperationStatus(i,
+                              new OperationStatus(OperationStatusCode.SUCCESS, 
result));
+                  }
+              }

Review Comment:
   > Result with value `0` are already set earlier and are still around right 
when this method is called ?
   
   That's correct, because from HBase side, no remaining logic of batchMutate() 
gets executed as we short-circuit with value `0`.
   Only when the whole batchMutate() execution goes through, Result object no 
longer stays around.
   ```
         batchOp.visitBatchOperations(true, finalLastIndexExclusive, (int i) -> 
{
           Mutation mutation = batchOp.getMutation(i);
           if (mutation instanceof Increment || mutation instanceof Append) {
             if (finalSuccess) {
               batchOp.retCodeDetails[i] =
                 new OperationStatus(OperationStatusCode.SUCCESS, 
batchOp.results[i]);
             } else {
               batchOp.retCodeDetails[i] = OperationStatus.FAILURE;
             }
           } else {
             batchOp.retCodeDetails[i] =
               finalSuccess ? OperationStatus.SUCCESS : OperationStatus.FAILURE;
           }
           return true;
         });
   ```
   
   Here, HBase sets `OperationStatus.SUCCESS` to `batchOp.retCodeDetails[i]` 
for Put/Delete mutations, leaving no Result object around with OperationStatus.
   However, in case of ignore, the above logic is not executed, hence what we 
set with value `0` with `addOnDupMutationsToBatch()` stays around but for 
setting `1`, we need to set it with `postBatchMutateIndispensably()`.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to