-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Construct dynamic updates directly via object builders #81449
Merged
romseygeek
merged 29 commits into
elastic:master
from
romseygeek:mapper/dynamic-update-without-merging
Jan 25, 2022
Merged
Changes from 17 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
f54f87a
WIP
romseygeek 578179d
Merge remote-tracking branch 'origin/master' into mapper/dots-in-leaf…
romseygeek 28233e3
Add 'flatten' option to ObjectMapper
romseygeek 2b8b94f
Merge remote-tracking branch 'origin/master' into mapper/dots-in-leaf…
romseygeek 75ca57c
tidying up
romseygeek 4ee36b4
tidy up
romseygeek 81a3613
Merge remote-tracking branch 'origin/master' into mapper/dots-in-leaf…
romseygeek 4a47404
Merge remote-tracking branch 'origin/master' into mapper/dots-in-leaf…
romseygeek 4e977bf
Merge remote-tracking branch 'origin/master' into mapper/dynamic-upda…
romseygeek f328c83
Merge remote-tracking branch 'origin/master' into mapper/dynamic-upda…
romseygeek 0078b19
spotless
romseygeek ec17691
Merge remote-tracking branch 'origin/master' into mapper/dynamic-upda…
romseygeek cc75426
remove copyonwritehashmap from ObjectMapper
romseygeek 39ade03
oops
romseygeek 4c362c6
Merge branch 'master' into mapper/dynamic-update-without-merging
elasticmachine 087886a
spotless
romseygeek 824f12c
Merge remote-tracking branch 'origin/master' into mapper/dynamic-upda…
romseygeek 005079f
Merge remote-tracking branch 'origin/master' into mapper/dynamic-upda…
romseygeek 9f4da05
deef
romseygeek b951025
Merge remote-tracking branch 'origin/master' into mapper/dynamic-upda…
romseygeek 6f1f42c
deef
romseygeek b8d4d18
enforce that dynamic intermediate objects have been created already; …
romseygeek 6e94b9b
Merge remote-tracking branch 'origin/master' into mapper/dynamic-upda…
romseygeek 0832808
Merge remote-tracking branch 'origin/master' into mapper/dynamic-upda…
romseygeek efc371f
spotless
romseygeek 025be06
Add back check for empty field name
romseygeek 8dc3fcf
Merge remote-tracking branch 'origin/master' into mapper/dynamic-upda…
romseygeek 660d3db
Merge branch 'master' into mapper/dynamic-update-without-merging
elasticmachine be672cc
Merge branch 'master' into mapper/dynamic-update-without-merging
elasticmachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,6 +91,7 @@ protected static void parseNested(String name, Map<String, Object> node, NestedO | |
private Explicit<Boolean> includeInParent; | ||
private final String nestedTypePath; | ||
private final Query nestedTypeFilter; | ||
private final Version indexVersionCreated; | ||
|
||
NestedObjectMapper(String name, String fullPath, Map<String, Mapper> mappers, Builder builder) { | ||
super(name, fullPath, builder.enabled, builder.dynamic, mappers); | ||
|
@@ -102,6 +103,7 @@ protected static void parseNested(String name, Map<String, Object> node, NestedO | |
this.nestedTypeFilter = NestedPathFieldMapper.filter(builder.indexCreatedVersion, nestedTypePath); | ||
this.includeInParent = builder.includeInParent; | ||
this.includeInRoot = builder.includeInRoot; | ||
this.indexVersionCreated = builder.indexCreatedVersion; | ||
} | ||
|
||
public Query nestedTypeFilter() { | ||
|
@@ -137,6 +139,16 @@ public Map<String, Mapper> getChildren() { | |
return Collections.unmodifiableMap(this.mappers); | ||
} | ||
|
||
@Override | ||
public ObjectMapper.Builder newBuilder() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe pass There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ++ |
||
NestedObjectMapper.Builder builder = new NestedObjectMapper.Builder(simpleName(), indexVersionCreated); | ||
builder.enabled = enabled; | ||
builder.dynamic = dynamic; | ||
builder.includeInRoot = includeInRoot; | ||
builder.includeInParent = includeInParent; | ||
return builder; | ||
} | ||
|
||
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
builder.startObject(simpleName()); | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the PR description I'd have thought we'd validate each object's name as we went and this method would kind of vanish.
Also, if we're going to keep it, can we make return fast if there are no dots? Whenever I see
if (thing) {return;}
I don't have to think much. Butif (thing) {stuff} else {stuff}
makes me think more.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is used both when building dynamic updates and when parsing the input document. I think we can probably move a lot of it into the DotExpanding parser but let's keep that for a follow-up? I'll rearrange it to be clearer here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've done this in #82359