Skip to content

Commit 717c0ca

Browse files
committed
updated to make more concise
1 parent fc45476 commit 717c0ca

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

core/src/main/scala/org/apache/spark/SparkConf.scala

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -237,24 +237,15 @@ class SparkConf(loadDefaults: Boolean) extends Cloneable with Logging {
237237
}
238238

239239
// Validate memoryFraction
240-
val storageMemFraction = getDouble("spark.storage.memoryFraction", 0.6)
241-
val shuffleMemFraction = getDouble("spark.shuffle.memoryFraction", 0.3)
242-
val shuffleSafFraction = getDouble("spark.shuffle.safetyFraction", 0.8)
243-
244-
if (storageMemFraction > 1 || storageMemFraction < 0) {
245-
val msg = s"spark.storage.memoryFraction should be between 0 and 1 " +
246-
s"(was '$storageMemFraction')."
247-
throw new IllegalArgumentException(msg)
248-
}
249-
if (shuffleMemFraction > 1 || shuffleMemFraction < 0) {
250-
val msg = s"spark.shuffle.memoryFraction should be between 0 and 1 " +
251-
s"(was '$shuffleMemFraction')."
252-
throw new IllegalArgumentException(msg)
253-
}
254-
if (shuffleSafFraction > 1 || shuffleSafFraction < 0) {
255-
val msg = s"spark.shuffle.safetyFraction should be between 0 and 1 " +
256-
s"(was '$shuffleSafFraction')."
257-
throw new IllegalArgumentException(msg)
240+
val memoryKeys = Seq(
241+
"spark.storage.memoryFraction",
242+
"spark.shuffle.memoryFraction",
243+
"spark.shuffle.safetyFraction")
244+
for (key -> memoryKeys) {
245+
val value = getDouble(key, 0.5)
246+
if (value > 1 || value < 0) {
247+
throw new IllegalArgumentException("$key should be between 0 and (was '$value').")
248+
}
258249
}
259250

260251
// Check for legacy configs

0 commit comments

Comments
 (0)