MapReduce之Word Count案例代码实现

本文详细介绍了如何使用MapReduce实现Word Count功能,从准备数据文件到在HDFS上创建目录,再到编写自定义Mapper和Reducer类,最后打包并运行程序,成功输出结果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  • 准备用于计算word count的数据文件
[root@hadoop01 test_data]# pwd
/usr/local/wyh/test_data
[root@hadoop01 test_data]# vi test_word_count.txt
[root@hadoop01 test_data]# cat test_word_count.txt
hello,world
hadoop,world,sqoop
hive,hello,hadoop,mysql
welcome,hadoop
  • 在HDFS上创建目录,并将上述准备的数据文件上传至HDFS
[root@hadoop01 test_data]# hdfs dfs -mkdir /test_word_count
[root@hadoop01 test_data]# hdfs dfs -put test_word_count.txt /test_word_count/
  • 新建project,pom.xml引入依赖
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&#
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

QYHuiiQ

听说打赏的人工资翻倍~

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值