concept method in category hadoop
appears as: methods, methods, method, method

This is an excerpt from Manning's book Hadoop in Practice, Second Edition.
Which classes changed to interfaces in Hadoop 2? Some of the notable ones are TaskAttemptContext, JobContext, and MapContext. Table 2.5 shows a selection of some of the methods available in the HadoopCompat class.
Table 2.5. Common classes and methods that are not binary compatible across MapReduce versions
Hadoop class and method
HadoopCompat call
Where you’d encounter the interface
JobContext.getConfiguration HadoopCompat.getConfiguration This is probably the most commonly used class (now an interface). You’ll likely bump into this interface as it’s how you get to a map or reduce task’s configuration. TaskAttemptContext.setStatus HadoopCompat.setStatus You’ll encounter this interface if you have a custom InputFormat, OutputFormat, RecordReader, or RecordWriter. TaskAttemptContext.getTaskAttemptID HadoopCompat.getTaskAttemptID You’ll use this interface if you have a custom InputFormat, OutputFormat, RecordReader, or RecordWriter. TaskAttemptContext.getCounter HadoopCompat.getCounter You’ll bump into this interface if you have a custom InputFormat, OutputFormat, RecordReader, or RecordWriter. Counter.incrementCounter HadoopCompat .incrementCounter If you use counters in your jobs, you’ll need to use the HadoopCompat call.
Listing 4.3. Methods to read and write LZOP files in HDFS
public static Path compress(Path src, Configuration config) throws IOException { Path destFile = new Path( src.toString() + new LzopCodec().getDefaultExtension()); LzopCodec codec = new LzopCodec(); codec.setConf(config); FileSystem hdfs = FileSystem.get(config); InputStream is = null; OutputStream os = null; try { is = hdfs.open(src); os = codec.createOutputStream(hdfs.create(destFile)); IOUtils.copyBytes(is, os, config); } finally { IOUtils.closeStream(os); IOUtils.closeStream(is); } return destFile; } public static void decompress(Path src, Path dest, Configuration config) throws IOException { LzopCodec codec = new LzopCodec(); codec.setConf(config); FileSystem hdfs = FileSystem.get(config); InputStream is = null; OutputStream os = null; try { is = codec.createInputStream(hdfs.open(src)); os = hdfs.create(dest); IOUtils.copyBytes(is, os, config); } finally { IOUtils.closeStream(os); IOUtils.closeStream(is); } }
Figure 6.17 shows the configuration names and methods that you’ll call in your code to set the partitioning, sorting, and grouping classes. The figure also shows what part of the composite key each class uses.