spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From srowen <...@git.apache.org>
Subject [GitHub] spark pull request: [SPARK-12317][SQL]Support configurable value i...
Date Tue, 05 Jan 2016 10:59:36 GMT
Github user srowen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/10314#discussion_r48833641
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/SQLConf.scala ---
    @@ -100,6 +101,37 @@ private[spark] object SQLConf {
             }
           }, _.toString, doc, isPublic)
     
    +    def intMemConf(
    +        key: String,
    +        defaultValue: Option[Int] = None,
    +        doc: String = "",
    +        isPublic: Boolean = true): SQLConfEntry[Int] =
    +      SQLConfEntry(key, defaultValue, { v =>
    +        val isInteger: Option[Int] = try {
    --- End diff --
    
    I find this body simpler:
    
    ```
    try {
      v.toInt
    } catch {
      case _: NumberFormatException =>
        val sizeInBytes = try {
          Utils.byteStringAsBytes(v)
        } catch {
          case _: NumberFormatException =>
            throw new IllegalArgumentException(s"$key should be int, but was $v")
        }
        require(getSizeAsBytes <= Int.MaxValue && getSizeAsBytes >= Int.MinValue)
        sizeInBytes.toInt
    }
    ```
    
    I'd like to hear from @marmbrus or @viirya for example before merging a change like this.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message