result.foreachRDD(rdd => {
rdd.foreachPartition(partitionOfRecords => {
val connection = createConnection()
partitionOfRecords.foreach(record => {
val sql = "insert into wordcount(word, wordcount) values('" + record._1 + "'," + record._2 + ")"
connection.createStatement().execute(sql)
})
connection.close()
})
})
比如说一次输入, a b a a c,然后经过map跟reduce处理出来是(a,3),(b,1),(c,1),那请问老师怎么知道这个就是rdd中的一个partition呢(因为用到rdd.foreachPartition)?如果一次输入很大量的数据,也是这样分区的吗?