flyrain commented on code in PR #4683:
URL: https://github.com/apache/iceberg/pull/4683#discussion_r881038554
##########
core/src/main/java/org/apache/iceberg/deletes/Deletes.java:
##########
@@ -137,93 +146,81 @@ protected boolean shouldKeep(T row) {
}
}
- private static class PositionSetDeleteFilter<T> extends Filter<T> {
- private final Function<T, Long> rowToPosition;
- private final PositionDeleteIndex deleteSet;
-
- private PositionSetDeleteFilter(Function<T, Long> rowToPosition,
PositionDeleteIndex deleteSet) {
- this.rowToPosition = rowToPosition;
- this.deleteSet = deleteSet;
- }
-
- @Override
- protected boolean shouldKeep(T row) {
- return !deleteSet.isDeleted(rowToPosition.apply(row));
- }
- }
-
private static class PositionStreamDeleteFilter<T> extends CloseableGroup
implements CloseableIterable<T> {
private final CloseableIterable<T> rows;
+ private final CloseableIterator<Long> deletePosIterator;
private final Function<T, Long> extractPos;
- private final CloseableIterable<Long> deletePositions;
+ private long nextDeletePos;
private PositionStreamDeleteFilter(CloseableIterable<T> rows, Function<T,
Long> extractPos,
CloseableIterable<Long>
deletePositions) {
this.rows = rows;
this.extractPos = extractPos;
- this.deletePositions = deletePositions;
+ this.deletePosIterator = deletePositions.iterator();
}
@Override
public CloseableIterator<T> iterator() {
- CloseableIterator<Long> deletePosIterator = deletePositions.iterator();
-
CloseableIterator<T> iter;
if (deletePosIterator.hasNext()) {
- iter = new PositionFilterIterator(rows.iterator(), deletePosIterator);
+ nextDeletePos = deletePosIterator.next();
+ iter = createPosDeleteIterator(rows.iterator());
} else {
iter = rows.iterator();
- try {
- deletePosIterator.close();
- } catch (IOException e) {
- throw new UncheckedIOException("Failed to close delete positions
iterator", e);
- }
}
addCloseable(iter);
+ addCloseable(deletePosIterator);
return iter;
}
- private class PositionFilterIterator extends FilterIterator<T> {
- private final CloseableIterator<Long> deletePosIterator;
- private long nextDeletePos;
+ boolean isDeleted(T row) {
Review Comment:
We intentionally changed the method name `deleted` to `isDeleted` in this PR
https://github.com/apache/iceberg/pull/3535#discussion_r748893494. `deleted` is
more concise, `isDeleted` is a bit easier to grab. I'm OK with either one. What
do you think?
--
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]