This is an automated email from the ASF dual-hosted git repository.

apurtell pushed a commit to branch PHOENIX-7562-feature
in repository https://gitbox.apache.org/repos/asf/phoenix.git

commit 55fc359df113e1d445fd3c0086de64430ee20e82
Author: Kadir Ozdemir <37155482+kadiro...@users.noreply.github.com>
AuthorDate: Thu Apr 24 12:41:20 2025 -0700

    PHOENIX-7574 Addendum to check loop variable increments against the loop 
condition (#2127)
---
 .../phoenix/coprocessor/CompactionScanner.java     | 40 ++++++++++++++--------
 1 file changed, 26 insertions(+), 14 deletions(-)

diff --git 
a/phoenix-core-server/src/main/java/org/apache/phoenix/coprocessor/CompactionScanner.java
 
b/phoenix-core-server/src/main/java/org/apache/phoenix/coprocessor/CompactionScanner.java
index 08302d220d..232a4a20c2 100644
--- 
a/phoenix-core-server/src/main/java/org/apache/phoenix/coprocessor/CompactionScanner.java
+++ 
b/phoenix-core-server/src/main/java/org/apache/phoenix/coprocessor/CompactionScanner.java
@@ -2391,11 +2391,15 @@ public class CompactionScanner implements 
InternalScanner {
                                     retainedCells.add(cell);
                                 }
                             }
-                            cell = result.get(index + 1);
-                            if (!CellUtil.matchingColumn(cell, 
currentColumnCell)) {
-                                continue top;
+                            if (index + 1 < result.size()) {
+                                cell = result.get(index + 1);
+                                if (!CellUtil.matchingColumn(cell, 
currentColumnCell)) {
+                                    continue top;
+                                }
+                                index++;
+                            } else {
+                                break top;
                             }
-                            index++;
                         }
                     }
                 }
@@ -2422,17 +2426,25 @@ public class CompactionScanner implements 
InternalScanner {
                     } else if (!major) {
                         retainedCells.add(cell);
                     }
-                    Cell nextCell = result.get(index + 1);
-                    if (!CellUtil.matchingColumn(currentColumnCell, nextCell)) 
{
-                        continue top;
-                    }
-                    // Increment index by one as the delete cell should be 
consumed
-                    index++;
-                    if (nextCell.getType() == Cell.Type.Put
-                            && cell.getTimestamp() == nextCell.getTimestamp()) 
{
-                        // This put cell is masked by the delete marker
+                    if (index + 1 < result.size()) {
+                        Cell nextCell = result.get(index + 1);
+                        if (!CellUtil.matchingColumn(currentColumnCell, 
nextCell)) {
+                            continue top;
+                        }
+                        // Increment index by one as the delete cell should be 
consumed
                         index++;
-                        cell = result.get(index);
+                        if (nextCell.getType() == Cell.Type.Put
+                                && cell.getTimestamp() == 
nextCell.getTimestamp()) {
+                            // This put cell is masked by the delete marker
+                            index++;
+                            if (index < result.size()) {
+                                cell = result.get(index);
+                            } else {
+                                break top;
+                            }
+                        }
+                    } else {
+                        break top;
                     }
                 }
                 if (cell.getType() == Cell.Type.DeleteColumn) {

Reply via email to