1
$\begingroup$

I have some questions about Custom Writable objects in Hadoop. First of all, the private instance variables of the Writable object have to be Writable?

How does Hadoop handle TreeSet<IntWritable> differently from ArrayWritable<IntWritable> in org.apache.giraph.utils (Class ArrayWritable<T extends org.apache.hadoop.io.Writable)?

I have the following variables:

private TreeSet<IntWritable> vertexList; 
private IntWritable shortestPathCounter;
private IntWritable totalShortestPathCounter;
private DoubleWritable bCentrality;

and the following method for serializing. Are write and readFields method correctly handled this way?

public void readFields(DataInput in) throws IOException {
    for(IntWritable i: vertexList)
        i.readFields(in);
    shortestPathCounter.readFields(in);
    totalShortestPathCounter.readFields(in);
    bCentrality.readFields(in);
}

public void write(DataOutput out) throws IOException {
    for(IntWritable i: vertexList)
        i.write(out);
    shortestPathCounter.write(out);
    totalShortestPathCounter.write(out);
    bCentrality.write(out);
}
$\endgroup$

0

Browse other questions tagged or ask your own question.