szehon-ho commented on code in PR #4683:
URL: https://github.com/apache/iceberg/pull/4683#discussion_r878559602


##########
core/src/main/java/org/apache/iceberg/deletes/Deletes.java:
##########
@@ -227,6 +237,39 @@ public void close() {
     }
   }
 
+  private static class PositionStreamDeleteMarker<T> extends 
PositionStreamDeleteFilter<T> {
+    private final Consumer<T> markDeleted;
+
+    private PositionStreamDeleteMarker(CloseableIterable<T> rows, Function<T, 
Long> extractPos,
+                                       CloseableIterable<Long> 
deletePositions, Consumer<T> markDeleted) {
+      super(rows, extractPos, deletePositions);
+      this.markDeleted = markDeleted;
+    }
+
+    @Override
+    protected PositionFilterIterator 
createPosDeleteIterator(CloseableIterator<T> items,
+                                                             
CloseableIterator<Long> deletePosIterator) {
+      return new PositionDeleteMarkerIterator(items, deletePosIterator);
+    }
+
+    private class PositionDeleteMarkerIterator extends PositionFilterIterator {

Review Comment:
   One idea is composition:
   
   Make a class DeleteIterator(Iterator<T> items, Iterator<T> 
deletePosIterator), which has method isDeleted() (the inverse of today's 
PositionFilterIterator's shouldKeep).
   
   Then both PosFilterIterator and PosDeleteIterator compose it:
   ```
   PosFilterIterator(DeleteIterator<T> deleteIterator) extend FilterIterator {
      boolean shouldKeep(row) {
        return !deleteIterator.isDeleted(row) 
      }
   
   PositionDeleteMarkerIterator(DeleteIterator<T> deleteIterator, Consumer<T> 
markDeleted) {
      T next() {
         if (deleteIterator.isDeleted(row)) {
            markDeleted.apply(row)
         }
         return deleteIterator.next()
      }
   ```
   
   Hope that's correct.  I think overhead wise, it should be similar today to 
the extra super method call?  Also fyi if @aokolnychyi  has any thought on it.



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