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

    https://github.com/apache/spark/pull/1195#discussion_r14306024
  
    --- Diff: 
streaming/src/main/scala/org/apache/spark/streaming/receiver/BlockGenerator.scala
 ---
    @@ -48,6 +49,13 @@ private[streaming] class BlockGenerator(
     
       private case class Block(id: StreamBlockId, buffer: ArrayBuffer[Any])
     
    +  /**
    +   * Internal representation of a callback function and its argument.
    +   * @param function - The callback function
    +   * @param arg - Argument to pass to pass to the function
    +   */
    +  private class Callback(val function: Any => Unit, val arg: Any)
    --- End diff --
    
    I don't know, this type feels weird to me. It feels like the the closure 
itself should encapsulate any local data it needs, and any arguments here 
should only be the ones that the caller of the callback is passing.
    
    e.g.:
    * if BlockGenerator does not pass any arguments to the callback, the 
callback signature should be "() => Unit"
    * if it passes a String, the signature should be "String => Unit"
    
    In the call site, if the closure needs other data, that data can exist 
locally and doesn't need to be known by this code, something along the lines of:
    
        val somethingLocal = "foo"
        bm.store(i, () => { println(somethingLocal) })



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