@@ -1857,23 +1857,31 @@ object SparkContext extends Logging {
18571857 }
18581858
18591859 /**
1860- * Because we can only have one active Spark Context per JVM and there are times when multiple
1861- * applications may wish to share a SparkContext, this function may be used to get or instantiate
1862- * a SparkContext and register it as a singleton object.
1860+ * This function may be used to get or instantiate a SparkContext and register it as a
1861+ * singleton object. Because we can only have one active SparkContext per JVM,
1862+ * this is useful when applications may wish to share a SparkContext.
18631863 *
1864- * Note: This function cannot be used to create multiple spark contexts even if multiple contexts
1865- * are allowed. Multiple contexts will still need to be created with explicit calls to the
1866- * SparkContext constructor.
1864+ * Note: This function cannot be used to create multiple SparkContexts even if multiple contexts
1865+ * are allowed.
18671866 */
18681867 def getOrCreate (config : SparkConf ): SparkContext = {
1869- if (activeContext.get() ! = null ) {
1868+ if (activeContext.get() = = null ) {
18701869 setActiveContext(new SparkContext (config),
18711870 config.getBoolean(" spark.driver.allowMultipleContexts" , false ))
18721871 }
18731872 activeContext.get()
18741873 }
18751874
1876- /** Allow not passing a SparkConf (useful if just retrieving) */
1875+ /**
1876+ * This function may be used to get or instantiate a SparkContext and register it as a
1877+ * singleton object. Because we can only have one active SparkContext per JVM,
1878+ * this is useful when applications may wish to share a SparkContext.
1879+ *
1880+ * This method allows not passing a SparkConf (useful if just retrieving)
1881+ *
1882+ * Note: This function cannot be used to create multiple SparkContexts even if multiple contexts
1883+ * are allowed.
1884+ */
18771885 def getOrCreate (): SparkContext = {
18781886 getOrCreate(new SparkConf ())
18791887 }
0 commit comments