Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
zhztheplayer committed Dec 24, 2024
1 parent 300f92a commit 9329a0c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package org.apache.spark.broadcast

import org.apache.spark.SparkEnv

object BroadcastFactoryInjection {
object BroadcastFactoryUnsafeAccess {
private val FIELD_INITIALIZED = {
val f = classOf[BroadcastManager].getDeclaredField("initialized")
f.setAccessible(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,27 @@ import org.apache.spark.sql.test.SharedSparkSession

import scala.reflect.ClassTag

class BroadcastFactoryInjectionSuite extends SharedSparkSession {
import BroadcastFactoryInjectionSuite._
class BroadcastFactoryUnsafeAccessSuite extends SharedSparkSession {
import BroadcastFactoryUnsafeAccessSuite._
test("Get") {
val factory = BroadcastFactoryInjection.get()
val factory = BroadcastFactoryUnsafeAccess.get()
assert(factory.isInstanceOf[TorrentBroadcastFactory])
}

test("Inject") {
BroadcastFactoryInjection.get().stop()
BroadcastFactoryUnsafeAccess.get().stop()
val factory = new DummyBroadcastFactory()
assert(!factory.initialized)
BroadcastFactoryInjection.inject(factory)
assert(BroadcastFactoryInjection.get() eq factory)
BroadcastFactoryUnsafeAccess.inject(factory)
assert(BroadcastFactoryUnsafeAccess.get() eq factory)
assert(factory.initialized)
val text: String = "DUMMY"
val b = SparkShimLoader.getSparkShims.broadcastInternal(sparkContext, text)
assert(b.isInstanceOf[DummyBroadcast[String]])
}
}

object BroadcastFactoryInjectionSuite {
object BroadcastFactoryUnsafeAccessSuite {
private class DummyBroadcast[T: ClassTag](id: Long, value: T) extends Broadcast[T](id) {
override protected def getValue(): T = value
override protected def doUnpersist(blocking: Boolean): Unit = {
Expand Down

0 comments on commit 9329a0c

Please sign in to comment.