giraph-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wasim Mohammad <wasim....@gmail.com>
Subject Connected components output format
Date Sun, 17 Mar 2013 14:21:06 GMT
Please tell me what is wrong with this code. It is giving me compilation
error.

package org.apache.giraph.io;

import org.apache.giraph.graph.Vertex;
import org.apache.giraph.io.VertexWriter;
import org.apache.giraph.io.formats.TextVertexOutputFormat;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.RecordWriter;
import org.apache.hadoop.mapreduce.TaskAttemptContext;

import java.io.IOException;

/**
 * Text-based {@link org.apache.giraph.graph.VertexOutputFormat} for usage
with
 * {@link ConnectedComponentsVertex}
 *
 * Each line consists of a vertex and its associated component (represented
by the smallest
 * vertex id in the component)
 */
public class VertexWithComponentTextOutputFormat extends
        TextVertexOutputFormat<IntWritable, IntWritable, NullWritable> {

    @Override
    public TextVertexWriter //<IntWritable, IntWritable, NullWritable>
            createVertexWriter(TaskAttemptContext context)
            throws IOException, InterruptedException {
        RecordWriter<Text, Text> recordWriter =
                textOutputFormat.getRecordWriter(context);
        return new VertexWithComponentWriter(recordWriter);
    }

     static  class VertexWithComponentWriter extends
            TextVertexWriter /*<IntWritable, IntWritable,
            NullWritable>*/ {

        public VertexWithComponentWriter(RecordWriter<Text, Text> writer) {
            super(writer);
        }

        @Override
        public void writeVertex(Vertex<IntWritable, IntWritable,
                NullWritable,?> vertex) throws IOException,
                InterruptedException {
            StringBuilder output = new StringBuilder();
            output.append(vertex.getId().get());
            output.append('\t');
            output.append(vertex.getValue().get());
            getRecordWriter().write(new Text(output.toString()), null);
        }

    }
}


Thanks,
M.Vasimuddin

Mime
View raw message