You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/07/31 03:33:59 UTC

[GitHub] [spark] viirya commented on a change in pull request #25262: [SPARK-28486][CORE][PYTHON] Map PythonBroadcast's data file to a BroadcastBlock to avoid delete by GC

viirya commented on a change in pull request #25262: [SPARK-28486][CORE][PYTHON] Map PythonBroadcast's data file to a BroadcastBlock to avoid delete by GC
URL: https://github.com/apache/spark/pull/25262#discussion_r309026377
 
 

 ##########
 File path: core/src/main/scala/org/apache/spark/broadcast/BroadcastManager.scala
 ##########
 @@ -58,8 +59,19 @@ private[spark] class BroadcastManager(
     new ReferenceMap(AbstractReferenceMap.HARD, AbstractReferenceMap.WEAK)
   }
 
+  private def attachBroadcastIdForPython[T: ClassTag](value_ : T, bid: Long): Unit = {
+    try {
+      value_.asInstanceOf[PythonBroadcast].setBroadcastId(bid)
+    } catch {
+      case e: ClassCastException =>
+        // is not a PythonBroadcast
+    }
+  }
+
   def newBroadcast[T: ClassTag](value_ : T, isLocal: Boolean): Broadcast[T] = {
-    broadcastFactory.newBroadcast[T](value_, isLocal, nextBroadcastId.getAndIncrement())
+    val bid = nextBroadcastId.getAndIncrement()
+    attachBroadcastIdForPython(value_, bid)
 
 Review comment:
   attachBroadcastIdForPython is short, maybe just inline?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org