Github user tdas commented on a diff in the pull request:
https://github.com/apache/spark/pull/2665#discussion_r20183888
--- Diff:
streaming/src/main/scala/org/apache/spark/streaming/dstream/StateDStream.scala
---
@@ -41,6 +42,28 @@ class StateDStream[K: ClassTag, V: ClassTag, S:
ClassTag](
override val mustCheckpoint = true
+ private [this] def computeUsingPreviousRDD (
+ parentRDD : RDD[(K, V)], prevStateRDD : RDD[(K, S)]) = {
+ // Define the function for the mapPartition operation on cogrouped RDD;
+ // first map the cogrouped tuple to tuples of required type,
+ // and then apply the update function
+ val updateFuncLocal = updateFunc
+ val finalFunc = (iterator: Iterator[(K, (Iterable[V], Iterable[S]))])
=> {
+ val i = iterator.map(t => {
+ val itr = t._2._2.iterator
+ val headOption = itr.hasNext match {
--- End diff --
I know this was existing code, but could you make this condition simpler
`val headOption = if (itr.hasNext) Some(itr.next()) else None`
Thanks :)
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]