Github user srowen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/10185#discussion_r46931863
  
    --- Diff: 
streaming/src/main/scala/org/apache/spark/streaming/StreamingContext.scala ---
    @@ -892,12 +892,14 @@ object StreamingContext extends Logging {
       }
     
       private[streaming] def rddToFileName[T](prefix: String, suffix: String, 
time: Time): String = {
    -    if (prefix == null) {
    -      time.milliseconds.toString
    -    } else if (suffix == null || suffix.length ==0) {
    -      prefix + "-" + time.milliseconds
    -    } else {
    -      prefix + "-" + time.milliseconds + "." + suffix
    +    var result = new StringBuilder()
    +    if (prefix != null && prefix.length > 0) {
    +      result = result.append(prefix).append("-")
    +    }
    +    result = result.append(time.milliseconds)
    +    if (suffix != null && suffix.length > 0) {
    +      result = result.append(".").append(suffix)
         }
    +    result.toString()
    --- End diff --
    
    I think it's fine; it might be simpler without bothering with 
`StringBuilder` but not by much.
    (In your code you should use `val result` and you do not need to assign 
`result` each time.)
    
    ```
    var result = time.milliseconds.toString
    if (prefix != null && prefix.length > 0) {
      result = prefix + "-" result
    }
    if (suffix != null && suffix.length > 0) {
      result = result + "." + suffix
    }
    result
    ```


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to