Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,10 @@ public long getLength() {
public String[] getLocations() {
// The implementation of getLocations() is only meant to be used during split computation
// getLocations() won't be accurate when called on worker nodes and will always return "*"
if (locations == null && conf != null) {
boolean localityPreferred = conf.getBoolean(InputFormatConfig.LOCALITY, false);
if (locations == null) {
boolean localityPreferred =
conf != null && conf.getBoolean(InputFormatConfig.LOCALITY, false);
locations = localityPreferred ? Util.blockLocations(task, conf) : ANYWHERE.clone();
} else {
locations = ANYWHERE.clone();
}

return locations;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,8 @@ public void testLocality() throws Exception {

for (InputSplit split : testInputFormat.create(builder.conf()).getSplits()) {
assertThat(split.getLocations()).containsExactly("localhost");
// repeated calls must return the same locations that were computed and cached above
assertThat(split.getLocations()).containsExactly("localhost");
}
}

Expand Down
Loading