shahrs87 commented on a change in pull request #978:
URL: https://github.com/apache/phoenix/pull/978#discussion_r532781817
##########
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:
> but eventually, do you think performing this entire cleanup + adding
new delete markers could be done at HBase side using Mutation API?
@virajjasani This jira https://issues.apache.org/jira/browse/PHOENIX-6213
was initially a hbase jira. Also refer to this thread here:
https://lists.apache.org/thread.html/r68bd14516383d3f624fc0185fff21ab6044f548c1f31e751e4130915%40%3Cdev.hbase.apache.org%3E
where hbase developers advised to add cell tags in phoenix coproc. :)
----------------------------------------------------------------
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]