virajjasani commented on a change in pull request #978:
URL: https://github.com/apache/phoenix/pull/978#discussion_r531661541
##########
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:
For now I think it's fine to perform this whole operation here, but
eventually, do you think performing this entire `cleanup + adding new delete
markers` could be done at HBase side using Mutation API? Not very strong point
but keeping as much cell mutations to hbase side as possible might be better?
Or maybe keeping this whole batch operation `setDeleteAttributes()` at hbase
side as Public/LP API?
WDYT @shahrs87 @gjacoby126 ? Apologies if this was already discussed, I know
there have been few nice long discussions overall.
----------------------------------------------------------------
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]