Skip to content

Commit cc3c6cd

Browse files
author
Prabin Banka
committed
Added missing Python APIs
1 parent 181ec50 commit cc3c6cd

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

python/pyspark/context.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,37 @@ def _getJavaStorageLevel(self, storageLevel):
372372
return newStorageLevel(storageLevel.useDisk, storageLevel.useMemory,
373373
storageLevel.deserialized, storageLevel.replication)
374374

375+
def setJobGroup(self, groupId, description):
376+
"""
377+
Assigns a group ID to all the jobs started by this thread until the group ID is set to a
378+
different value or cleared.
379+
380+
Often, a unit of execution in an application consists of multiple Spark actions or jobs.
381+
Application programmers can use this method to group all those jobs together and give a
382+
group description. Once set, the Spark web UI will associate such jobs with this group.
383+
"""
384+
self._jsc.setJobGroup(groupId, description)
385+
386+
def setLocalProperty(self, key, value):
387+
"""
388+
Set a local property that affects jobs submitted from this thread, such as the
389+
Spark fair scheduler pool.
390+
"""
391+
self._jsc.setLocalProperty(key, value)
392+
393+
def getLocalProperty(self, key):
394+
"""
395+
Get a local property set in this thread, or null if it is missing. See
396+
L{setLocalProperty}
397+
"""
398+
return self._jsc.getLocalProperty(key)
399+
400+
def sparkUser(self):
401+
"""
402+
Get SPARK_USER for user who is running SparkContext.
403+
"""
404+
return self._jsc.sc().sparkUser()
405+
375406
def _test():
376407
import atexit
377408
import doctest

python/pyspark/rdd.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,13 @@ def __init__(self, jrdd, ctx, jrdd_deserializer):
9595
self.is_checkpointed = False
9696
self.ctx = ctx
9797
self._jrdd_deserializer = jrdd_deserializer
98+
self._id = jrdd.id()
99+
100+
def id(self):
101+
"""
102+
A unique ID for this RDD (within its SparkContext).
103+
"""
104+
return self._id
98105

99106
def __repr__(self):
100107
return self._jrdd.toString()

0 commit comments

Comments
 (0)