aokolnychyi commented on code in PR #11825:
URL: https://github.com/apache/iceberg/pull/11825#discussion_r1924681185
##########
core/src/main/java/org/apache/iceberg/actions/SizeBasedDataRewriter.java:
##########
@@ -84,13 +87,34 @@ private boolean shouldRewrite(List<FileScanTask> group) {
return enoughInputFiles(group)
|| enoughContent(group)
|| tooMuchContent(group)
- || anyTaskHasTooManyDeletes(group);
+ || anyTaskHasTooManyDeletes(group)
+ || anyTaskHasTooHighDeleteRatio(group);
}
private boolean anyTaskHasTooManyDeletes(List<FileScanTask> group) {
return group.stream().anyMatch(this::tooManyDeletes);
}
+ private boolean anyTaskHasTooHighDeleteRatio(List<FileScanTask> group) {
+ return group.stream().anyMatch(this::tooHighDeleteRatio);
+ }
+
+ private boolean tooHighDeleteRatio(FileScanTask task) {
+ if (null == task.deletes() || task.deletes().isEmpty()) {
+ return false;
+ }
+
+ if (ContentFileUtil.containsSingleDV(task.deletes())
Review Comment:
Do we actually have to limit ourselves to cases when there either 1 DV or
only file-scoped deletes? Why not just count the number of records that we know
are definitely removed and use that?
```
double knownDeletedRecordCount =
task.deletes().stream()
.filter(ContentFileUtil::isFileScoped)
.mapToDouble(ContentFile::recordCount)
.sum();
double deleteRatio = knownDeletedRecordCount / task.file().recordCount();
```
I think `isFileScoped` must be true for all file-scoped deletes, including
DVs.
--
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]