Class SparkContextUtil


  • public final class SparkContextUtil
    extends Object
    A SparkContextUtil is a utility class for adding and retrieving a SparkSession to/from the user Context.
    • Method Detail

      • addSparkSession

        public static void addSparkSession​(Context context,
                                           StoreProperties storeProperties)
        Adds a spark session to the given Context.
        Parameters:
        context - the user context
        storeProperties - the store properties - used to create a spark session
      • addSparkSession

        public static void addSparkSession​(Context context,
                                           org.apache.spark.sql.SparkSession sparkSession)
        Adds a spark session to the given Context.
        Parameters:
        context - the user context
        sparkSession - the spark session to add to the context
      • createContext

        public static Context createContext​(User user,
                                            StoreProperties storeProperties)
        Create a new Context with the given user and store properties
        Parameters:
        user - the user
        storeProperties - the store properties
        Returns:
        the new Context.
      • createContext

        public static Context createContext​(User user,
                                            org.apache.spark.sql.SparkSession sparkSession)
        Create a new Context with the given user and spark session.
        Parameters:
        user - the user
        sparkSession - the spark session
        Returns:
        the new Context.
      • getSparkSession

        public static org.apache.spark.sql.SparkSession getSparkSession​(Context context,
                                                                        StoreProperties properties)
        Extracts the SparkSession from the Context. If there is no SparkSession in the Context then a new SparkSession instance is created and added to the context.
        Parameters:
        context - the User Context
        properties - the store properties - used to create a spark session if required
        Returns:
        the SparkSession
      • createSparkSession

        public static org.apache.spark.sql.SparkSession createSparkSession​(StoreProperties storeProperties)