计算出10月1日这天每小时的载客量

CarMapper:

package com.hadoop.map;import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;import java.io.IOException;public class CarMapper extends Mapper<LongWritable, Text,Text,Text> {@Overrideprotected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {if (value!=null&&value.toString().length()>0){String[] split = value.toString().split(",");String time=split[3];if (time.substring(4,6).equals("10")&&time.substring(6,8).equals("01")){//key是车牌号+每小时context.write(new Text(time.substring(8,10)),value);}}}
}

CarReduce:

package com.hadoop.reduce;import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;public class CarReduce extends Reducer<Text,Text,Text,Text> {@Overrideprotected void reduce(Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException {/*** 载客量*/int CarryingCapacity=0;HashMap<String, ArrayList<String>> map = new HashMap<>();ArrayList<String> list = new ArrayList<>();for (Text value : values) {String[] split = value.toString().split(",");if (split[2].equals("1")){CarryingCapacity++;}}context.write(key,new Text(CarryingCapacity+""));}
}

CarDriver:

package com.hadoop.driver;import com.hadoop.map.CarMapper;
import com.hadoop.reduce.CarReduce;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;public class CarDriver extends Configured implements Tool {@Overridepublic int run(String[] args) throws Exception {Configuration configuration = new Configuration();Job JB = Job.getInstance(configuration, "CarDriver");FileSystem fileSystem = FileSystem.get(configuration);JB.setInputFormatClass(TextInputFormat.class);TextInputFormat.addInputPath(JB,new Path("E:\\出租车数据\\2012001"));JB.setMapperClass(CarMapper.class);JB.setMapOutputKeyClass(Text.class);JB.setMapOutputValueClass(Text.class);JB.setReducerClass(CarReduce.class);JB.setOutputKeyClass(Text.class);JB.setOutputValueClass(Text.class);boolean exists = fileSystem.exists(new Path("E:\\出租车数据\\Out"));if (exists){fileSystem.delete(new Path("E:\\出租车数据\\Out"),true);}JB.setOutputFormatClass(TextOutputFormat.class);TextOutputFormat.setOutputPath(JB,new Path("E:\\出租车数据\\Out"));return JB.waitForCompletion(true)?0:1;}public static void main(String[] args) throws Exception {ToolRunner.run(new CarDriver(),args);}
}

计算出10月1日这天超速(超过120)的车辆,超速的次数,超速的详细时间

CarMapper:

package com.hadoop.Car1;import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;import java.io.IOException;public class CarMapper extends Mapper<LongWritable, Text,Text,Text> {@Overrideprotected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {if (value!=null&&value.toString().length()>0){String[] split = value.toString().split(",");if (Integer.parseInt(split[6])>120){context.write(new Text(split[0]),value);}}}
}

CarReduce:

package com.hadoop.Car1;import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;import java.io.IOException;public class CarReduce extends Reducer<Text,Text,Text,Text> {@Overrideprotected void reduce(Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException {StringBuffer sb =new StringBuffer();int count=0;for (Text value : values) {count++;String s = value.toString().split(",")[3];sb.append(s).append("-");}context.write(key,new Text("超速的次数:"+count+"超速的时间---->"+sb));}
}

CarDriver:

package com.hadoop.Car1;import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;public class CarDriver extends Configured implements Tool {@Overridepublic int run(String[] args) throws Exception {Configuration configuration = new Configuration();Job JB = Job.getInstance(configuration, "CarDriver");FileSystem fileSystem = FileSystem.get(configuration);JB.setInputFormatClass(TextInputFormat.class);TextInputFormat.addInputPath(JB,new Path("E:\\出租车数据\\2012001"));JB.setMapperClass(CarMapper.class);JB.setMapOutputKeyClass(Text.class);JB.setMapOutputValueClass(Text.class);JB.setReducerClass(CarReduce.class);JB.setOutputKeyClass(Text.class);JB.setOutputValueClass(Text.class);boolean exists = fileSystem.exists(new Path("E:\\出租车数据\\Out"));if (exists){fileSystem.delete(new Path("E:\\出租车数据\\Out"),true);}JB.setOutputFormatClass(TextOutputFormat.class);TextOutputFormat.setOutputPath(JB,new Path("E:\\出租车数据\\Out"));return JB.waitForCompletion(true)?0:1;}public static void main(String[] args) throws Exception {ToolRunner.run(new CarDriver(),args);}
}

计算出10月1日这天全天停运的车辆

CarMapper:

package com.hadoop.Car2;import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;import java.io.IOException;public class CarMapper extends Mapper<LongWritable, Text,Text,Text> {@Overrideprotected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {if (value!=null&&value.toString().length()>0){String[] split = value.toString().split(",");if (split[3].substring(4,6).equals("10")&&split[3].substring(6,8).equals("01")){context.write(new Text(""),value);}}}
}

CarReduce:

package com.hadoop.Car2;import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;import java.io.IOException;public class CarReduce extends Reducer<Text,Text,Text,Text> {@Overrideprotected void reduce(Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException {int count=0;for (Text value : values) {String[] split = value.toString().split(",");if (split[2].equals("3")||split[2]=="3"){count++;}}context.write(new Text(""),new Text("这天全天停运的车辆为:"+count+"辆"));}
}

CarDriver:

package com.hadoop.Car2;import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;public class CarDriver extends Configured implements Tool {@Overridepublic int run(String[] args) throws Exception {Configuration configuration = new Configuration();Job JB = Job.getInstance(configuration, "CarDriver");FileSystem fileSystem = FileSystem.get(configuration);JB.setInputFormatClass(TextInputFormat.class);TextInputFormat.addInputPath(JB,new Path("E:\\出租车数据\\2012001"));JB.setMapperClass(CarMapper.class);JB.setMapOutputKeyClass(Text.class);JB.setMapOutputValueClass(Text.class);JB.setReducerClass(CarReduce.class);JB.setOutputKeyClass(Text.class);JB.setOutputValueClass(Text.class);boolean exists = fileSystem.exists(new Path("E:\\出租车数据\\Out"));if (exists){fileSystem.delete(new Path("E:\\出租车数据\\Out"),true);}JB.setOutputFormatClass(TextOutputFormat.class);TextOutputFormat.setOutputPath(JB,new Path("E:\\出租车数据\\Out"));return JB.waitForCompletion(true)?0:1;}public static void main(String[] args) throws Exception {ToolRunner.run(new CarDriver(),args);}
}

计算出10月1日这天载客次数超过10次的车辆,载客总次数,载客详细时间。

CarMapper:

package com.hadoop.Car3;import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;import java.io.IOException;public class CarMapper extends Mapper<LongWritable, Text,Text,Text> {@Overrideprotected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {if (value!=null&&value.toString().length()>0){String[] split = value.toString().split(",");if (split[3].substring(4,6).equals("10")&&split[3].substring(6,8).equals("01")){context.write(new Text(split[0]),value);}}}
}

CarReduce:

package com.hadoop.Car3;import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;import java.io.IOException;public class CarReduce extends Reducer<Text,Text,Text,Text> {@Overrideprotected void reduce(Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException {int count=0;StringBuffer sb = new StringBuffer();for (Text value : values) {String[] split = value.toString().split(",");if (split[2].equals("1")||split[2]=="1"){count++;String s=split[3];sb.append(s).append("_");}}if (count>10){context.write(new Text(key),new Text("载客总次数:"+count+"------>载客详细时间:"+sb));}}
}

CarDriver:

package com.hadoop.Car3;import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;public class CarDriver extends Configured implements Tool {@Overridepublic int run(String[] args) throws Exception {Configuration configuration = new Configuration();Job JB = Job.getInstance(configuration, "CarDriver");FileSystem fileSystem = FileSystem.get(configuration);JB.setInputFormatClass(TextInputFormat.class);TextInputFormat.addInputPath(JB,new Path("E:\\出租车数据\\2012001"));JB.setMapperClass(CarMapper.class);JB.setMapOutputKeyClass(Text.class);JB.setMapOutputValueClass(Text.class);JB.setReducerClass(CarReduce.class);JB.setOutputKeyClass(Text.class);JB.setOutputValueClass(Text.class);boolean exists = fileSystem.exists(new Path("E:\\出租车数据\\Out"));if (exists){fileSystem.delete(new Path("E:\\出租车数据\\Out"),true);}JB.setOutputFormatClass(TextOutputFormat.class);TextOutputFormat.setOutputPath(JB,new Path("E:\\出租车数据\\Out"));return JB.waitForCompletion(true)?0:1;}public static void main(String[] args) throws Exception {ToolRunner.run(new CarDriver(),args);}
}

计算出10月1日这天连续与运行12小时一以上的车辆

CarMapper:

package com.hadoop.Car4;import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;import java.io.IOException;public class CarMapper extends Mapper<LongWritable, Text,Text,Text> {@Overrideprotected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {if (value!=null&&value.toString().length()>0){String[] split = value.toString().split(",");if (split[3].substring(4,6).equals("10")&&split[3].substring(6,8).equals("01")){context.write(new Text(split[0]),value);}}}
}

CarReduce:

package com.hadoop.Car4;import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;import java.io.IOException;
import java.util.HashSet;public class CarReduce extends Reducer<Text,Text,Text,Text> {@Overrideprotected void reduce(Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException {StringBuffer sb = new StringBuffer();//        ArrayList<Text> list = new ArrayList<>();// [01 01  02  01 03 05 06 ]HashSet<Integer> list12 = new HashSet<>();for (Text value : values) {String[] split = value.toString().split(",");
//            list.add(new Text(split[3].substring(8,10)));for (int i = 0; i < 24; i++) {if (Integer.parseInt(split[3].substring(8,10))==i){list12.add(Integer.parseInt(split[3].substring(8,10)));}}}for (int i = 0; i < 24; i++) {if (list12.contains(i)){sb.append("1");}else{sb.append("0");}}if (sb.toString().contains("111111111111")) {context.write(key,new Text("----->此车运行了12以上"));}}
}

CarDriver:

package com.hadoop.Car4;import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;public class CarDriver extends Configured implements Tool {@Overridepublic int run(String[] args) throws Exception {Configuration configuration = new Configuration();Job JB = Job.getInstance(configuration, "CarDriver");FileSystem fileSystem = FileSystem.get(configuration);JB.setInputFormatClass(TextInputFormat.class);TextInputFormat.addInputPath(JB,new Path("E:\\出租车数据\\2012001"));JB.setMapperClass(CarMapper.class);JB.setMapOutputKeyClass(Text.class);JB.setMapOutputValueClass(Text.class);JB.setReducerClass(CarReduce.class);JB.setOutputKeyClass(Text.class);JB.setOutputValueClass(Text.class);boolean exists = fileSystem.exists(new Path("E:\\出租车数据\\Out"));if (exists){fileSystem.delete(new Path("E:\\出租车数据\\Out"),true);}JB.setOutputFormatClass(TextOutputFormat.class);TextOutputFormat.setOutputPath(JB,new Path("E:\\出租车数据\\Out"));return JB.waitForCompletion(true)?0:1;}public static void main(String[] args) throws Exception {ToolRunner.run(new CarDriver(),args);}
}

计算出10月1日载客次数大于10月2日载客次数的车辆

CarMapper:

package com.hadoop.Car5;import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.lib.input.FileSplit;import java.io.IOException;public class CarMapper extends Mapper<LongWritable, Text,Text,Text> {@Overrideprotected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {FileSplit sp = (FileSplit) context.getInputSplit();String name = sp.getPath().getName();if (name.contains("20121001")){if (value!=null&&value.toString().length()>0){String[] split = value.toString().split(",");context.write(new Text(split[0]),value);}}else {if (value!=null&&value.toString().length()>0){String[] split = value.toString().split(",");context.write(new Text(split[0]),value);}}}
}

CarReduce:

package com.hadoop.Car5;import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;import java.io.IOException;public class CarReduce extends Reducer<Text,Text,Text,Text> {@Overrideprotected void reduce(Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException {int  One=0;int Two=0;for (Text value : values) {if (value.toString().contains("20121001")){String[] split = value.toString().split(",");if (split[1].equals("4")&&split[2].equals("1")){One++;}}else{String[] split = value.toString().split(",");if (split[1].equals("4")&&split[2].equals("1")) {Two++;}}}if (One>Two){context.write(key,new Text("十月一日载客量:"+One+"----大于---"+"十月二日载客量:"+Two));}}
}

CarDriver:

package com.hadoop.Car5;import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;public class CarDriver extends Configured implements Tool {@Overridepublic int run(String[] args) throws Exception {Configuration configuration = new Configuration();Job JB = Job.getInstance(configuration, "CarDriver");FileSystem fileSystem = FileSystem.get(configuration);JB.setInputFormatClass(TextInputFormat.class);TextInputFormat.addInputPath(JB,new Path("E:\\出租车数据\\201210011002"));JB.setMapperClass(CarMapper.class);JB.setMapOutputKeyClass(Text.class);JB.setMapOutputValueClass(Text.class);JB.setReducerClass(CarReduce.class);JB.setOutputKeyClass(Text.class);JB.setOutputValueClass(Text.class);boolean exists = fileSystem.exists(new Path("E:\\出租车数据\\Out"));if (exists){fileSystem.delete(new Path("E:\\出租车数据\\Out"),true);}JB.setOutputFormatClass(TextOutputFormat.class);TextOutputFormat.setOutputPath(JB,new Path("E:\\出租车数据\\Out"));return JB.waitForCompletion(true)?0:1;}public static void main(String[] args) throws Exception {ToolRunner.run(new CarDriver(),args);}
}

计算出10月1日上班10月2日没有上班的车辆

CarMapper:

package com.hadoop.Car6;import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.lib.input.FileSplit;import java.io.IOException;public class CarMapper extends Mapper<LongWritable, Text,Text,Text> {@Overrideprotected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {FileSplit sp = (FileSplit) context.getInputSplit();String name = sp.getPath().getName();if (name.contains("20121001")){if (value!=null&&value.toString().length()>0){String[] split = value.toString().split(",");context.write(new Text(split[0]),value);}}else {if (value!=null&&value.toString().length()>0){String[] split = value.toString().split(",");context.write(new Text(split[0]),value);}}}
}

CarReduce:

package com.hadoop.Car6;import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;import java.io.IOException;public class CarReduce extends Reducer<Text,Text,Text,Text> {@Overrideprotected void reduce(Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException {boolean falg1=true;//当falg1为false的时候就证明10月1日没有上班boolean falg2=true;//当falg1为false的时候就证明10月2日没有上班for (Text value : values) {if (value.toString().contains("20121001")){String[] split = value.toString().split(",");if (split[2].equals("3")){falg1=false;}}else{String[] split = value.toString().split(",");if (split[2].equals("3")) {falg2=false;}}}if (falg1==true&&falg2==false){context.write(key,new Text("十月一日:"+falg1+"-----"+"十月二日:"+falg2));}}
}

CarDriver:

package com.hadoop.Car6;import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;public class CarDriver extends Configured implements Tool {@Overridepublic int run(String[] args) throws Exception {Configuration configuration = new Configuration();Job JB = Job.getInstance(configuration, "CarDriver");FileSystem fileSystem = FileSystem.get(configuration);JB.setInputFormatClass(TextInputFormat.class);TextInputFormat.addInputPath(JB,new Path("E:\\出租车数据\\201210011002"));JB.setMapperClass(CarMapper.class);JB.setMapOutputKeyClass(Text.class);JB.setMapOutputValueClass(Text.class);JB.setReducerClass(CarReduce.class);JB.setOutputKeyClass(Text.class);JB.setOutputValueClass(Text.class);boolean exists = fileSystem.exists(new Path("E:\\出租车数据\\Out"));if (exists){fileSystem.delete(new Path("E:\\出租车数据\\Out"),true);}JB.setOutputFormatClass(TextOutputFormat.class);TextOutputFormat.setOutputPath(JB,new Path("E:\\出租车数据\\Out"));return JB.waitForCompletion(true)?0:1;}public static void main(String[] args) throws Exception {ToolRunner.run(new CarDriver(),args);}
}

计算出连续48小时运营的车辆

CarMapper:

package com.hadoop.Taxi08;import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.lib.input.FileSplit;import java.io.IOException;public class TaxiMap08  extends Mapper<LongWritable,Text,Text,Text> {@Overrideprotected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {FileSplit fileSplit = (FileSplit) context.getInputSplit();String name = fileSplit.getPath().getName();if (name.contains("20121001")){if (value.toString().length()>0){String[] split = value.toString().split(",");context.write(new Text(split[0]), value);}}else{if (value.toString().length()>0){String[] split = value.toString().split(",");context.write(new Text(split[0]), value);}}}
}

CarReduce:

package com.hadoop.Taxi08;import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;import java.io.IOException;
import java.util.HashSet;public class TaxiReduce08 extends Reducer<Text,Text,Text,Text> {@Overrideprotected void reduce(Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException {HashSet<Integer> One = new HashSet<>();HashSet<Integer> Two = new HashSet<>();StringBuffer sbOne = new StringBuffer();StringBuffer sbTwo = new StringBuffer();for (Text value : values) {if (value.toString().contains("20121001")){String[] split = value.toString().split(",");One.add(Integer.parseInt(split[3].substring(8,10 ))); //key ----> value:01 02 03 04 05 06}else{String[] split = value.toString().split(",");Two.add(Integer.parseInt(split[3].substring(8,10 ))); //key ----> value:01 02 03 04 05 06}}for (int i = 0; i < 24; i++) {if (One.contains(i)){sbOne.append("1");}else{sbOne.append("0");}if (Two.contains(i)){sbTwo.append("1");}else{sbTwo.append("0");}}if (!sbOne.toString().contains("0")&&!sbTwo.toString().contains("0")){context.write(key, new Text(sbOne+"---------"+sbTwo+"---------"+"此车连续运行48小时"));}}
}

CarDriver:

package com.hadoop.Taxi08;import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;public class TaxiDriver08 extends Configured implements Tool {@Overridepublic int run(String[] args) throws Exception {Configuration configuration = new Configuration();Job job=Job.getInstance(configuration, "TaxiDriver08");job.setJarByClass(TaxiDriver08.class);job.setInputFormatClass(TextInputFormat.class);TextInputFormat.addInputPath(job, new Path("D:\\出租车数据\\ALLtxt"));job.setMapperClass(TaxiMap08.class);job.setMapOutputKeyClass(Text.class);job.setMapOutputValueClass(Text.class);job.setReducerClass(TaxiReduce08.class);job.setOutputKeyClass(Text.class);job.setOutputValueClass(Text.class);job.setOutputFormatClass(TextOutputFormat.class);TextOutputFormat.setOutputPath(job, new Path("data/08_output"));return job.waitForCompletion(true)?0:1;}public static void main(String[] args) throws Exception {int run = ToolRunner.run(new TaxiDriver08(), args);System.out.println(run);}
}

GPS数据格式说明

数据格式
数据以ASCII文本表示,以逗号为分隔符,以回车换行符(0x0D 0x0A)结尾。

数据项及顺序:

车机标识,触发事件,运营状态,GPS时间,GPS经度,GPS纬度,GPS速度,GPS方向,GPS状态

车机标识:6个字符
触发事件:0=变空车,1=变载客,2=设防,3=撤防,4=其它
运营状态:0=空车,1=载客,2=驻车,3=停运,4=其它
GPS时间:格式yyyymmddhhnnss,北京时间
GPS经度:格式ddd.ddddddd,以度为单位。
GPS纬度:格式dd.ddddddd,以度为单位。
GPS速度:格式ddd,取值000-255内整数,以公里/小时为单位。
GPS方位:格式ddd,取值000-360内整数,以度为单位。
GPS状态:0=无效,1=有效
结束串:回车符+换行符

数据示例:
123456,0,0,20110414160613,116.4078674,40.2220650,21,274,1<0x0D0x0A>

数据发送方式:
每次200条以上的数据压缩打包后UDP发送。采用ZLIB125压缩库最大压缩率压缩。
接收应答:每接收1包或多包回复1个4字节整数,这个整数可以是收到的包数累计或字节数累计,该回复仅用于判断链路是否正常,不用于重发判断。

MapReduce:出租车数据案例相关推荐

  1. 第二篇:智能电网(Smart Grid)中的数据工程与大数据案例分析

    前言 上篇文章中讲到,在智能电网的控制与管理侧中,数据的分析和挖掘.可视化等工作属于核心环节.除此之外,二次侧中需要对数据进行采集,数据共享平台的搭建显然也涉及到数据的管理.那么在智能电网领域中,数据 ...

  2. MapReduce的序列化案例

    MapReduce的序列化案例 需求 文件内容 案例分析 1. 需求: 2. 输入数据格式 3. 期望输出格式 4. Map阶段 5. Reduce阶段 编码实现 1. 编写流量统计的Bean对象 2 ...

  3. 解析postgresql 删除重复数据案例

    这篇文章主要介绍了postgresql 删除重复数据案例详解,本篇文章通过简要的案例,讲解了该项技术的了解与使用,以下就是详细内容,需要的朋友可以参考下 1.建表 /*Navicat Premium ...

  4. MapReduce的数据去重功能

    实验材料及说明 现有某电商网站用户对商品的收藏数据,记录了用户收藏的商品id以及收藏日期,文件名为buyer_favorite.buyer_favorite包含:买家id,商品id,收藏日期这三个字段 ...

  5. java 获取nodejs端Gson数据案例(请求MongoDB)

    java  获取nodejs端Gson数据案例 原理:这是一个demo,主要通过java向nodejs端发送请求,nodejs端向mongodb请求数据,并将请求的数据以Gson的格式返回给java端 ...

  6. 通过日志恢复MS SQL数据案例

     [导读]本文介绍通过日志恢复MS SQL数据案例,以数据库的故障恢复改为非简单模式,去掉自动关闭和自动收缩两个选项为前提. 前提条件是数据库的故障恢复改为非简单模式,去掉自动关闭和自动收缩两个选项. ...

  7. 连线IBM大数据案例 让大数据接地气

    文章讲的是连线IBM大数据案例 让大数据接地气,6月16日,对于世贸天阶来说可以说是大数据的一天,IBM连线大数据与分析活动在此举行.在这聚集时尚前沿的阵地上,IBM再次与我们公话"大数据& ...

  8. 荣登2019中国“十佳大数据案例”,腾讯大数据再获国家认可

    5月26日,由工业和信息化部.国家发展和改革委员会.国家互联网信息办公室和贵州省人民政府主办,国家工业信息安全发展研究中心承办的<大数据优秀产品和应用解决方案案例系列丛书>发布会暨数博会& ...

  9. 数据分析与挖掘建模实战003:单因子探索分析与可视化001数据案例介绍

    数据案例 代码 import pandas as pd df = pd.read_csv('HR.csv') df.head(10) 后面将使用到的数据的情况

  10. 出租车数据的地图展示

    出租车数据的地图展示 实现方法 python数据预处理后将数据导入地图代码. 效果 数据预处理: f1['dropoff_longitude'].fillna(value=f1['dropoff_lo ...

最新文章

  1. Serverless 微服务实践-移动应用包分发服务
  2. Tomcat配置优化
  3. 为什么 SQL 正在击败 NoSQL,这对未来的数据意味着什么?
  4. 给大家提炼几个产品经理的核心点
  5. python同时输出多个值_怎样在python中输出多个数组元素?
  6. mysqlreport的学习
  7. InvalidCharacterError: Failed to execute 'setAttribute' on 'Element': ')' is not a valid
  8. Lua 之table的测试
  9. 简单描述HTML相对路径与绝对路径(转)
  10. How to study Watir?
  11. 微信小程序入门指南——程序员计算器设计(一)
  12. 当年的好记星、诺亚舟都去哪了?
  13. 用java求梯形面积
  14. 【图像隐藏】基于matlab像素预测和位平面压缩的加密图像可逆数据隐藏【含Matlab源码 2218期】
  15. 精选优美英文短文1——Dear Basketball(亲爱的篮球)
  16. 1.22-1.23板卡调试日志
  17. python爬取王者荣耀皮肤高清图
  18. 百度大脑EasyDL多人标注重磅上线啦
  19. 【计算机视觉】:(3)全景图像拼接
  20. Python爬虫爬取笔趣阁小说

热门文章

  1. python学习笔记(3)---cookie session
  2. 业务逻辑配置化的可选技术方案
  3. Power Spectral Density
  4. bzoj1076 奖励关(概率dp)(状态压缩)
  5. c++ 随机数相关的一些函数
  6. 深度学习图像分类(十二):MobileNet系列(V1,V1,V3)
  7. java reflector_Java DefaultReflectorFactory类代码示例
  8. springcloud架构特点_董事长挖来一位京东T9架构师,送我们两份微服务文档,实在太香了...
  9. MFC使用ADO对象开发数据库应用程序
  10. gstream初次尝试