-
Notifications
You must be signed in to change notification settings - Fork 28.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-10227] fatal warnings with sbt on Scala 2.11 #8433
Conversation
@@ -47,7 +48,7 @@ import org.apache.spark.util.Utils | |||
* @tparam T partial data that can be added in | |||
*/ | |||
class Accumulable[R, T] private[spark] ( | |||
@transient initialValue: R, | |||
@(transient @param @field) initialValue: R, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, tough call. If the code is acting like this is a field, and it's not, then that seems like a problem to solved in itself. I think a lot of the annotations could be removed. For example, initialValue
here should never become a field in this object.
I get the potential problem, that code changes in a way that makes this a field. If the field isn't serializable, it starts to fail. Unit tests would (hopefully) catch it. But, I also think that having such a new field become transient isn't a good solution; it piles an unintended change on an unintended change.
In fact, I think a lot of current usages of @transient
in the code are poor practice anyway; they exist to make an object serialize, but it's not clear that the object makes sense without the field after deserialization.
What do you / others think about just removing these unneeded annotations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My original fix was to remove the unneeded annotations, and to transform the parameter where the annotation was making sense into private val
. But it looks so much like a common pattern, that I didn't change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/cc @rxin since we talked about this before, and he's the one who added -XfatalWarnings
to the build.
What's the meaning of param and field? The scala documentation doesn't really say anything: http://www.scala-lang.org/api/2.10.4/index.html#scala.annotation.meta.param "Consult the documentation in package scala.annotation.meta." But scala.annotation.meta doesn't say much either. |
It indicates on which of the elements generated for the class parameter to apply the annotation. The base question was mostly: do we want to remove the |
@rxin et al I think I'd favor removing these |
Updated the changes for |
Test build #1711 has finished for PR 8433 at commit
|
@@ -24,6 +24,7 @@ import java.util.{Collections, ArrayList => JArrayList, List => JList, Map => JM | |||
import scala.collection.JavaConverters._ | |||
import scala.collection.mutable | |||
import scala.language.existentials | |||
import scala.annotation.meta._ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this import still needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it is a left over of the previous changes.
Test build #1719 has finished for PR 8433 at commit
|
Aside from possible removing those imports, yes, this looks good to me for master/1.6. |
Just giving this one more go through Jenkins, but still LGTM. our test framework is just testing Scala 2.10, not 2.11. However, it seems like this patch can only make it less broken for Scala 2.11 + SBT if it doesn't work now, so I think the risk of merging into master is low. The changes seem sound and positive in any event. |
Test build #1726 has finished for PR 8433 at commit
|
…sient annotations The Scala 2.11 SBT build currently fails for Spark 1.6.0 and master due to warnings about the `transient` annotation: ``` [error] [warn] /Users/joshrosen/Documents/spark/extras/kinesis-asl/src/main/scala/org/apache/spark/streaming/kinesis/KinesisBackedBlockRDD.scala:73: no valid targets for annotation on value sc - it is discarded unused. You may specify targets with meta-annotations, e.g. (transient param) [error] [warn] transient sc: SparkContext, ``` This fix implemented here is the same as what we did in #8433: remove the `transient` annotations when they are not necessary and replace use `transient private val` in the remaining cases. Author: Josh Rosen <joshrosen@databricks.com> Closes #10479 from JoshRosen/fix-sbt-2.11.
The bulk of the changes are on
@transient
annotation on class parameter. Often the compiler doesn't generate a field for this parameters, so the the transient annotation would be unnecessary.But if the class parameter are used in methods, then fields are created. So it is safer to keep the annotations.
The remainder are some potential bugs, and deprecated syntax.