- 新增 hbase-20250509 模块用于 HBase 课程项目 - 实现了流量统计和词频统计两个 MapReduce 任务 - 添加了相应的 Mapper、Reducer 和 Driver 类- 创建了输入样例文件- 配置了 Maven 依赖
36 lines
1.2 KiB
Java
36 lines
1.2 KiB
Java
package FlowCount2;
|
|
|
|
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;
|
|
|
|
public class FlowCountDriver {
|
|
public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
|
|
Configuration conf = new Configuration();
|
|
|
|
Job job = Job.getInstance(conf, "FlowBean");
|
|
|
|
job.setMapperClass(FlowCountMapper.class);
|
|
job.setReducerClass(FlowCountReducer.class);
|
|
|
|
job.setMapOutputKeyClass(Text.class);
|
|
job.setMapOutputValueClass(FlowBean.class);
|
|
job.setOutputKeyClass(Text.class);
|
|
job.setOutputValueClass(FlowBean.class);
|
|
|
|
job.setNumReduceTasks(1);
|
|
|
|
FileInputFormat.setInputPaths(job, new Path("hbase-lesson/hbase-20250509/src/main/java/FlowCount2/input/"));
|
|
FileOutputFormat.setOutputPath(job, new Path("hbase-lesson/hbase-20250509/src/main/java/FlowCount2/output/"));
|
|
|
|
job.waitForCompletion(true);
|
|
|
|
|
|
}
|
|
}
|