本文介绍了如何解决此错误“未找到:值BMValsProcessor";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在此代码中解决此错误
特征处理器00 {def process(oraOptionDfConfig:DataFrameReader,sparkSession:SparkSession):单位}BMValsProcessor类扩展了处理器{def process(oraOptionDfConfig:DataFrameReader,sparkSession:SparkSession):单位= {println("in BMValsProcessor")///实际业务逻辑}}BMValsProcessor2类扩展了处理器{def process(oraOptionDfConfig:DataFrameReader,sparkSession:SparkSession):单位= {println("in BMValsProcessor2")//实际的业务逻辑}}对象ValProcessor {def main(args:Array [String]):Unit = {val df:DataFrameReader = null;//初始化DataFrameReaderval spark:SparkSession = null;//SparkSession的初始化val procs:Map [String,(DataFrameReader,SparkSession)=>单位] = getAllDefinedProcessors();procs.values.foreach(proc =>proc(df,spark))}def getAllDefinedProcessors():Map [String,(DataFrameReader,SparkSession)=>单位] = {val myFuncs2:Map [String,()=>单位] =地图("bm_vals"->(()=> BMValsProcessor().process),//错误"bm_vals2"->(()=> BMValsProcessor2().process)//错误)myFuncs2;}}
错误是:
解决方案
表达式 BMValsProcessor()
是对象 BMValsProcessor
的调用方法 apply
查看 https://gist.github.com/AndriiStefaniv/902938c71440c3f25769528e5c730d4f >
我试图修复它.
How to fix this error in this code
trait Processor00 {
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] = {
val myFuncs2 : Map[String, () => Unit]=
Map(
"bm_vals" -> (() => BMValsProcessor().process), //Error
"bm_vals2" -> (() => BMValsProcessor2().process) //Error
)
myFuncs2;
}
}
The error is:
解决方案
Expression BMValsProcessor()
is call method apply
of object BMValsProcessor
Look into https://gist.github.com/AndriiStefaniv/902938c71440c3f25769528e5c730d4f
I tried to fix it.
这篇关于如何解决此错误“未找到:值BMValsProcessor";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!