Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/326.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/hadoop/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java getstrings方法hadoop中的null指针异常_Java_Hadoop_Mapreduce - Fatal编程技术网

Java getstrings方法hadoop中的null指针异常

Java getstrings方法hadoop中的null指针异常,java,hadoop,mapreduce,Java,Hadoop,Mapreduce,正在驱动程序类conf.getstrings()方法中获取空指针异常。此驱动程序类是从我的自定义网站调用的 以下是驾驶员等级的详细信息 @SuppressWarnings("unchecked") public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Co

正在驱动程序类conf.getstrings()方法中获取空指针异常。此驱动程序类是从我的自定义网站调用的

以下是驾驶员等级的详细信息

 @SuppressWarnings("unchecked")
public void doGet(HttpServletRequest request,
                 HttpServletResponse response)
         throws ServletException, IOException
{
       Configuration conf = new Configuration();       
       //conf.set("fs.default.name", "hdfs://localhost:54310");
       //conf.set("mapred.job.tracker", "localhost:54311");
       //conf.set("mapred.jar","/home/htcuser/Desktop/ResumeLatest.jar");
       Job job = new Job(conf, "ResumeSearchClass");        
       job.setJarByClass(HelloForm.class);      
       job.setJobName("ResumeParse");
       job.setInputFormatClass(FileInputFormat.class);
       FileInputFormat.addInputPath(job, new Path("hdfs://localhost:54310/usr/ResumeDirectory"));
       job.setMapperClass(ResumeMapper.class);
       job.setReducerClass(ResumeReducer.class);
       job.setMapOutputKeyClass(IntWritable.class);
       job.setSortComparatorClass(ReverseComparator.class);       
       job.setMapOutputValueClass(Text.class);
       job.setOutputKeyClass(IntWritable.class);
       job.setOutputValueClass(Text.class);
       job.setOutputFormatClass(FileOutPutFormat.class);
       FileOutputFormat.setOutputPath(job, new Path("hdfs://localhost:54310/usr/output" + System.currentTimeMillis()));
       long start = System.currentTimeMillis();
       var = job.waitForCompletion(true) ? 0 : 1;
    public class RecordWrite extends org.apache.hadoop.mapreduce.RecordWriter<IntWritable, Text> {

    TaskAttemptContext context1;
    Configuration conf;

    public RecordWrite(DataOutputStream output, TaskAttemptContext context)
    {
        out = output;        
        conf  = context.getConfiguration();
        HelloForm.context1=context;        
        try {
            out.writeBytes("result:\n");
            out.writeBytes("Name:\t\t\t\tExperience\t\t\t\t\tPriority\tPriorityCount\n");            
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    public RecordWrite() {
        // TODO Auto-generated constructor stub
    }
    @Override
    public void close(TaskAttemptContext context) throws IOException,
            InterruptedException
    {    
        out.close();
    }
    int z=0;
    @Override
    public void write(IntWritable value,Text key) throws IOException,
            InterruptedException
    {

        conf.setStrings("Keytext", key1string); //setting values here        
        conf.setStrings("valtext", valuestring);
        String[] keytext=key.toString().split(Pattern.quote("^"));
        //some code here

    }
}`
从以下两行代码中获取空指针异常

String[] keytextarray=conf.getStrings("Keytext");   

for(int i=0;i<keytextarray.length;i++) //GETTING NULL POINTER EXCEPTION HERE IN keytextarray.length
    {
        //some code here
    }

       if(var==0)
       {        
        RequestDispatcher dispatcher = request.getRequestDispatcher("/Result.jsp");
        dispatcher.forward(request, response);
       long finish= System.currentTimeMillis();
       System.out.println("Time Taken "+(finish-start));
       }
}
String[]keytextarray=conf.getStrings(“Keytext”);

对于(int i=0;i如果在作业类中有key1staring和valuestirng的值,请尝试在作业类本身而不是RecordWriter.write()方法中设置它们。

如果在作业类中有key1staring和valuestirng的值,请尝试在作业类本身而不是RecordWriter.write()中设置它们方法。

我在作业类(驱动程序类)中没有key1string和valuestring的值。值来自reducer类的输出,我需要在我的驱动程序中检索它。请尝试添加字符串[]keytextarray=conf.getString(“Keytext”);在resultwriter中,在您设置值并验证其设置是否正确后。我可以在recordwriter中使用getString作为ser属性并成功检索它,但在driverclasss中无法检索。请让我知道如何从recordwriter检索值到driverclasss..conf与作业链接,因此我假设在完成减速机后,您将从作业本身获取conf。此外,我可以看到您正在将自定义值设置为conf,只是为了传递。我不确定传递值的方法是否正确。感谢您的帮助。我可以通过使用Getter和setter创建自定义类并设置TaskAttemptCon来检索Driverclass中的RecordWrite内容文本对象到RecordWrite中的自定义类,并成功从Driverclass中的自定义类获取TaskAttemptContext对象。但该代码在群集中不起作用。下面是详细信息RecordWrite类
公共RecordWrite(DataOutputStream输出,TaskAttemptContext上下文){SaveObject.setObject(上下文);}
Driver Class`TaskAttemptContext context1=(TaskAttemptContext)SaveObject.getObject();“我在作业类(驱动程序类)中没有key1string和valuestring的值。值来自reducer类的输出,我需要在我的驱动程序中检索它。请尝试添加字符串[]keytextarray=conf.getStrings(“Keytext”);在resultwriter中,在您设置值并验证其设置是否正确后。我可以在recordwriter中使用getString作为ser属性并成功检索它,但在driverclasss中无法检索。请让我知道如何从recordwriter检索值到driverclasss..conf与作业链接,因此我假设在完成减速机后,您将从作业本身获取conf。此外,我可以看到您正在将自定义值设置为conf,只是为了传递。我不确定传递值的方法是否正确。感谢您的帮助。我可以通过使用Getter和setter创建自定义类并设置TaskAttemptCon来检索Driverclass中的RecordWrite内容文本对象到RecordWrite中的自定义类,并成功从Driverclass中的自定义类获取TaskAttemptContext对象。但该代码在群集中不起作用。下面是详细信息RecordWrite类
公共RecordWrite(DataOutputStream输出,TaskAttemptContext上下文){SaveObject.setObject(上下文);}
Driver Class`TaskAttemptContext context1=(TaskAttemptContext)SaveObject.getObject();“我在作业类(驱动程序类)中没有key1string和valuestring的值。值来自reducer类的输出,我需要在我的驱动程序中检索它。请尝试添加字符串[]keytextarray=conf.getStrings(“Keytext”);在resultwriter中,在您设置值并验证其设置是否正确后。我可以在recordwriter中使用getString作为ser属性并成功检索它,但在driverclasss中无法检索。请让我知道如何从recordwriter检索值到driverclasss..conf与作业链接,因此我假设在完成减速机后,您将从作业本身获取conf。此外,我可以看到您正在将自定义值设置为conf,只是为了传递。我不确定传递值的方法是否正确。感谢您的帮助。我可以通过使用Getter和setter创建自定义类并设置TaskAttemptCon来检索Driverclass中的RecordWrite内容文本对象到RecordWrite中的自定义类,并成功从Driverclass中的自定义类获取TaskAttemptContext对象。但该代码在群集中不起作用。下面是详细信息RecordWrite类
公共RecordWrite(DataOutputStream输出,TaskAttemptContext上下文){SaveObject.setObject(上下文);}
Driver类`TaskAttemptContext context1=(TaskAttemptContext)SaveObject.getObject();'