@@ -94,30 +94,22 @@ public String indexMetaBlobId(SnapshotId snapshotId, IndexId indexId) {
94
94
*/
95
95
public IndexMetaDataGenerations withAddedSnapshot (SnapshotId snapshotId , Map <IndexId , String > newLookup ,
96
96
Map <String , String > newIdentifiers ) {
97
- final Map <String , String > identifierDeduplicator = new HashMap <>(this .identifiers .size ());
98
- for (String identifier : identifiers .keySet ()) {
99
- identifierDeduplicator .put (identifier , identifier );
100
- }
101
97
final Map <SnapshotId , Map <IndexId , String >> updatedIndexMetaLookup = new HashMap <>(this .lookup );
102
98
final Map <String , String > updatedIndexMetaIdentifiers = new HashMap <>(identifiers );
103
99
updatedIndexMetaIdentifiers .putAll (newIdentifiers );
104
- updatedIndexMetaLookup .compute (snapshotId , (snId , lookup ) -> {
105
- if (lookup == null ) {
106
- if (newLookup .isEmpty ()) {
107
- return null ;
108
- }
109
- final Map <IndexId , String > fixedLookup = new HashMap <>(newLookup .size ());
110
- for (Map .Entry <IndexId , String > entry : newLookup .entrySet ()) {
111
- final String generation = entry .getValue ();
112
- fixedLookup .put (entry .getKey (), identifierDeduplicator .getOrDefault (generation , generation ));
113
- }
114
- return Map .copyOf (fixedLookup );
115
- } else {
116
- final Map <IndexId , String > updated = new HashMap <>(lookup );
117
- updated .putAll (newLookup );
118
- return Map .copyOf (updated );
100
+ if (newLookup .isEmpty () == false ) {
101
+ final Map <String , String > identifierDeduplicator = new HashMap <>(this .identifiers .size ());
102
+ for (String identifier : identifiers .keySet ()) {
103
+ identifierDeduplicator .put (identifier , identifier );
104
+ }
105
+ final Map <IndexId , String > fixedLookup = new HashMap <>(newLookup .size ());
106
+ for (Map .Entry <IndexId , String > entry : newLookup .entrySet ()) {
107
+ final String generation = entry .getValue ();
108
+ fixedLookup .put (entry .getKey (), identifierDeduplicator .getOrDefault (generation , generation ));
119
109
}
120
- });
110
+ final Map <IndexId , String > existing = updatedIndexMetaLookup .put (snapshotId , Map .copyOf (fixedLookup ));
111
+ assert existing == null : "unexpected existing index generation mappings " + existing ;
112
+ }
121
113
return new IndexMetaDataGenerations (updatedIndexMetaLookup , updatedIndexMetaIdentifiers );
122
114
}
123
115
0 commit comments