mapReducer程序编写过程

/*
    第一步    split    有系统自动切分
    第二步    map        撰写map类extemds Maper 复写Map方法;
    第三步    shuffle        
                Partion        分区,将不同信息区分的分发到不同的Reducer中
                Sort        排序,按照key的不同标准判断顺序
                Group        分组,按照不同的key值判断相同的标准分组到一起
    第四步    Reducer        处理分组数据。输出信息。        

    自定义key值    implements writableComparable<>
    编写Map类
    重写Partion    extends    HashPartitioner<MyKey, DoubleWritable>
                    两个参数分别是自定义key的类型,和值得类型。
                    重写getPartion方法,(要求短小)
    重写sort方法    extends    writableCompare方法,
                //使用父类构造方法加载并创建自定义key类。
                public MySort(){
                    super(MyKey.class,true);
                }
                //重写compare方法,自定义比较标准。(需要将WritableComparable转化为指定类)
                public int compare(WritableComparable a, WritableComparable b)
    重写分组方法    extends    writableCompare方法,
                //使用父类构造方法加载并创建自定义key类。
                public MySort(){
                    super(MyKey.class,true);
                }
                //重写compare方法,自定义比较标准。(需要将WritableComparable转化为指定类)
                public int compare(WritableComparable a, WritableComparable b)
    编写Reduce类,extends Reducer<MyKey, DoubleWritable, Text, NullWritable>
                重写 Reducer方法。输出。
    编写Job类        设置配置参数,创建Job类型,设置相关类。            
    
    
*/

posted on 2016-08-15 23:05  笑明子  阅读(520)  评论(0编辑  收藏  举报

导航