29 lines
1.5 KiB
Diff
29 lines
1.5 KiB
Diff
# UNDF: UNDF-2026-000000102
|
|
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/DefaultStoreFileManager.java
|
|
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/DefaultStoreFileManager.java
|
|
@@ -17,6 +17,7 @@ import java.util.ArrayList;
|
|
import java.util.Collection;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
+import java.util.HashSet;
|
|
+import java.util.Set;
|
|
import java.util.stream.Collectors;
|
|
|
|
// ... (other imports unchanged)
|
|
|
|
@@ -229,9 +230,11 @@ public class DefaultStoreFileManager implements StoreFileManager {
|
|
@Override
|
|
public Collection<HStoreFile> getUnneededFiles(long maxTs, List<HStoreFile> filesCompacting) {
|
|
ImmutableList<HStoreFile> files = storeFiles.all;
|
|
+ // Build a HashSet once for O(1) membership test inside the stream.
|
|
+ // Without this, filesCompacting.contains() is O(C) per file — O(F*C) total.
|
|
+ Set<HStoreFile> compactingSet = new HashSet<>(filesCompacting);
|
|
// 1) We can never get rid of the last file which has the maximum seqid.
|
|
// 2) Files that are not the latest can't become one due to (1), so the rest are fair game.
|
|
return files.stream().limit(Math.max(0, files.size() - 1)).filter(sf -> {
|
|
long fileTs = sf.getReader().getMaxTimestamp();
|
|
- if (fileTs < maxTs && !filesCompacting.contains(sf)) {
|
|
+ if (fileTs < maxTs && !compactingSet.contains(sf)) {
|
|
LOG.info("Found an expired store file {} whose maxTimestamp is {}, which is below {}",
|
|
sf.getPath(), fileTs, maxTs);
|
|
return true;
|