我在spark中使用mongo-hadoop客戶端(r1.5.2)從mongoDB和bson中讀取數據,請看以下鏈接:https://github.com/mongodb/mongo-hadoop/wiki/Spark-Usage。到目前爲止,我可以從mongoDB讀取沒有問題。但是,bson配置甚至無法編譯。請幫忙。Spark不能用mongo-hadoop連接器的BSONFileInputFormat編譯newAPIHadoopRDD
我的代碼在斯卡拉:
dataConfig.set("mapred.input.dir", "path.bson")
val documents = sc.newAPIHadoopRDD(
dataConfig,
classOf[BSONFileInputFormat],
classOf[Object],
classOf[BSONObject])
錯誤:
Error:(56, 24) inferred type arguments [Object,org.bson.BSONObject,com.mongodb.hadoop.mapred.BSONFileInputFormat] do not conform to method newAPIHadoopRDD's type parameter bounds [K,V,F <: org.apache.hadoop.mapreduce.InputFormat[K,V]]
val documents = sc.newAPIHadoopRDD(
^
嘗試使用BSONFileInputFormat而不是MongoInputFormat。還請指定您正在使用的mongo-hadoop連接器的版本。 –