Github user zsxwing commented on a diff in the pull request:

    https://github.com/apache/spark/pull/9256#discussion_r44503186
  
    --- Diff: 
streaming/src/main/scala/org/apache/spark/streaming/rdd/TrackStateRDD.scala ---
    @@ -0,0 +1,188 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.streaming.rdd
    +
    +import java.io.{IOException, ObjectInputStream, ObjectOutputStream}
    +
    +import scala.collection.mutable.ArrayBuffer
    +import scala.reflect.ClassTag
    +
    +import org.apache.spark.rdd.{MapPartitionsRDD, RDD}
    +import org.apache.spark.streaming.{Time, StateImpl, State}
    +import org.apache.spark.streaming.util.{EmptyStateMap, StateMap}
    +import org.apache.spark.util.Utils
    +import org.apache.spark._
    +
    +/**
    + * Record storing the keyed-state [[TrackStateRDD]]. Each record contains 
a [[StateMap]] and a
    + * sequence of records returned by the tracking function of 
`trackStateByKey`.
    + */
    +private[streaming] case class TrackStateRDDRecord[K, S, T](
    +    var stateMap: StateMap[K, S], var emittedRecords: Seq[T])
    +
    +/**
    + * Partition of the [[TrackStateRDD]], which depends on corresponding 
partitions of prev state
    + * RDD, and a partitioned keyed-data RDD
    + */
    +private[streaming] class TrackStateRDDPartition(
    +    idx: Int,
    +    @transient private var prevStateRDD: RDD[_],
    +    @transient private var partitionedDataRDD: RDD[_]) extends Partition {
    +
    +  private[rdd] var previousSessionRDDPartition: Partition = null
    +  private[rdd] var partitionedDataRDDPartition: Partition = null
    +
    +  override def index: Int = idx
    +  override def hashCode(): Int = idx
    +
    +  @throws(classOf[IOException])
    +  private def writeObject(oos: ObjectOutputStream): Unit = 
Utils.tryOrIOException {
    +    // Update the reference to parent split at the time of task 
serialization
    +    previousSessionRDDPartition = prevStateRDD.partitions(index)
    +    partitionedDataRDDPartition = partitionedDataRDD.partitions(index)
    +    oos.defaultWriteObject()
    +  }
    +}
    +
    +
    +/**
    + * RDD storing the keyed-state of `trackStateByKey` and corresponding 
emitted records.
    + * Each partition of this RDD has a single record of type 
[[TrackStateRDDRecord]]. This contains a
    + * [[StateMap]] (containing the keyed-states) and the sequence of records 
returned by the tracking
    + * function of  `trackStateByKey`.
    + * @param prevStateRDD The previous TrackStateRDD on whose StateMap data 
`this` RDD will be created
    + * @param partitionedDataRDD The partitioned data RDD which is used update 
the previous StateMaps
    + *                           in the `prevStateRDD` to create `this` RDD
    + * @param trackingFunction The function that will be used to update state 
and return new data
    + * @param batchTime        The time of the batch to which this RDD belongs 
to. Use to update
    + */
    +private[streaming] class TrackStateRDD[K: ClassTag, V: ClassTag, S: 
ClassTag, T: ClassTag](
    +    private var prevStateRDD: RDD[TrackStateRDDRecord[K, S, T]],
    +    private var partitionedDataRDD: RDD[(K, V)],
    +    trackingFunction: (Time, K, Option[V], State[S]) => Option[T],
    +    batchTime: Time, timeoutThresholdTime: Option[Long]
    --- End diff --
    
    no doc for `timeoutThresholdTime `


---
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]

Reply via email to