wypoon commented on code in PR #4588:
URL: https://github.com/apache/iceberg/pull/4588#discussion_r856699808


##########
data/src/main/java/org/apache/iceberg/data/DeleteFilter.java:
##########
@@ -188,31 +202,52 @@ private CloseableIterable<T> 
applyEqDeletes(CloseableIterable<T> records) {
     Filter<T> remainingRowsFilter = new Filter<T>() {
       @Override
       protected boolean shouldKeep(T item) {
-        return remainingRows.test(item);
+        boolean keep = remainingRows.test(item); // false means row is deleted
+        if (!keep && counter != null) {
+          counter.increment();
+        }
+        return keep;
       }
     };
 
     return remainingRowsFilter.filter(records);
   }
 
-  public Predicate<T> eqDeletedRowFilter() {
-    if (eqDeleteRows == null) {
-      eqDeleteRows = applyEqDeletes().stream()
-          .map(Predicate::negate)
-          .reduce(Predicate::and)
-          .orElse(t -> true);
+  public int applyEqDeletes(Iterator<T> records, int[] mapping) {
+    Predicate<T> remainingRows = applyEqDeletes().stream()
+        .map(Predicate::negate)
+        .reduce(Predicate::and)
+        .orElse(t -> true);
+
+    int rowId = 0;
+    int currentRowId = 0;
+    while (records.hasNext()) {
+      T row = records.next();
+      if (remainingRows.test(row)) {
+        // the row is NOT deleted
+        // skip deleted rows by pointing to the next undeleted row Id
+        mapping[currentRowId] = mapping[rowId];
+        currentRowId++;
+      } else if (counter != null) {
+        counter.increment();
+      }
+
+      rowId++;
     }
-    return eqDeleteRows;
+
+    return currentRowId;
   }
 
   public PositionDeleteIndex deletedRowPositions() {
+    LOG.debug("calling deletedRowPositions()");

Review Comment:
   Removed.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to