Basically I m failing to understand how to construct
Test
object in this case.
Yup, you're missing the point. If you need to construct an instance of Test
and populate atoms
, then you need to add a constructor to Test
:
public Test(ArrayList<AtomicWritable> atoms) {
this.atoms = atoms;
}
or you need to use the default constructor and add a method or a setter that lets you add items to atoms
or set the value of atoms
. The latter is actually pretty common in the Hadoop framework, to have a default constructor and a set
method. cf., e.g., Text.set
.
You don't call readFields
and write
; the Hadoop framework does that for you when it needs to serialize and deserialize inputs and outputs to and from map
and reduce
.