我们都知道一个产品唯一对应一个单价,本案例将通过两种类型输入文件:product类(产品)和price类(价格)进行一对一的关联查询,得到产品名(例如:手表)与产品价格(例如:$100)的关联信息。
开发环境
硬件环境:Centos 6.5 服务器4台(一台为Master节点,三台为Slave节点)
软件环境:Java 1.7.0_45、hadoop-1.2.1
1、 Map过程
首先使用默认的TextInputFormat类对输入文件进行处理,得到文本中每行的偏移量及其内容并存入
2、 Reduce过程
Reduce过程首先对输入
3、 驱动实现
驱动核心代码实现如下,详细源码请参考:ProductJoinPrice\src\com\zonesion\tablejoin\ProductJoinPrice.java。
public static void main(String[] args) throws Exception {
Configuration conf = new Configuration();
String[] otherArgs = new GenericOptionsParser(conf,args).getRemainingArgs();
if(otherArgs.length != 3){
System.err.println("Usage:Join <productTableD