Skip to content

Commit 3aa6a57

Browse files
authored
Ensure dynamicMapping updates are handled in insertion order (#103047) (#103083)
The switch to holding dynamic fields in a hashmap effectively randomizes their iteration order. This can be troublesome when building the mapping update required by these updates. When iterating in an unknown order, recursing to the leaf mapper can occur many times `O(n^2)`. However, starting with insertion order, it will occur only `O(n)` times. closes: #103011
1 parent 5a0c79a commit 3aa6a57

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

docs/changelog/103047.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 103047
2+
summary: Ensure `dynamicMapping` updates are handled in insertion order
3+
area: Mapping
4+
type: bug
5+
issues: []

server/src/main/java/org/elasticsearch/index/mapper/DocumentParserContext.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
import java.util.ArrayList;
2323
import java.util.Collection;
2424
import java.util.Collections;
25-
import java.util.HashMap;
2625
import java.util.HashSet;
26+
import java.util.LinkedHashMap;
2727
import java.util.List;
2828
import java.util.Map;
2929
import java.util.Set;
@@ -166,9 +166,9 @@ protected DocumentParserContext(
166166
mappingParserContext,
167167
source,
168168
new HashSet<>(),
169-
new HashMap<>(),
169+
new LinkedHashMap<>(),
170170
new HashSet<>(),
171-
new HashMap<>(),
171+
new LinkedHashMap<>(),
172172
new ArrayList<>(),
173173
null,
174174
null,

0 commit comments

Comments
 (0)