Skip to content

Commit

Permalink
[AMORO-3391] Fix minor optimizing repeated issue (#3392)
Browse files Browse the repository at this point in the history
* Fix minor optimizing repeated issue

* Fix segmentShouldRewritePos issue
  • Loading branch information
zhoujinsong authored Jan 6, 2025
1 parent 907973e commit 0cc0529
Showing 1 changed file with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,16 +235,27 @@ public boolean fileShouldRewrite(DataFile dataFile, List<ContentFile<?>> deletes

public boolean segmentShouldRewritePos(DataFile dataFile, List<ContentFile<?>> deletes) {
Preconditions.checkArgument(!isFragmentFile(dataFile), "Unsupported fragment file.");
long posDeleteFileCount =
deletes.stream().filter(delete -> delete.content() == FileContent.POSITION_DELETES).count();
if (posDeleteFileCount == 1) {
return !TableFileUtil.isOptimizingPosDeleteFile(
dataFile.path().toString(), deletes.get(0).path().toString());
} else if (posDeleteFileCount > 1) {
long equalDeleteFileCount = 0;
long posDeleteFileCount = 0;

for (ContentFile<?> delete : deletes) {
if (delete.content() == FileContent.EQUALITY_DELETES) {
equalDeleteFileCount++;
} else if (delete.content() == FileContent.POSITION_DELETES) {
posDeleteFileCount++;
}
}
if (posDeleteFileCount > 1) {
combinePosSegmentFileCount++;
return true;
} else if (equalDeleteFileCount > 0) {
return true;
} else if (posDeleteFileCount == 1) {
return !TableFileUtil.isOptimizingPosDeleteFile(
dataFile.path().toString(), deletes.get(0).path().toString());
} else {
return false;
}
return deletes.stream().anyMatch(delete -> delete.content() == FileContent.EQUALITY_DELETES);
}

protected boolean isFullOptimizing() {
Expand Down

0 comments on commit 0cc0529

Please sign in to comment.