def get_spark_context(conf=None):
    """
    Get the current active spark context and create one if no active instance
    :param conf: combining bigdl configs into spark conf
    :return: SparkContext
    """
    if hasattr(SparkContext, "getOrCreate"):
        with SparkContext._lock:
            if SparkContext._active_spark_context is None:
                spark_conf = create_spark_conf() if conf is None else conf
                return SparkContext.getOrCreate(spark_conf)
            else:
                return SparkContext.getOrCreate()

    else:
        # Might have threading issue but we cann't add _lock here
        # as it's not RLock in spark1.5;
        if SparkContext._active_spark_context is None:
            spark_conf = create_spark_conf() if conf is None else conf
            return SparkContext(conf=spark_conf)
        else:
            return SparkContext._active_spark_context
def get_spark_context(conf=None):
    """
    Get the current active spark context and create one if no active instance
    :param conf: combining bigdl configs into spark conf
    :return: SparkContext
    """
    if hasattr(SparkContext, "getOrCreate"):
        with SparkContext._lock:
            if SparkContext._active_spark_context is None:
                spark_conf = create_spark_conf() if conf is None else conf
                return SparkContext.getOrCreate(spark_conf)
            else:
                return SparkContext.getOrCreate()

    else:
        # Might have threading issue but we cann't add _lock here
        # as it's not RLock in spark1.5;
        if SparkContext._active_spark_context is None:
            spark_conf = create_spark_conf() if conf is None else conf
            return SparkContext(conf=spark_conf)
        else:
            return SparkContext._active_spark_context
def get_spark_context ( conf = None ) : if hasattr ( SparkContext , "getOrCreate" ) : with SparkContext . _lock : if SparkContext . _active_spark_context is None : spark_conf = create_spark_conf ( ) if conf is None else conf return SparkContext . getOrCreate ( spark_conf ) else : return SparkContext . getOrCreate ( ) else : # Might have threading issue but we cann't add _lock here # as it's not RLock in spark1.5; if SparkContext . _active_spark_context is None : spark_conf = create_spark_conf ( ) if conf is None else conf return SparkContext ( conf = spark_conf ) else : return SparkContext . _active_spark_context
Get the current active spark context and create one if no active instance
    :param conf: combining bigdl configs into spark conf
    :return: SparkContext
Get the current active spark context and create one if no active instance : param conf : combining bigdl configs into spark conf : return : SparkContext