Github user rotationsymmetry commented on a diff in the pull request: https://github.com/apache/spark/pull/8022#discussion_r38162690 --- Diff: mllib/src/main/scala/org/apache/spark/mllib/regression/StreamingLinearRegressionWithSGD.scala --- @@ -47,6 +52,7 @@ class StreamingLinearRegressionWithSGD private[mllib] ( private var numIterations: Int, private var miniBatchFraction: Double) extends StreamingLinearAlgorithm[LinearRegressionModel, LinearRegressionWithSGD] + with StreamingDecaySetter[StreamingLinearRegressionWithSGD] --- End diff -- Thanks for the suggestions. I agree we can consolidate `StreamingDecay` and `StreamingDecaySetter` into one class. Regarding the implementation. If we do the following ``` scala trait StreamingDecay[T] { self: T => def setX: T = this } class StreamingLinearAlgorithm extends StreamingDecay[StreamingLinearAlgorithm] class StreamingLinearRegressionWithSGD extends StreamingLinearAlgorithm val s = new StreamingLinearRegressionWithSGD() ``` Then the return type of `s.setX` will be `StreamingLinearAlgorithm` since this is what the generic `T` refers to. So I propose we override the `setX` method to get the correct type. ``` scala trait StreamingDecay { def setX: this.type = this } class StreamingLinearAlgorithm extends StreamingDecay class StreamingLinearRegressionWithSGD extends StreamingLinearAlgorithm { override def setX: this.type = { super.setX this } } val s = new StreamingLinearRegressionWithSGD() ``` I have run this proposed implementation and the code is working. Shall we proceed?
--- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org