0
votes

Hello I wrote the following code

val receivedStream: DStream[PubsubSparkMessage] =
      PubsubSource.createStream(ssc, pubsubConfig, pubsubSubscriber)
    @volatile var receivedMessages: List[PubsubSparkMessage] = List() //scalastyle:ignore
    receivedStream.foreachRDD { rdd =>
      if (!rdd.isEmpty()) {
        receivedMessages = List(rdd.collect)
        receivedMessages
      }
    }

I am getting an error because type mismatch; My question is how to modify List[Array[PubsubSparkMessage]] to List[PubsubSparkMessage]

1
Please share the error when posting questions.Don Branson

1 Answers

0
votes

Something like:

val list : List[Array[PubsubSparkMessage]] = List()

val result = list.flatMap(x => x)