LuciferYang commented on a change in pull request #29836:
URL: https://github.com/apache/spark/pull/29836#discussion_r492703765
##########
File path:
streaming/src/main/scala/org/apache/spark/streaming/DStreamGraph.scala
##########
@@ -29,8 +28,8 @@ import org.apache.spark.util.Utils
final private[streaming] class DStreamGraph extends Serializable with Logging {
- private val inputStreams = new ArrayBuffer[InputDStream[_]]()
- private val outputStreams = new ArrayBuffer[DStream[_]]()
+ private var inputStreams = Array.empty[InputDStream[_]]
Review comment:
Let me try with mutable.Seq, will feedback later
##########
File path:
streaming/src/main/scala/org/apache/spark/streaming/DStreamGraph.scala
##########
@@ -29,8 +28,8 @@ import org.apache.spark.util.Utils
final private[streaming] class DStreamGraph extends Serializable with Logging {
- private val inputStreams = new ArrayBuffer[InputDStream[_]]()
- private val outputStreams = new ArrayBuffer[DStream[_]]()
+ private var inputStreams = Array.empty[InputDStream[_]]
Review comment:
- default implementation of `mutable.Seq` is `ArrayBuffer`, it can't
work.
- default implementation of `immutable.Seq` is `List`, it can't work also
- `mutable.ArraySeq` and `immutable.ArraySeq` both work, but still need use
`var` because they are not `Growable`
##########
File path:
streaming/src/main/scala/org/apache/spark/streaming/DStreamGraph.scala
##########
@@ -29,8 +28,8 @@ import org.apache.spark.util.Utils
final private[streaming] class DStreamGraph extends Serializable with Logging {
- private val inputStreams = new ArrayBuffer[InputDStream[_]]()
- private val outputStreams = new ArrayBuffer[DStream[_]]()
+ private var inputStreams = Array.empty[InputDStream[_]]
Review comment:
- default implementation of `mutable.Seq` is `ArrayBuffer`, it can't
work.
- default implementation of `immutable.Seq` is `List`, it can't work also
- `mutable.ArraySeq` and `immutable.ArraySeq` both work, but still need use
`var` because they are not `Growable`, no `+=` method
##########
File path:
streaming/src/main/scala/org/apache/spark/streaming/DStreamGraph.scala
##########
@@ -29,8 +28,8 @@ import org.apache.spark.util.Utils
final private[streaming] class DStreamGraph extends Serializable with Logging {
- private val inputStreams = new ArrayBuffer[InputDStream[_]]()
- private val outputStreams = new ArrayBuffer[DStream[_]]()
+ private var inputStreams = Array.empty[InputDStream[_]]
Review comment:
recommend `mutable.ArraySeq` or `immutable.ArraySeq`? Or keep use
`Array`?
##########
File path:
streaming/src/main/scala/org/apache/spark/streaming/DStreamGraph.scala
##########
@@ -29,8 +28,8 @@ import org.apache.spark.util.Utils
final private[streaming] class DStreamGraph extends Serializable with Logging {
- private val inputStreams = new ArrayBuffer[InputDStream[_]]()
- private val outputStreams = new ArrayBuffer[DStream[_]]()
+ private var inputStreams = Array.empty[InputDStream[_]]
Review comment:
recommend use `mutable.ArraySeq` or `immutable.ArraySeq`? Or keep use
`Array`?
##########
File path:
streaming/src/main/scala/org/apache/spark/streaming/DStreamGraph.scala
##########
@@ -29,8 +28,8 @@ import org.apache.spark.util.Utils
final private[streaming] class DStreamGraph extends Serializable with Logging {
- private val inputStreams = new ArrayBuffer[InputDStream[_]]()
- private val outputStreams = new ArrayBuffer[DStream[_]]()
+ private var inputStreams = Array.empty[InputDStream[_]]
Review comment:
- default implementation of `mutable.Seq` in Scala 2.13 is
`ArrayBuffer`, it can't work.
- default implementation of `immutable.Seq` in Scala 2.13 is `List`, it
can't work also
- `mutable.ArraySeq` and `immutable.ArraySeq` both work, but still need use
`var` because they are not `Growable`, no `+=` method
##########
File path:
streaming/src/main/scala/org/apache/spark/streaming/DStreamGraph.scala
##########
@@ -29,8 +28,8 @@ import org.apache.spark.util.Utils
final private[streaming] class DStreamGraph extends Serializable with Logging {
- private val inputStreams = new ArrayBuffer[InputDStream[_]]()
- private val outputStreams = new ArrayBuffer[DStream[_]]()
+ private var inputStreams = Array.empty[InputDStream[_]]
Review comment:
recommend use `mutable.ArraySeq` or keep use `Array`?
`immutable.ArraySeq` has different namespace between Scala 2.12 and Scala 2.13
##########
File path:
streaming/src/main/scala/org/apache/spark/streaming/DStreamGraph.scala
##########
@@ -29,8 +28,8 @@ import org.apache.spark.util.Utils
final private[streaming] class DStreamGraph extends Serializable with Logging {
- private val inputStreams = new ArrayBuffer[InputDStream[_]]()
- private val outputStreams = new ArrayBuffer[DStream[_]]()
+ private var inputStreams = Array.empty[InputDStream[_]]
Review comment:
- default implementation of `mutable.Seq` in Scala 2.13 is
`ArrayBuffer`, it can't work.
- default implementation of `immutable.Seq` in Scala 2.13 is `List`, it
can't work also
- `mutable.ArraySeq` and `immutable.ArraySeq` both work in Scala 2.13, but
still need use `var` because they are not `Growable`, no `+=` method
##########
File path:
streaming/src/main/scala/org/apache/spark/streaming/DStreamGraph.scala
##########
@@ -29,8 +28,8 @@ import org.apache.spark.util.Utils
final private[streaming] class DStreamGraph extends Serializable with Logging {
- private val inputStreams = new ArrayBuffer[InputDStream[_]]()
- private val outputStreams = new ArrayBuffer[DStream[_]]()
+ private var inputStreams = Array.empty[InputDStream[_]]
Review comment:
Ok ~ Address 3fef228 fix this
##########
File path:
streaming/src/main/scala/org/apache/spark/streaming/DStreamGraph.scala
##########
@@ -29,8 +29,8 @@ import org.apache.spark.util.Utils
final private[streaming] class DStreamGraph extends Serializable with Logging {
- private val inputStreams = new ArrayBuffer[InputDStream[_]]()
- private val outputStreams = new ArrayBuffer[DStream[_]]()
+ private var inputStreams = mutable.ArraySeq.empty[InputDStream[_]]
Review comment:
if this is a `val`, which api should use at line 94 & line 101, there
is currently a reassignment here
##########
File path:
streaming/src/main/scala/org/apache/spark/streaming/DStreamGraph.scala
##########
@@ -29,8 +29,8 @@ import org.apache.spark.util.Utils
final private[streaming] class DStreamGraph extends Serializable with Logging {
- private val inputStreams = new ArrayBuffer[InputDStream[_]]()
- private val outputStreams = new ArrayBuffer[DStream[_]]()
+ private var inputStreams = mutable.ArraySeq.empty[InputDStream[_]]
Review comment:
but `+=` is not a member of `mutable.ArraySeq` because
`mutable.ArraySeq` is not `Growable ` .....
##########
File path:
streaming/src/main/scala/org/apache/spark/streaming/DStreamGraph.scala
##########
@@ -29,8 +29,8 @@ import org.apache.spark.util.Utils
final private[streaming] class DStreamGraph extends Serializable with Logging {
- private val inputStreams = new ArrayBuffer[InputDStream[_]]()
- private val outputStreams = new ArrayBuffer[DStream[_]]()
+ private var inputStreams = mutable.ArraySeq.empty[InputDStream[_]]
Review comment:

##########
File path:
streaming/src/main/scala/org/apache/spark/streaming/DStreamGraph.scala
##########
@@ -29,8 +29,8 @@ import org.apache.spark.util.Utils
final private[streaming] class DStreamGraph extends Serializable with Logging {
- private val inputStreams = new ArrayBuffer[InputDStream[_]]()
- private val outputStreams = new ArrayBuffer[DStream[_]]()
+ private var inputStreams = mutable.ArraySeq.empty[InputDStream[_]]
Review comment:
```
Welcome to Scala 2.13.3 (OpenJDK 64-Bit Server VM, Java 1.8.0_232).
Type in expressions for evaluation. Or try :help.
scala> val s = scala.collection.mutable.ArraySeq.empty[Int]
val s: scala.collection.mutable.ArraySeq[Int] = ArraySeq()
scala> s += 1
^
error: value += is not a member of
scala.collection.mutable.ArraySeq[Int]
Expression does not convert to assignment because receiver is not
assignable.
```
execute in Scala shell above
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]