You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by srowen <gi...@git.apache.org> on 2015/12/08 10:37:38 UTC
[GitHub] spark pull request: [SPARK-12136] [STREAMING] rddToFileName does n...
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 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