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

    https://github.com/apache/spark/pull/2844#discussion_r19066407
  
    --- Diff: 
core/src/main/scala/org/apache/spark/broadcast/TorrentBroadcast.scala ---
    @@ -179,43 +183,29 @@ private[spark] class TorrentBroadcast[T: ClassTag](
     
     
     private object TorrentBroadcast extends Logging {
    -  /** Size of each block. Default value is 4MB. */
    -  private lazy val BLOCK_SIZE = conf.getInt("spark.broadcast.blockSize", 
4096) * 1024
    -  private var initialized = false
    -  private var conf: SparkConf = null
    -  private var compress: Boolean = false
    -  private var compressionCodec: CompressionCodec = null
    -
    -  def initialize(_isDriver: Boolean, conf: SparkConf) {
    -    TorrentBroadcast.conf = conf // TODO: we might have to fix it in tests
    -    synchronized {
    -      if (!initialized) {
    -        compress = conf.getBoolean("spark.broadcast.compress", true)
    -        compressionCodec = CompressionCodec.createCodec(conf)
    -        initialized = true
    -      }
    -    }
    -  }
     
    -  def stop() {
    -    initialized = false
    -  }
    -
    -  def blockifyObject[T: ClassTag](obj: T): Array[ByteBuffer] = {
    -    val bos = new ByteArrayChunkOutputStream(BLOCK_SIZE)
    -    val out: OutputStream = if (compress) 
compressionCodec.compressedOutputStream(bos) else bos
    -    val ser = SparkEnv.get.serializer.newInstance()
    +  def blockifyObject[T: ClassTag](
    --- End diff --
    
    These two methods, `blockifyObject` and `unBlockifyObject`, now accept all 
of their dependencies directly, which makes it easier to unit-test them.


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