0
我有一個流式應用程序,當我嘗試調用HiveContext.getOrCreate時,它出錯了以下stmt。 「在包蜂巢對象HiveContext不能在包訪問org.apache.spark.sql.hive」HiveContext單身對象
我需要HiveContext代替SQLContext我的應用程序和創建新HiveContext每次不會是一個可行的解決方案。
這裏是我的代碼片段:
object sampleStreamingApp {
def createStreamingContext(checkpointDirectory: String): StreamingContext = {
val conf = new SparkConf().setAppName("sampleStreaming")
val sc = new SparkContext(conf)
val ssc = new StreamingContext(sc, Milliseconds(5000))
ssc.checkpoint(checkpointDirectory)
val smDStream = ssc.textFileStream("/user/hdpuser/data")
val smSplitted = smDStream.map(x => x.split(";")).map(x => Row.fromSeq(x))
smSplitted.foreachRDD { rdd =>
val sqlContext = HiveContext.getOrCreate(rdd.sparkContext)
import sqlContext.implicits._
<other code logic goes here>
}
}
ssc
}
def main(args: Array[String]) {
val checkpointDirectory = "hdfs://localhost:8020/user/dfml/checkpointing/AAA"
val ssc = StreamingContext.getActiveOrCreate(checkpointDirectory,() => createStreamingContext(checkpointDirectory))
ssc.start()
ssc.awaitTermination()
}
}
任何幫助,將不勝感激