I'm trying to understand how to write and read an int array into/from a file in the HDFS..
since a int[]
array isn't a Writable
object, I'm actually using the class org.apache.hadoop.io.ObjectWritable
So the write task boils down to the following call:
new ObjectWritable(int[].class, array).write(arg0);
Instead, the read task causes the following:
int[] array = {};
new ObjectWritable(int[].class, array).readFields(arg0);
I'm not so sure about the last code snippet. In fact if I try to execute it, I get a NullPointerException
on the second line.
How can I perform correctly a read of an int[]
array?