giraph-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maja Kabiljo <majakabi...@fb.com>
Subject Re: Connected components output format
Date Mon, 18 Mar 2013 15:56:05 GMT
Hi Wasim,

Two things:
- TextVertexWriter is not a static class, so VertexWithComponentWriter shouldn't be either
- TextVertexWriter only has a default constructor, and you don't have to create RecordWriter

Maja

From: Wasim Mohammad <wasim.mzr@gmail.com<mailto:wasim.mzr@gmail.com>>
Reply-To: "user@giraph.apache.org<mailto:user@giraph.apache.org>" <user@giraph.apache.org<mailto:user@giraph.apache.org>>
Date: Sunday, March 17, 2013 6:21 AM
To: "user@giraph.apache.org<mailto:user@giraph.apache.org>" <user@giraph.apache.org<mailto:user@giraph.apache.org>>
Subject: Connected components output format


Please tell me what is wrong with this code. It is giving me compilation error.

package org.apache.giraph.io<http://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