我是新的火花,我想要保存到Hbase表的recommendProductsForUsers的輸出。我發現一個示例(https://sparkkb.wordpress.com/2015/05/04/save-javardd-to-hbase-using-saveasnewapihadoopdataset-spark-api-java-coding/)顯示使用JavaPairRDD和saveAsNewAPIHadoopDataset進行保存。如何保存火花MatrixFactorizationModel recommendedProductsForUsers到Hbase
如何將JavaRDD<Tuple2<Object, Rating[]>>
轉換爲JavaPairRDD<ImmutableBytesWritable, Put>
以便我可以使用saveAsNewAPIHadoopDataset?
//Loads the data from hdfs
MatrixFactorizationModel sameModel = MatrixFactorizationModel.load(jsc.sc(), trainedDataPath);
//Get recommendations for all users
JavaRDD<Tuple2<Object, Rating[]>> ratings3 = sameModel.recommendProductsForUsers(noOfProductsToReturn).toJavaRDD();
您想保存模型或建議嗎? – eliasah
@eliasah我想保存推薦 – Ani