Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Dead Branch from IndexMetadataGenerations#withAddedSnapshot #73658

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,30 +94,22 @@ public String indexMetaBlobId(SnapshotId snapshotId, IndexId indexId) {
*/
public IndexMetaDataGenerations withAddedSnapshot(SnapshotId snapshotId, Map<IndexId, String> newLookup,
Map<String, String> newIdentifiers) {
final Map<String, String> identifierDeduplicator = new HashMap<>(this.identifiers.size());
for (String identifier : identifiers.keySet()) {
identifierDeduplicator.put(identifier, identifier);
}
final Map<SnapshotId, Map<IndexId, String>> updatedIndexMetaLookup = new HashMap<>(this.lookup);
final Map<String, String> updatedIndexMetaIdentifiers = new HashMap<>(identifiers);
updatedIndexMetaIdentifiers.putAll(newIdentifiers);
updatedIndexMetaLookup.compute(snapshotId, (snId, lookup) -> {
if (lookup == null) {
if (newLookup.isEmpty()) {
return null;
}
final Map<IndexId, String> fixedLookup = new HashMap<>(newLookup.size());
for (Map.Entry<IndexId, String> entry : newLookup.entrySet()) {
final String generation = entry.getValue();
fixedLookup.put(entry.getKey(), identifierDeduplicator.getOrDefault(generation, generation));
}
return Map.copyOf(fixedLookup);
} else {
final Map<IndexId, String> updated = new HashMap<>(lookup);
updated.putAll(newLookup);
return Map.copyOf(updated);
if (newLookup.isEmpty() == false) {
final Map<String, String> identifierDeduplicator = new HashMap<>(this.identifiers.size());
for (String identifier : identifiers.keySet()) {
identifierDeduplicator.put(identifier, identifier);
}
final Map<IndexId, String> fixedLookup = new HashMap<>(newLookup.size());
for (Map.Entry<IndexId, String> entry : newLookup.entrySet()) {
final String generation = entry.getValue();
fixedLookup.put(entry.getKey(), identifierDeduplicator.getOrDefault(generation, generation));
}
});
final Map<IndexId, String> existing = updatedIndexMetaLookup.put(snapshotId, Map.copyOf(fixedLookup));
assert existing == null : "unexpected existing index generation mappings " + existing;
}
return new IndexMetaDataGenerations(updatedIndexMetaLookup, updatedIndexMetaIdentifiers);
}

Expand Down