4242import java .util .LinkedList ;
4343import java .util .List ;
4444import java .util .Optional ;
45- import java .util .TreeSet ;
45+ import java .util .PriorityQueue ;
4646import java .util .concurrent .ExecutionException ;
4747import java .util .concurrent .ExecutorService ;
4848
@@ -57,7 +57,7 @@ public class BucketedAppendCompactManager extends CompactFutureManager {
5757
5858 private final ExecutorService executor ;
5959 private final DeletionVectorsMaintainer dvMaintainer ;
60- private final TreeSet <DataFileMeta > toCompact ;
60+ private final PriorityQueue <DataFileMeta > toCompact ;
6161 private final int minFileNum ;
6262 private final int maxFileNum ;
6363 private final long targetFileSize ;
@@ -78,7 +78,7 @@ public BucketedAppendCompactManager(
7878 @ Nullable CompactionMetrics .Reporter metricsReporter ) {
7979 this .executor = executor ;
8080 this .dvMaintainer = dvMaintainer ;
81- this .toCompact = new TreeSet <>(fileComparator (false ));
81+ this .toCompact = new PriorityQueue <>(fileComparator (false ));
8282 this .toCompact .addAll (restored );
8383 this .minFileNum = minFileNum ;
8484 this .maxFileNum = maxFileNum ;
@@ -197,7 +197,7 @@ Optional<List<DataFileMeta>> pickCompactBefore() {
197197 LinkedList <DataFileMeta > candidates = new LinkedList <>();
198198
199199 while (!toCompact .isEmpty ()) {
200- DataFileMeta file = toCompact .pollFirst ();
200+ DataFileMeta file = toCompact .poll ();
201201 candidates .add (file );
202202 totalFileSize += file .fileSize ();
203203 fileNum ++;
@@ -217,7 +217,7 @@ Optional<List<DataFileMeta>> pickCompactBefore() {
217217 }
218218
219219 @ VisibleForTesting
220- TreeSet <DataFileMeta > getToCompact () {
220+ PriorityQueue <DataFileMeta > getToCompact () {
221221 return toCompact ;
222222 }
223223
0 commit comments