virajjasani commented on a change in pull request #978:
URL: https://github.com/apache/phoenix/pull/978#discussion_r532786843



##########
File path: 
phoenix-core/src/main/java/org/apache/phoenix/hbase/index/IndexRegionObserver.java
##########
@@ -991,6 +999,47 @@ public void 
preBatchMutateWithExceptions(ObserverContext<RegionCoprocessorEnviro
         }
     }
 
+    /**
+     * Set Cell Tags to delete markers with source of operation attribute.
+     * @param miniBatchOp
+     * @throws IOException
+     */
+    private void setDeleteAttributes(MiniBatchOperationInProgress<Mutation> 
miniBatchOp)
+            throws IOException {
+        for (int i = 0; i < miniBatchOp.size(); i++) {
+            Mutation m = miniBatchOp.getOperation(i);
+            if (!(m instanceof  Delete)) {
+                // Ignore if it is not Delete type.
+                continue;
+            }
+            byte[] sourceOpAttr = 
m.getAttribute(QueryServices.SOURCE_OPERATION_ATTRIB);
+            if (sourceOpAttr == null) {
+                continue;
+            }
+
+            Tag sourceOpTag = new 
ArrayBackedTag(PhoenixTagType.SOURCE_OPERATION_TAG_TYPE,
+                    sourceOpAttr);
+            List<Cell> updatedCells = new ArrayList<>();
+            for (CellScanner cellScanner = m.cellScanner(); 
cellScanner.advance();) {
+                Cell cell = cellScanner.current();
+                // TODO: Cell#getTagsArray, Cell#getTagsOffset, 
Cell#getTagsLength are deprecated.
+                //TODO: Need to replace them with new methods.
+                List<Tag> tags = PrivateCellUtil.getTags(cell);
+                tags.add(sourceOpTag);
+                // TODO: PrivateCellUtil's IA is Private. Need to change it to 
LP with
+                // TODO: IA.COPROC.
+                Cell updatedCell = PrivateCellUtil.createCell(cell, tags);
+                updatedCells.add(updatedCell);
+            }
+            m.getFamilyCellMap().clear();
+            // Clear and add new Cells to the Mutation.
+            for (Cell cell : updatedCells) {
+                Delete d = (Delete) m;
+                d.addDeleteMarker(cell);
+            }

Review comment:
       Sounds good, and now with new Builder as IA.LP, we are good to use LP 
APIs until upgrading to 2.5.x/1.7.x (hopefully) and till then we can use 
`ArrayBackedTag` directly.




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

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


Reply via email to