Skip to content

Commit 88e7e87

Browse files
committed
[MINOR][PYTHON] Use a helper in PythonUtils instead of direct accessing Scala package
## What changes were proposed in this pull request? This PR proposes to use add a helper in `PythonUtils` instead of direct accessing Scala package. ## How was this patch tested? Jenkins tests. Closes #22483 from HyukjinKwon/minor-refactoring. Authored-by: hyukjinkwon <gurwls223@apache.org> Signed-off-by: hyukjinkwon <gurwls223@apache.org>
1 parent 67f2c6a commit 88e7e87

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

core/src/main/scala/org/apache/spark/api/python/PythonUtils.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,8 @@ private[spark] object PythonUtils {
7474
def toScalaMap[K, V](jm: java.util.Map[K, V]): Map[K, V] = {
7575
jm.asScala.toMap
7676
}
77+
78+
def getEncryptionEnabled(sc: JavaSparkContext): Boolean = {
79+
sc.conf.get(org.apache.spark.internal.config.IO_ENCRYPTION_ENABLED)
80+
}
7781
}

python/pyspark/context.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,7 @@ def _do_init(self, master, appName, sparkHome, pyFiles, environment, batchSize,
192192
# If encryption is enabled, we need to setup a server in the jvm to read broadcast
193193
# data via a socket.
194194
# scala's mangled names w/ $ in them require special treatment.
195-
encryption_conf = self._jvm.org.apache.spark.internal.config.__getattr__("package$")\
196-
.__getattr__("MODULE$").IO_ENCRYPTION_ENABLED()
197-
self._encryption_enabled = self._jsc.sc().conf().get(encryption_conf)
195+
self._encryption_enabled = self._jvm.PythonUtils.getEncryptionEnabled(self._jsc)
198196

199197
self.pythonExec = os.environ.get("PYSPARK_PYTHON", 'python')
200198
self.pythonVer = "%d.%d" % sys.version_info[:2]

0 commit comments

Comments
 (0)