Created
October 26, 2018 11:42
-
-
Save AndriiStefaniv/902938c71440c3f25769528e5c730d4f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Processor { | |
def process(oraOptionDfConfig: DataFrameReader, sparkSession: SparkSession): Unit | |
} | |
class BMValsProcessor extends Processor { | |
def process(oraOptionDfConfig: DataFrameReader, sparkSession: SparkSession): Unit = { | |
println("in BMValsProcessor") ///actual business logic | |
} | |
} | |
class BMValsProcessor2 extends Processor { | |
def process(oraOptionDfConfig: DataFrameReader, sparkSession: SparkSession): Unit = { | |
println("in BMValsProcessor2") ///actual business logic | |
} | |
} | |
object ValProcessor { | |
def main(args: Array[String]): Unit = { | |
val df: DataFrameReader = null; // initialization of DataFrameReader | |
val spark: SparkSession = null; // initialization of SparkSession | |
val procs: Map[String, (DataFrameReader, SparkSession) => Unit] = getAllDefinedProcessors() | |
procs.values.foreach( | |
proc => proc(df, spark) | |
) | |
} | |
def getAllDefinedProcessors(): Map[String, (DataFrameReader, SparkSession) => Unit] = { | |
Map( | |
"bm_vals" -> new BMValsProcessor().process, | |
"bm_vals2" -> new BMValsProcessor2().process | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You could try something like