新API的旧API

时间:2012-09-25 12:18:26

标签: hadoop mapreduce

My Original Question

因为在This Question 中找到了对该问题的可行回答 答案是旧的API。所以这迫使我把一个愚蠢的问题翻译成新API

private long mapperCounter;

     @Override
     public void configure(JobConf conf) {
               JobClient client = new JobClient(conf);
               RunningJob parentJob = 
               client.getJob(JobID.forName( conf.get("mapred.job.id") ));
               mapperCounter = parentJob.getCounters().getCounter(MAP_COUNTER_NAME);
      }

注意:我希望在reducer中使用此代码,因此可用的继承函数是:

            @Override
    protected void setup(Context context) throws IOException,
            InterruptedException {


    }



    @Override
    protected void cleanup(Context context) throws IOException,
            InterruptedException {

    }



    @Override
    public void run(Context context) throws IOException,
            InterruptedException {
        Job job=new Job(context.getConfiguration());


    }



    @Override
    public void reduce(ImmutableBytesWritable key,Iterable<ImmutableBytesWritable> result,Context context )
    {

    }

谢谢:) :)

1 个答案:

答案 0 :(得分:3)

This演示文稿总结了旧API和新API之间的变化。