Github user holdenk commented on a diff in the pull request:
https://github.com/apache/spark/pull/9313#discussion_r43350330
--- Diff: python/pyspark/context.py ---
@@ -806,6 +806,24 @@ def addPyFile(self, path):
import importlib
importlib.invalidate_caches()
+ def addJar(self, path):
+ """
+ Adds a JAR dependency for all tasks to be executed on this
SparkContext in the future.
+ The `path` passed can be either a local file, a file in HDFS (or
other Hadoop-supported
+ filesystems), an HTTP, HTTPS or FTP URI, or local:/path for a file
on every worker node.
+ """
+ self._jsc.sc().addJar(path)
+ self._jvm.PythonUtils.updatePrimaryClassLoader(self._jsc)
+
+ def _loadClass(self, className):
+ """
+ .. note:: Experimental
+
+ Loads a JVM class using the MutableClass loader used by spark.
+ This function exists because Py4J uses a different class loader.
+ """
+
self._jvm.java.lang.Thread.currentThread().getContextClassLoader().loadClass(className)
--- End diff --
based on
http://www.javaworld.com/article/2077344/core-java/find-a-way-out-of-the-classloader-maze.html
every thread has a classloader associated with it unless it was created by
native code. This is also the technique @tdas used for getting the class loader
in the python kafka utils. Although this did come up (in
https://issues.apache.org/jira/browse/SPARK-1403 ). I'll fix it here and make a
follow up JIRA to update the kafka utils pyspark to use the common methodlogy.
---
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]