Skip to content

Commit

Permalink
[SPARK-19991][CORE][YARN] FileSegmentManagedBuffer performance improv…
Browse files Browse the repository at this point in the history
…ement

## What changes were proposed in this pull request?

Avoid `NoSuchElementException` every time `ConfigProvider.get(val, default)` falls back to default. This apparently causes non-trivial overhead in at least one path, and can easily be avoided.

See #17329

## How was this patch tested?

Existing tests

Author: Sean Owen <[email protected]>

Closes #17567 from srowen/SPARK-19991.
  • Loading branch information
srowen committed Apr 9, 2017
1 parent 34fc48f commit 1f0de3c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ public String get(String name) {
return value;
}

@Override
public String get(String name, String defaultValue) {
String value = config.get(name);
return value == null ? defaultValue : value;
}

@Override
public Iterable<Map.Entry<String, String>> getAll() {
return config.entrySet();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ public String get(String name) {
return value;
}

@Override
public String get(String name, String defaultValue) {
String value = conf.get(name);
return value == null ? defaultValue : value;
}

@Override
public Iterable<Map.Entry<String, String>> getAll() {
return conf;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ object SparkTransportConf {

new TransportConf(module, new ConfigProvider {
override def get(name: String): String = conf.get(name)

override def get(name: String, defaultValue: String): String = conf.get(name, defaultValue)
override def getAll(): java.lang.Iterable[java.util.Map.Entry[String, String]] = {
conf.getAll.toMap.asJava.entrySet()
}
Expand Down

0 comments on commit 1f0de3c

Please sign in to comment.