forked from apache/spark
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implementing transform function in Python
- Loading branch information
Ken Takagiwa
authored and
Ken Takagiwa
committed
Jul 16, 2014
1 parent
94a0787
commit 69e9cd3
Showing
4 changed files
with
42 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...aming/src/main/scala/org/apache/spark/streaming/api/python/PythonTransformedDStream.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.apache.spark.streaming.api.python | ||
|
||
import org.apache.spark.Accumulator | ||
import org.apache.spark.api.python.PythonRDD | ||
import org.apache.spark.broadcast.Broadcast | ||
import org.apache.spark.rdd.RDD | ||
import org.apache.spark.streaming.api.java.JavaDStream | ||
import org.apache.spark.streaming.{Time, Duration} | ||
import org.apache.spark.streaming.dstream.DStream | ||
|
||
import scala.reflect.ClassTag | ||
|
||
/** | ||
* Created by ken on 7/15/14. | ||
*/ | ||
class PythonTransformedDStream[T: ClassTag]( | ||
parents: Seq[DStream[T]], | ||
command: Array[Byte], | ||
envVars: JMap[String, String], | ||
pythonIncludes: JList[String], | ||
preservePartitoning: Boolean, | ||
pythonExec: String, | ||
broadcastVars: JList[Broadcast[Array[Byte]]], | ||
accumulator: Accumulator[JList[Array[Byte]]] | ||
) extends DStream[Array[Byte]](parent.ssc) { | ||
|
||
override def dependencies = List(parent) | ||
|
||
override def slideDuration: Duration = parent.slideDuration | ||
|
||
//pythonDStream compute | ||
override def compute(validTime: Time): Option[RDD[Array[Byte]]] = { | ||
val parentRDDs = parents.map(_.getOrCompute(validTime).orNull).toSeq | ||
Some() | ||
} | ||
val asJavaDStream = JavaDStream.fromDStream(this) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters