MR: Fix NPE when InputSplit.getLocations is called on mappers - #1582
Merged
Conversation
Contributor
Author
|
cc: @guilload |
kbendick
approved these changes
Oct 11, 2020
Contributor
There was a problem hiding this comment.
This seems good to me.
And for the example you linked, I agree it seems not necessary to serialize the location data and then have to have special handling of that just for the toString method to have exact locality scheduling information, especially on the mappers once that information should not really be that relevant.
rdsr
reviewed
Oct 11, 2020
| @Override | ||
| public String[] getLocations() { | ||
| if (locations == null) { | ||
| if (locations == null && conf != null) { |
Contributor
There was a problem hiding this comment.
I think a comment can help here saying implementation of getLocations is only meant to be used during splits computation. getLocations won't be accurate when called on worker nodes
rdblue
approved these changes
Oct 12, 2020
Contributor
|
Merging since @rdsr's comment was addressed. Thanks, @shardulm94! |
anuragmantri
added a commit
to anuragmantri/iceberg
that referenced
this pull request
Jul 25, 2025
…3.5 tests (apache#13040) (apache#1582) Co-authored-by: Tom Tanaka <43331405+tomtongue@users.noreply.github.com>
This was referenced Sep 10, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
InputSplit.getLocations()can be called on mappers in some cases (Example). Since bothlocationsandconfare transient, the current code produces an NPE asconfis null on the mappers.The value of
locationsis not really relevant on the mappers since the tasks have already been distributed. So here we just returnANYWHEREwhen theconfis null. We can probably be more accurate by serializing thelocationsvalues if set, but I don't think its worth it.I discovered this issue while testing our internal Pig
LoadFuncimplementation which works with multipleInputFormats. Iceberg'sLoadFuncimplementation iniceberg-pigdoes not have this issue as it contains its ownInputSplitimplementation which does not provide location information (as opposed to theInputSplitimplementation iniceberg-mr).