Time for action – using the Writable wrapper classes
Let's write a class to show some of these wrapper classes in action:
Create the following as
WritablesTest.java
:import org.apache.hadoop.io.* ; import java.util.* ; public class WritablesTest { public static class IntArrayWritable extends ArrayWritable { public IntArrayWritable() { super(IntWritable.class) ; } } public static void main(String[] args) { System.out.println("*** Primitive Writables ***") ; BooleanWritable bool1 = new BooleanWritable(true) ; ByteWritable byte1 = new ByteWritable( (byte)3) ; System.out.printf("Boolean:%s Byte:%d\n", bool1, byte1.get()) ; IntWritable i1 = new IntWritable(5) ; IntWritable i2 = new IntWritable( 17) ; System.out.printf("I1:%d I2:%d\n", i1.get(), i2.get()) ; i1.set(i2.get()) ; System.out.printf("I1:%d I2:%d\n", i1.get(), i2.get()) ; Integer i3 = new Integer...