haridsv commented on code in PR #2209: URL: https://github.com/apache/phoenix/pull/2209#discussion_r2190116124
########## phoenix-core-server/src/main/java/org/apache/phoenix/coprocessor/CDCGlobalIndexRegionScanner.java: ########## @@ -259,4 +310,44 @@ private Object getColumnValue(byte[] cellValue, int offset, int length, PDataTyp } return CDCUtil.getColumnEncodedValue(value, dataType); } + + /** + * Handles CDC events that already contain pre-image data, avoiding data table scan. + * Supports both the new CDC_IMAGE_CQ column and traditional CDC JSON column. + * + * @param indexRow The CDC index row cells + * @param indexRowKey The CDC index row key + * @param indexCell The primary index cell + * @param result The result list to populate + * @return true if event was processed successfully + */ + private boolean handlePreImageCDCEvent(List<Cell> indexRow, byte[] indexRowKey, + Cell indexCell, List<Cell> result) { + Cell cdcDataCell = null; + for (Cell cell : indexRow) { + if (Bytes.equals(cell.getQualifierArray(), cell.getQualifierOffset(), + cell.getQualifierLength(), + QueryConstants.CDC_IMAGE_CQ_BYTES, 0, + QueryConstants.CDC_IMAGE_CQ_BYTES.length)) { + cdcDataCell = cell; + break; + } + } + if (cdcDataCell == null) { + return false; + } + byte[] cdcEventBytes = CellUtil.cloneValue(cdcDataCell); Review Comment: The if condition is meant to reduce garbage when possible. The other one always clones the byte array. Of course this shouldn't be used when the byte array needs to be kept around, but I think it is not the case here. -- 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: issues-unsubscr...@phoenix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org