@@ -35,15 +35,15 @@ import org.apache.spark.streaming.api.java._
3535/**
3636 * Interface for Python callback function with three arguments
3737 */
38- private [python] trait PythonRDDFunction {
38+ private [python] trait PythonTransformFunction {
3939 def call (time : Long , rdds : JList [_]): JavaRDD [Array [Byte ]]
4040}
4141
4242/**
43- * Wrapper for PythonRDDFunction
43+ * Wrapper for PythonTransformFunction
4444 * TODO: support checkpoint
4545 */
46- private [python] class RDDFunction (@ transient var pfunc : PythonRDDFunction )
46+ private [python] class TransformFunction (@ transient var pfunc : PythonTransformFunction )
4747 extends function.Function2 [JList [JavaRDD [_]], Time , JavaRDD [Array [Byte ]]] with Serializable {
4848
4949 def apply (rdd : Option [RDD [_]], time : Time ): Option [RDD [Array [Byte ]]] = {
@@ -77,27 +77,27 @@ private[python] class RDDFunction(@transient var pfunc: PythonRDDFunction)
7777}
7878
7979/**
80- * Interface for Python Serializer to serialize PythonRDDFunction
80+ * Interface for Python Serializer to serialize PythonTransformFunction
8181 */
82- private [python] trait PythonRDDFunctionSerializer {
82+ private [python] trait PythonTransformFunctionSerializer {
8383 def dumps (id : String ): Array [Byte ] //
84- def loads (bytes : Array [Byte ]): PythonRDDFunction
84+ def loads (bytes : Array [Byte ]): PythonTransformFunction
8585}
8686
8787/**
88- * Wrapper for PythonRDDFunctionSerializer
88+ * Wrapper for PythonTransformFunctionSerializer
8989 */
90- private [python] class RDDFunctionSerializer (pser : PythonRDDFunctionSerializer ) {
91- def serialize (func : PythonRDDFunction ): Array [Byte ] = {
92- // get the id of PythonRDDFunction in py4j
90+ private [python] class TransformFunctionSerializer (pser : PythonTransformFunctionSerializer ) {
91+ def serialize (func : PythonTransformFunction ): Array [Byte ] = {
92+ // get the id of PythonTransformFunction in py4j
9393 val h = Proxy .getInvocationHandler(func.asInstanceOf [Proxy ])
9494 val f = h.getClass().getDeclaredField(" id" )
9595 f.setAccessible(true )
9696 val id = f.get(h).asInstanceOf [String ]
9797 pser.dumps(id)
9898 }
9999
100- def deserialize (bytes : Array [Byte ]): PythonRDDFunction = {
100+ def deserialize (bytes : Array [Byte ]): PythonTransformFunction = {
101101 pser.loads(bytes)
102102 }
103103}
@@ -107,18 +107,18 @@ private[python] class RDDFunctionSerializer(pser: PythonRDDFunctionSerializer) {
107107 */
108108private [python] object PythonDStream {
109109
110- // A serializer in Python, used to serialize PythonRDDFunction
111- var serializer : RDDFunctionSerializer = _
110+ // A serializer in Python, used to serialize PythonTransformFunction
111+ var serializer : TransformFunctionSerializer = _
112112
113113 // Register a serializer from Python, should be called during initialization
114- def registerSerializer (ser : PythonRDDFunctionSerializer ) = {
115- serializer = new RDDFunctionSerializer (ser)
114+ def registerSerializer (ser : PythonTransformFunctionSerializer ) = {
115+ serializer = new TransformFunctionSerializer (ser)
116116 }
117117
118118 // helper function for DStream.foreachRDD(),
119119 // cannot be `foreachRDD`, it will confusing py4j
120- def callForeachRDD (jdstream : JavaDStream [Array [Byte ]], pfunc : PythonRDDFunction ) {
121- val func = new RDDFunction ((pfunc))
120+ def callForeachRDD (jdstream : JavaDStream [Array [Byte ]], pfunc : PythonTransformFunction ) {
121+ val func = new TransformFunction ((pfunc))
122122 jdstream.dstream.foreachRDD((rdd, time) => func(Some (rdd), time))
123123 }
124124
@@ -134,10 +134,10 @@ private[python] object PythonDStream {
134134 * Base class for PythonDStream with some common methods
135135 */
136136private [python]
137- abstract class PythonDStream (parent : DStream [_], @ transient pfunc : PythonRDDFunction )
137+ abstract class PythonDStream (parent : DStream [_], @ transient pfunc : PythonTransformFunction )
138138 extends DStream [Array [Byte ]] (parent.ssc) {
139139
140- val func = new RDDFunction (pfunc)
140+ val func = new TransformFunction (pfunc)
141141
142142 override def dependencies = List (parent)
143143
@@ -153,7 +153,7 @@ abstract class PythonDStream(parent: DStream[_], @transient pfunc: PythonRDDFunc
153153 * as an template for future use, this can reduce the Python callbacks.
154154 */
155155private [python]
156- class PythonTransformedDStream (parent : DStream [_], @ transient pfunc : PythonRDDFunction ,
156+ class PythonTransformedDStream (parent : DStream [_], @ transient pfunc : PythonTransformFunction ,
157157 var reuse : Boolean = false )
158158 extends PythonDStream (parent, pfunc) {
159159
@@ -193,10 +193,10 @@ class PythonTransformedDStream (parent: DStream[_], @transient pfunc: PythonRDDF
193193 */
194194private [python]
195195class PythonTransformed2DStream (parent : DStream [_], parent2 : DStream [_],
196- @ transient pfunc : PythonRDDFunction )
196+ @ transient pfunc : PythonTransformFunction )
197197 extends DStream [Array [Byte ]] (parent.ssc) {
198198
199- val func = new RDDFunction (pfunc)
199+ val func = new TransformFunction (pfunc)
200200
201201 override def slideDuration : Duration = parent.slideDuration
202202
@@ -213,7 +213,7 @@ class PythonTransformed2DStream(parent: DStream[_], parent2: DStream[_],
213213 * similar to StateDStream
214214 */
215215private [python]
216- class PythonStateDStream (parent : DStream [Array [Byte ]], @ transient reduceFunc : PythonRDDFunction )
216+ class PythonStateDStream (parent : DStream [Array [Byte ]], @ transient reduceFunc : PythonTransformFunction )
217217 extends PythonDStream (parent, reduceFunc) {
218218
219219 super .persist(StorageLevel .MEMORY_ONLY )
@@ -235,16 +235,16 @@ class PythonStateDStream(parent: DStream[Array[Byte]], @transient reduceFunc: Py
235235 */
236236private [python]
237237class PythonReducedWindowedDStream (parent : DStream [Array [Byte ]],
238- @ transient preduceFunc : PythonRDDFunction ,
239- @ transient pinvReduceFunc : PythonRDDFunction ,
238+ @ transient preduceFunc : PythonTransformFunction ,
239+ @ transient pinvReduceFunc : PythonTransformFunction ,
240240 _windowDuration : Duration ,
241241 _slideDuration : Duration
242242 ) extends PythonDStream (parent, preduceFunc) {
243243
244244 super .persist(StorageLevel .MEMORY_ONLY )
245245 override val mustCheckpoint = true
246246
247- val invReduceFunc = new RDDFunction (pinvReduceFunc)
247+ val invReduceFunc = new TransformFunction (pinvReduceFunc)
248248
249249 def windowDuration : Duration = _windowDuration
250250 override def slideDuration : Duration = _slideDuration
0 commit comments