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

    https://github.com/apache/incubator-gearpump/pull/131#discussion_r95948836
  
    --- Diff: 
streaming/src/main/scala/org/apache/gearpump/streaming/dsl/scalaapi/Stream.scala
 ---
    @@ -36,55 +38,95 @@ class Stream[T](
         private val edge: Option[OpEdge] = None) {
     
       /**
    -   * converts a value[T] to a list of value[R]
    +   * Returns a new stream by applying a flatMap function to each element
    +   * and flatten the results.
        *
    -   * @param fn FlatMap function
    +   * @param fn flatMap function
        * @param description The description message for this operation
        * @return A new stream with type [R]
        */
       def flatMap[R](fn: T => TraversableOnce[R], description: String = 
"flatMap"): Stream[R] = {
    -    val flatMapOp = ChainableOp(new FlatMapFunction[T, R](fn, description))
    -    graph.addVertex(flatMapOp)
    -    graph.addEdge(thisNode, edge.getOrElse(Direct), flatMapOp)
    -    new Stream[R](graph, flatMapOp)
    +    this.flatMap(FlatMapFunction(fn), description)
       }
     
       /**
    -   * Maps message of type T message of type R
    +   * Returns a new stream by applying a [[FlatMapFunction]] to each element
    +   * and flatten the results.
        *
    -   * @param fn Function
    +   * @param fn [[FlatMapFunction]]
    +   * @param description The description message for this operation
    +   * @return A new stream with type [R]
    +   */
    +  def flatMap[R](fn: FlatMapFunction[T, R], description: String): 
Stream[R] = {
    +    transform(new FlatMapper[T, R](fn, description))
    +  }
    +
    +  /**
    +   * Returns a new stream by applying a map function to each element.
    +   *
    +   * @param fn map function
        * @return A new stream with type [R]
        */
       def map[R](fn: T => R, description: String = "map"): Stream[R] = {
    -    this.flatMap({ data =>
    -      Option(fn(data))
    -    }, description)
    +    this.map(MapFunction(fn), description)
    +  }
    +
    +  /**
    +   * Returns a new stream by applying a [[MapFunction]] to each element.
    +   *
    +   * @param fn [[MapFunction]]
    +   * @return A new stream with type [R]
    +   */
    +  def map[R](fn: MapFunction[T, R], description: String): Stream[R] = {
    +    this.flatMap(FlatMapFunction(fn), description)
    --- End diff --
    
    never mind, I got it.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to