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


##########
phoenix-core-server/src/main/java/org/apache/phoenix/coprocessor/CompactionScanner.java:
##########
@@ -205,7 +212,15 @@ public CompactionScanner(RegionCoprocessorEnvironment env,
         emptyCFStore = familyCount == 1 || 
columnFamilyName.equals(Bytes.toString(emptyCF))
                         || localIndex;
 
-        isCDCIndex = table != null ? CDCUtil.isCDCIndex(table) : false;
+        this.table = table;
+        isCDCIndex = CDCUtil.isCDCIndex(table);

Review Comment:
   `isCDCIndex` is already in use, this change is just optimization from 
`isCDCIndex = table != null ? CDCUtil.isCDCIndex(table) : false` to `isCDCIndex 
= CDCUtil.isCDCIndex(table)`



##########
phoenix-core-server/src/main/java/org/apache/phoenix/coprocessor/CDCGlobalIndexRegionScanner.java:
##########
@@ -259,4 +307,71 @@ private Object getColumnValue(byte[] cellValue, int 
offset, int length, PDataTyp
         }
         return CDCUtil.getColumnEncodedValue(value, dataType);
     }
+
+    /**
+     * Checks if the CDC index row already contains pre-image data.
+     * This is true for TTL delete events that embed complete row data.
+     * Checks for the new CDC_IMAGE_CQ column that contains pre-computed CDC 
event data.
+     *
+     * @param indexRow The CDC index row cells
+     * @return true if pre-image data is available, false if data table scan 
is needed
+     */
+    private boolean hasPreImageData(List<Cell> indexRow) {
+        try {
+            if (indexRow.size() == 1) {
+                return false;
+            }
+            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)) {
+                    return true;
+                }
+            }
+        } catch (Exception e) {
+            LOGGER.error("Error checking for pre-image data in CDC index row", 
e);
+        }
+        return false;
+    }
+
+    /**
+     * 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;
+            }
+        }

Review Comment:
   Done



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

Reply via email to