資源簡介
1、功能描述
用戶的手機,連接到不同的基站會產生一條記錄。
數據格式為:用戶標識 設備標識 基站位置 通訊的日期 通訊時間
example: 0000009999 0054785806 00000089 2016-02-21 21:55:37
需要得到的數據格式為:
用戶標識 時段 基站位置 停留時間
example: 0000000001 09-18 00000003 15
用戶0000000001在09-18點這個時間段在基站00000003停留了15分鐘
用戶的手機,連接到不同的基站會產生一條記錄。
數據格式為:用戶標識 設備標識 基站位置 通訊的日期 通訊時間
example: 0000009999 0054785806 00000089 2016-02-21 21:55:37
需要得到的數據格式為:
用戶標識 時段 基站位置 停留時間
example: 0000000001 09-18 00000003 15
用戶0000000001在09-18點這個時間段在基站00000003停留了15分鐘

代碼片段和文件信息
package?phoneMapReduce;
import?org.apache.hadoop.conf.Configuration;
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.FileInputFormat;
import?org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import?java.io.IOException;
/**
?*?Created?by?ue50?on?11/13/19.
?*/
public?class?PhoneMain
{
????public?static?void?main(String[]?args)?throws?InterruptedException?IOException?ClassNotFoundException
????{
????????//String.equals()比較字符串的值是否相同
????????if(args?==?null?||?“0“.equals(args[0]))
????????{
????????????throw?new?RuntimeException(“argument?is?not?right!“);
????????}
????????//Configuration是作業的配置信息類
????????Configuration?configuration?=?new?Configuration();
????????//set(String?name?String?value)設置配置項
????????configuration.set(“timeRange“?args[0]);
????????Job?job?=?Job.getInstance(configuration);
????????job.setJarByClass(PhoneMain.class);
????????job.setMapperClass(PhoneMapper.class);
????????job.setMapOutputKeyClass(Text.class);
????????job.setMapOutputKeyClass(Text.class);
????????job.setReducerClass(PhoneReducer.class);
????????job.setOutputKeyClass(Text.class);
????????job.setOutputValueClass(Text.class);
????????//FileInputFormat.setInputPaths(job?new?Path(“hdfs://xdata-m0:8020/user/ue50/pos.txt“));
????????//FileOutputFormat.setOutputPath(job?new?Path(“hdfs://xdata-m0:8020/user/ue50/out“));
????????FileInputFormat.setInputPaths(job?new?Path(args[1]));
????????FileOutputFormat.setOutputPath(job?new?Path(args[2]));
????????job.waitForCompletion(true);
????}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????1664??2019-11-14?16:03??exam3\PhoneMain.java
?????文件????????2711??2019-11-14?16:03??exam3\PhoneMapper.java
?????文件????????3806??2019-11-14?16:35??exam3\PhoneReducer.java
?????文件????????3669??2019-11-14?16:03??exam3\pom.xm
?????文件?????1168660??2019-11-14?16:03??exam3\pos.txt
?????文件???????59652??2019-11-14?16:03??exam3\實踐三運營商用戶基站停留數據統計.docx
?????目錄???????????0??2019-11-30?23:19??exam3\
- 上一篇:帶約束處理的粒子群算法,簡明清晰
- 下一篇:復制粘貼工具
評論
共有 條評論