Skip to content

Commit

Permalink
[core] CleanOrphanFilesResult.deletedFilesPath should be nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
JingsongLi committed Nov 26, 2024
1 parent 8d57d3d commit ee466bc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,29 @@

import org.apache.paimon.fs.Path;

import javax.annotation.Nullable;

import java.util.List;

/** The result of OrphanFilesClean. */
public class CleanOrphanFilesResult {

private List<Path> deletedFilesPath;
private final long deletedFileCount;
private final long deletedFileTotalLenInBytes;

@Nullable private final List<Path> deletedFilesPath;

public CleanOrphanFilesResult(long deletedFileCount, long deletedFileTotalLenInBytes) {
this.deletedFileCount = deletedFileCount;
this.deletedFileTotalLenInBytes = deletedFileTotalLenInBytes;
this(deletedFileCount, deletedFileTotalLenInBytes, null);
}

public CleanOrphanFilesResult(
List<Path> deletedFilesPath, long deletedFileCount, long deletedFileTotalLenInBytes) {
this(deletedFileCount, deletedFileTotalLenInBytes);
long deletedFileCount,
long deletedFileTotalLenInBytes,
@Nullable List<Path> deletedFilesPath) {
this.deletedFilesPath = deletedFilesPath;
this.deletedFileCount = deletedFileCount;
this.deletedFileTotalLenInBytes = deletedFileTotalLenInBytes;
}

public long getDeletedFileCount() {
Expand All @@ -48,6 +53,7 @@ public long getDeletedFileTotalLenInBytes() {
return deletedFileTotalLenInBytes;
}

@Nullable
public List<Path> getDeletedFilesPath() {
return deletedFilesPath;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public CleanOrphanFilesResult clean()
Map<String, Pair<Path, Long>> candidates = getCandidateDeletingFiles();
if (candidates.isEmpty()) {
return new CleanOrphanFilesResult(
deleteFiles, deleteFiles.size(), deletedFilesLenInBytes.get());
deleteFiles.size(), deletedFilesLenInBytes.get(), deleteFiles);
}
candidateDeletes = new HashSet<>(candidates.keySet());

Expand All @@ -128,7 +128,7 @@ public CleanOrphanFilesResult clean()
candidateDeletes.clear();

return new CleanOrphanFilesResult(
deleteFiles, deleteFiles.size(), deletedFilesLenInBytes.get());
deleteFiles.size(), deletedFilesLenInBytes.get(), deleteFiles);
}

private void collectWithoutDataFile(
Expand Down

0 comments on commit ee466bc

Please sign in to comment.