请帮我编写一个用于火花流工作的insertmongo函数。 这是一个字数统计程序
import pymongo_spark
........
counts = lines.flatMap(lambda line: line.split(" ")).map(lambda word: (word,1)).reduceByKey(lambda a, b: a+b)
counts = counts.map(lambda x:"word":x[0],"count":int(x[1]),"ts":str(uuid1())})
def insertMongo(time,rdd):
rdd.saveToMongoDB('mongodb://localhost:27017/telematics.test')
counts.foreachRDD(insertMongo)