giraph-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Carmen Manzulli <carmenmanzu...@gmail.com>
Subject Re: Couldn't instantiate
Date Tue, 01 Jul 2014 09:42:58 GMT
Hi John,
yes I've tried to insert a no-arguments constructor but the problem seems
to be another one.This is my code, an input format with a vertexreader to
read triple as RDF.

import java.io.IOException;
import java.util.ArrayList;
import java.lang.InterruptedException;

import org.apache.giraph.graph.Vertex;
import org.apache.giraph.edge.Edge;
import org.apache.giraph.edge.EdgeFactory;
import org.apache.giraph.io.VertexReader;
import org.apache.giraph.io.VertexInputFormat;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.InputSplit;
import org.apache.hadoop.mapreduce.RecordReader;
import org.apache.hadoop.mapreduce.lib.input.LineRecordReader;
import org.apache.hadoop.mapreduce.TaskAttemptContext;



public abstract class SimpleRDFVertexInputFormat extends VertexInputFormat
<Text,NullWritable,Text> {

    public SimpleRDFVertexInputFormat() {
        // TODO Auto-generated constructor stub
        super();
    }

    public VertexReader<Text,NullWritable,Text>
createVertexReader(InputSplit split,TaskAttemptContext context) throws
IOException{
        return new SimpleRDFVertexReader();
    }
    public class SimpleRDFVertexReader extends
VertexReader<Text,NullWritable,Text>{

        private RecordReader<LongWritable,Text> lineRecordReader;
        private TaskAttemptContext context;


        @Override
        public void initialize(InputSplit inputsplit, TaskAttemptContext
context) throws IOException, InterruptedException{

            this.setContext(context);
            lineRecordReader= new LineRecordReader();
            lineRecordReader.initialize(inputsplit, context);

        }

        @Override
        public final boolean nextVertex() throws IOException,
InterruptedException{
            return lineRecordReader.nextKeyValue();
        }


        @Override
        public final Vertex<Text,NullWritable,Text> getCurrentVertex()
throws IOException, InterruptedException{
            Text line = lineRecordReader.getCurrentValue();
            Vertex<Text,NullWritable,Text> vertex =
getConf().createVertex();
            String[] elements = line.toString().split(" ");
            Text firstele = new Text(elements[0]);
            int len1 = firstele.getLength();
            Text  subject = new Text(firstele.toString().substring(1,
len1-1));
            Text secondele = new Text(elements[1]);
            int len2 = secondele.getLength();
            Text predicate = new Text(secondele.toString().substring(1,
len2-1));
            Text object = new Text(elements[2]);
            ArrayList<Edge<Text,Text>> edge = new
ArrayList<Edge<Text,Text>>();
            edge.add(EdgeFactory.create(object, predicate) );
            vertex.initialize(subject, null, edge );
            return vertex;

        }

        @Override
        public void close() throws IOException{
            lineRecordReader.close();
        }

        @Override
        public  float getProgress()throws IOException,InterruptedException{
            return lineRecordReader.getProgress();
        }

        public TaskAttemptContext getContext() {
            return context;
        }

        public void setContext(TaskAttemptContext context) {
            this.context = context;
        }


    }


}


2014-07-01 4:23 GMT+02:00 John Yost <soozandjohnyost@gmail.com>:

> Hi Carmen,
>
> Question--did you only define an arguments constructor?  If so, I think
> you are getting this because you did not define a no-arguments constructor
> with public visibility.  If this is not the case, I recommend posting your
> source code and I will be happy to help.
>
> --John
>
>
> On Mon, Jun 30, 2014 at 9:38 AM, Carmen Manzulli <carmenmanzulli@gmail.com
> > wrote:
>
>> Hi,
>>
>> I'm trying to run a selectionComputation with my own code for VertexInputFormat but
giraph' job starts to work and then fails with:
>>
>>
>>
>>
>> java.lang.IllegalStateException: run: Caught an unrecoverable exception newInstance:
Couldn't instantiate sisinflab.SimpleRDFVertexInputFormat
>> 	at org.apache.giraph.graph.GraphMapper.run(GraphMapper.java:101)
>> 	at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:764)
>> 	at org.apache.hadoop.mapred.MapTask.run(MapTask.java:364)
>> 	at org.apache.hadoop.mapred.Child$4.run(Child.java:255)
>> 	at java.security.AccessController.doPrivileged(Native Method)
>> 	at javax.security.auth.Subject.doAs(Subject.java:415)
>> 	at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1190)
>> 	at org.apache.hadoop.mapred.Child.main(Child.java:249)
>> Caused by: java.lang.IllegalStateException: newInstance: Couldn't instantiate sisinflab.SimpleRDFVertexInputFormat
>> 	at org.apache.giraph.utils.ReflectionUtils.newInstance(ReflectionUtils.java:105)
>> 	at org.apache.giraph.conf.ImmutableClassesGiraphConfiguration.createVertexInputFormat(ImmutableClassesGiraphConfiguration.java:235)
>> 	at org.apache.giraph.conf.ImmutableClassesGiraphConfiguration.createWrappedVertexInputFormat(ImmutableClassesGiraphConfiguration.java:246)
>> 	at org.apache.giraph.graph.GraphTaskManager.checkInput(GraphTaskManager.java:171)
>> 	at org.apache.giraph.graph.GraphTaskManager.setup(GraphTaskManager.java:207)
>> 	at org.apache.giraph.graph.GraphMapper.setup(GraphMapper.java:59)
>> 	at org.apache.giraph.graph.GraphMapper.run(GraphMapper.java:89)
>> 	... 7 more
>> Caused by: java.lang.InstantiationException
>> 	at sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:48)
>> 	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
>> 	at java.lang.Class.newInstance(Class.java:374)
>> 	at org.apache.giraph.utils.ReflectionUtils.newInstance(ReflectionUtils.java:103)
>> 	... 13 more
>>
>>
>> what does it mean? where is the problem?
>>
>> Who can help me?
>>
>> Carmen
>>
>>
>

Mime
View raw message