- 阅读权限
- 255
- 威望
- 0 级
- 论坛币
- 50288 个
- 通用积分
- 83.6306
- 学术水平
- 253 点
- 热心指数
- 300 点
- 信用等级
- 208 点
- 经验
- 41518 点
- 帖子
- 3256
- 精华
- 14
- 在线时间
- 766 小时
- 注册时间
- 2006-5-4
- 最后登录
- 2022-11-6
已卖:4194份资源
院士
还不是VIP/贵宾
TA的文库 其他... Bayesian NewOccidental
Spatial Data Analysis
东西方数据挖掘
- 威望
- 0 级
- 论坛币
 - 50288 个
- 通用积分
- 83.6306
- 学术水平
- 253 点
- 热心指数
- 300 点
- 信用等级
- 208 点
- 经验
- 41518 点
- 帖子
- 3256
- 精华
- 14
- 在线时间
- 766 小时
- 注册时间
- 2006-5-4
- 最后登录
- 2022-11-6
|
经管之家送您一份
应届毕业生专属福利!
求职就业群
感谢您参与论坛问题回答
经管之家送您两个论坛币!
+2 论坛币
Python
- text_file = spark.textFile("hdfs://...")
- counts = text_file.flatMap(lambda line: line.split(" ")) \
- .map(lambda word: (word, 1)) \
- .reduceByKey(lambda a, b: a + b)
- counts.saveAsTextFile("hdfs://...")
复制代码Scala
- val textFile = spark.textFile("hdfs://...")
- val counts = textFile.flatMap(line => line.split(" "))
- .map(word => (word, 1))
- .reduceByKey(_ + _)
- counts.saveAsTextFile("hdfs://...")
复制代码Java
- JavaRDD<String> textFile = spark.textFile("hdfs://...");
- JavaRDD<String> words = textFile.flatMap(new FlatMapFunction<String, String>() {
- public Iterable<String> call(String s) { return Arrays.asList(s.split(" ")); }
- });
- JavaPairRDD<String, Integer> pairs = words.mapToPair(new PairFunction<String, String, Integer>() {
- public Tuple2<String, Integer> call(String s) { return new Tuple2<String, Integer>(s, 1); }
- });
- JavaPairRDD<String, Integer> counts = pairs.reduceByKey(new Function2<Integer, Integer, Integer>() {
- public Integer call(Integer a, Integer b) { return a + b; }
- });
- counts.saveAsTextFile("hdfs://...");
复制代码
扫码加我 拉你入群
请注明:姓名-公司-职位
以便审核进群资格,未注明则拒绝
|
|
|