|
@@ -49,7 +49,7 @@ public class BlobStoreIndexShardSnapshots implements Iterable<SnapshotFiles>, To
|
|
|
private final Map<String, List<FileInfo>> physicalFiles;
|
|
private final Map<String, List<FileInfo>> physicalFiles;
|
|
|
|
|
|
|
|
public BlobStoreIndexShardSnapshots(List<SnapshotFiles> shardSnapshots) {
|
|
public BlobStoreIndexShardSnapshots(List<SnapshotFiles> shardSnapshots) {
|
|
|
- this.shardSnapshots = Collections.unmodifiableList(new ArrayList<>(shardSnapshots));
|
|
|
|
|
|
|
+ this.shardSnapshots = List.copyOf(shardSnapshots);
|
|
|
// Map between blob names and file info
|
|
// Map between blob names and file info
|
|
|
Map<String, FileInfo> newFiles = new HashMap<>();
|
|
Map<String, FileInfo> newFiles = new HashMap<>();
|
|
|
// Map between original physical names and file info
|
|
// Map between original physical names and file info
|
|
@@ -65,17 +65,12 @@ public class BlobStoreIndexShardSnapshots implements Iterable<SnapshotFiles>, To
|
|
|
// the first loop de-duplicates fileInfo objects that were loaded from different snapshots but refer to
|
|
// the first loop de-duplicates fileInfo objects that were loaded from different snapshots but refer to
|
|
|
// the same blob
|
|
// the same blob
|
|
|
for (FileInfo fileInfo : snapshot.indexFiles()) {
|
|
for (FileInfo fileInfo : snapshot.indexFiles()) {
|
|
|
- List<FileInfo> physicalFileList = physicalFiles.get(fileInfo.physicalName());
|
|
|
|
|
- if (physicalFileList == null) {
|
|
|
|
|
- physicalFileList = new ArrayList<>();
|
|
|
|
|
- physicalFiles.put(fileInfo.physicalName(), physicalFileList);
|
|
|
|
|
- }
|
|
|
|
|
- physicalFileList.add(newFiles.get(fileInfo.name()));
|
|
|
|
|
|
|
+ physicalFiles.computeIfAbsent(fileInfo.physicalName(), k -> new ArrayList<>()).add(newFiles.get(fileInfo.name()));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
Map<String, List<FileInfo>> mapBuilder = new HashMap<>();
|
|
Map<String, List<FileInfo>> mapBuilder = new HashMap<>();
|
|
|
for (Map.Entry<String, List<FileInfo>> entry : physicalFiles.entrySet()) {
|
|
for (Map.Entry<String, List<FileInfo>> entry : physicalFiles.entrySet()) {
|
|
|
- mapBuilder.put(entry.getKey(), Collections.unmodifiableList(new ArrayList<>(entry.getValue())));
|
|
|
|
|
|
|
+ mapBuilder.put(entry.getKey(), List.copyOf(entry.getValue()));
|
|
|
}
|
|
}
|
|
|
this.physicalFiles = unmodifiableMap(mapBuilder);
|
|
this.physicalFiles = unmodifiableMap(mapBuilder);
|
|
|
this.files = unmodifiableMap(newFiles);
|
|
this.files = unmodifiableMap(newFiles);
|
|
@@ -87,17 +82,12 @@ public class BlobStoreIndexShardSnapshots implements Iterable<SnapshotFiles>, To
|
|
|
Map<String, List<FileInfo>> physicalFiles = new HashMap<>();
|
|
Map<String, List<FileInfo>> physicalFiles = new HashMap<>();
|
|
|
for (SnapshotFiles snapshot : shardSnapshots) {
|
|
for (SnapshotFiles snapshot : shardSnapshots) {
|
|
|
for (FileInfo fileInfo : snapshot.indexFiles()) {
|
|
for (FileInfo fileInfo : snapshot.indexFiles()) {
|
|
|
- List<FileInfo> physicalFileList = physicalFiles.get(fileInfo.physicalName());
|
|
|
|
|
- if (physicalFileList == null) {
|
|
|
|
|
- physicalFileList = new ArrayList<>();
|
|
|
|
|
- physicalFiles.put(fileInfo.physicalName(), physicalFileList);
|
|
|
|
|
- }
|
|
|
|
|
- physicalFileList.add(files.get(fileInfo.name()));
|
|
|
|
|
|
|
+ physicalFiles.computeIfAbsent(fileInfo.physicalName(), k -> new ArrayList<>()).add(files.get(fileInfo.name()));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
Map<String, List<FileInfo>> mapBuilder = new HashMap<>();
|
|
Map<String, List<FileInfo>> mapBuilder = new HashMap<>();
|
|
|
for (Map.Entry<String, List<FileInfo>> entry : physicalFiles.entrySet()) {
|
|
for (Map.Entry<String, List<FileInfo>> entry : physicalFiles.entrySet()) {
|
|
|
- mapBuilder.put(entry.getKey(), Collections.unmodifiableList(new ArrayList<>(entry.getValue())));
|
|
|
|
|
|
|
+ mapBuilder.put(entry.getKey(), List.copyOf(entry.getValue()));
|
|
|
}
|
|
}
|
|
|
this.physicalFiles = unmodifiableMap(mapBuilder);
|
|
this.physicalFiles = unmodifiableMap(mapBuilder);
|
|
|
}
|
|
}
|
|
@@ -203,7 +193,7 @@ public class BlobStoreIndexShardSnapshots implements Iterable<SnapshotFiles>, To
|
|
|
// First we list all blobs with their file infos:
|
|
// First we list all blobs with their file infos:
|
|
|
builder.startArray(Fields.FILES);
|
|
builder.startArray(Fields.FILES);
|
|
|
for (Map.Entry<String, FileInfo> entry : files.entrySet()) {
|
|
for (Map.Entry<String, FileInfo> entry : files.entrySet()) {
|
|
|
- FileInfo.toXContent(entry.getValue(), builder, params);
|
|
|
|
|
|
|
+ FileInfo.toXContent(entry.getValue(), builder);
|
|
|
}
|
|
}
|
|
|
builder.endArray();
|
|
builder.endArray();
|
|
|
// Then we list all snapshots with list of all blobs that are used by the snapshot
|
|
// Then we list all snapshots with list of all blobs that are used by the snapshot
|