aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/scala/spark/util/MemoryParam.scala
blob: 3726738842f9795dedf6b8c9925e85afd27ccbfb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
package spark.util

import spark.Utils

/**
 * An extractor object for parsing JVM memory strings, such as "10g", into an Int representing
 * the number of megabytes. Supports the same formats as Utils.memoryStringToMb.
 */
private[spark] object MemoryParam {
  def unapply(str: String): Option[Int] = {
    try {
      Some(Utils.memoryStringToMb(str))
    } catch {
      case e: NumberFormatException => None
    }
  }
}