@@ -302,49 +302,59 @@ public void remove(String type) {
302
302
303
303
private void removeObjectAndFieldMappers (DocumentMapper docMapper ) {
304
304
// we need to remove those mappers
305
+ MapBuilder <String , FieldMappers > nameFieldMappers = newMapBuilder (this .nameFieldMappers );
306
+ MapBuilder <String , FieldMappers > indexNameFieldMappers = newMapBuilder (this .indexNameFieldMappers );
307
+ MapBuilder <String , FieldMappers > fullNameFieldMappers = newMapBuilder (this .fullNameFieldMappers );
308
+
305
309
for (FieldMapper mapper : docMapper .mappers ()) {
306
310
FieldMappers mappers = nameFieldMappers .get (mapper .names ().name ());
307
311
if (mappers != null ) {
308
312
mappers = mappers .remove (mapper );
309
313
if (mappers .isEmpty ()) {
310
- nameFieldMappers = newMapBuilder ( nameFieldMappers ) .remove (mapper .names ().name ()). map ( );
314
+ nameFieldMappers .remove (mapper .names ().name ());
311
315
} else {
312
- nameFieldMappers = newMapBuilder ( nameFieldMappers ) .put (mapper .names ().name (), mappers ). map ( );
316
+ nameFieldMappers .put (mapper .names ().name (), mappers );
313
317
}
314
318
}
315
319
316
320
mappers = indexNameFieldMappers .get (mapper .names ().indexName ());
317
321
if (mappers != null ) {
318
322
mappers = mappers .remove (mapper );
319
323
if (mappers .isEmpty ()) {
320
- indexNameFieldMappers = newMapBuilder ( indexNameFieldMappers ) .remove (mapper .names ().indexName ()). map ( );
324
+ indexNameFieldMappers .remove (mapper .names ().indexName ());
321
325
} else {
322
- indexNameFieldMappers = newMapBuilder ( indexNameFieldMappers ) .put (mapper .names ().indexName (), mappers ). map ( );
326
+ indexNameFieldMappers .put (mapper .names ().indexName (), mappers );
323
327
}
324
328
}
325
329
326
330
mappers = fullNameFieldMappers .get (mapper .names ().fullName ());
327
331
if (mappers != null ) {
328
332
mappers = mappers .remove (mapper );
329
333
if (mappers .isEmpty ()) {
330
- fullNameFieldMappers = newMapBuilder ( fullNameFieldMappers ) .remove (mapper .names ().fullName ()). map ( );
334
+ fullNameFieldMappers .remove (mapper .names ().fullName ());
331
335
} else {
332
- fullNameFieldMappers = newMapBuilder ( fullNameFieldMappers ) .put (mapper .names ().fullName (), mappers ). map ( );
336
+ fullNameFieldMappers .put (mapper .names ().fullName (), mappers );
333
337
}
334
338
}
335
339
}
340
+ this .nameFieldMappers = nameFieldMappers .map ();
341
+ this .indexNameFieldMappers = indexNameFieldMappers .map ();
342
+ this .fullNameFieldMappers = fullNameFieldMappers .map ();
336
343
344
+ MapBuilder <String , ObjectMappers > fullPathObjectMappers = newMapBuilder (this .fullPathObjectMappers );
337
345
for (ObjectMapper mapper : docMapper .objectMappers ().values ()) {
338
346
ObjectMappers mappers = fullPathObjectMappers .get (mapper .fullPath ());
339
347
if (mappers != null ) {
340
348
mappers = mappers .remove (mapper );
341
349
if (mappers .isEmpty ()) {
342
- fullPathObjectMappers = newMapBuilder ( fullPathObjectMappers ) .remove (mapper .fullPath ()). map ( );
350
+ fullPathObjectMappers .remove (mapper .fullPath ());
343
351
} else {
344
- fullPathObjectMappers = newMapBuilder ( fullPathObjectMappers ) .put (mapper .fullPath (), mappers ). map ( );
352
+ fullPathObjectMappers .put (mapper .fullPath (), mappers );
345
353
}
346
354
}
347
355
}
356
+
357
+ this .fullPathObjectMappers = fullPathObjectMappers .map ();
348
358
}
349
359
350
360
/**
0 commit comments