我想提取 username
以及 count
(每个用户执行每个事件的次数)使用javardd类。如何创建javardd对象。
以下是我的数据快照:
{
"_id" : ObjectId("57b3e6d1cab823158a06cafe"),
"app" : {
"clientIp" : "111.0.0.1",
"event" : {
"event_name" : "MAX_SEARCH",
"appId" : 1,
"userName" : "Alex"
}
}
}
预期结果:
Alex MAX_SEARCH 5
我该怎么做?
1条答案
按热度按时间u4dcyp6a1#
假设您在文本文件中有多条记录,如下所示,您希望获得用户名、事件名称和事件计数。
下面的代码片段帮助您从上面的文件中读取数据,从中创建rdd并生成预期的结果。
执行上述代码段后,您将看到以下输出: