MapReduce处理公共自行车数据

编程入门 行业动态 更新时间:2024-10-04 23:24:19

MapReduce处理公共<a href=https://www.elefans.com/category/jswz/34/1766735.html style=自行车数据"/>

MapReduce处理公共自行车数据

利用Hadoop平台处理公共自行车数据,数据Excel表如下:

Excel表中有一列duration表示自行车使用时间,利用MapReduce统计自行车使用时间为60s,120,180s以此类推的使用量。

代码如下:

Map端:

package com.tyut.rcr;import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;public class Map extends Mapper<LongWritable, Text, Text, IntWritable> {private static final IntWritable one = new IntWritable(1);protected void map(LongWritable key, Text value,org.apache.hadoop.mapreduce.Mapper<LongWritable, Text, Text, IntWritable>.Context context)throws java.io.IOException, InterruptedException {String line = value.toString();String[] datas= line.split(",");String during=datas[0];int dur = Integer.parseInt(during);if(dur<60){String str = "自行车使用时间<60s次数:  "+dur;context.write(new Text(str),one);}else {for(int i=1;i<

更多推荐

MapReduce处理公共自行车数据

本文发布于:2024-02-27 22:22:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1766305.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自行车   数据   MapReduce

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!