Skip to content

Commit

Permalink
Ensure dynamicMapping updates are handled in insertion order (#103047) (
Browse files Browse the repository at this point in the history
#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
  • Loading branch information
benwtrent committed Dec 6, 2023
1 parent 5a0c79a commit 3aa6a57
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions docs/changelog/103047.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 103047
summary: Ensure `dynamicMapping` updates are handled in insertion order
area: Mapping
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -166,9 +166,9 @@ protected DocumentParserContext(
mappingParserContext,
source,
new HashSet<>(),
new HashMap<>(),
new LinkedHashMap<>(),
new HashSet<>(),
new HashMap<>(),
new LinkedHashMap<>(),
new ArrayList<>(),
null,
null,
Expand Down

0 comments on commit 3aa6a57

Please sign in to comment.