m0_59356461 2021-06-16 11:49 采纳率: 0%
浏览 28

求各位大佬看看我这是什么问题

package com.position.clean;

import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;

/**
 * @author zyb
 * @date 2021/6/15 - 17:28
 */
public class CleanJob {
    public static String deleteString(String str, char delchar) {
        StringBuffer stringBuffer = new StringBuffer("");
        for (int i = 0; i < str.length(); i++) {
            if (str.charAt(i) != delchar) {
                stringBuffer.append(str.charAt(i));
            }
        }
        return stringBuffer.toString();
    }
    public static String mergeString(String position, JSONArray company)throws JSONException{
        String result = "";
        if (company.length() != 0) {
            for (int i = 0; i < company.length(); i++) {
                result = result + company.get(i) + "-";
            }
        }
        if (position != "") {
            String[] positionList = position.split("|;|, |、|,|; |/");
            for (int i = 0; i < positionList.length; i++) {
                result = result + positionList[i].replaceAll("[\\pP\\p{Punct}]","")+"-";
            }
        }
        return result.substring(0,result.length()-1);
    }
    public static String killResult(JSONArray killData) throws JSONException{
        String result = "";
        if (killData.length() != 0) {
            for (int i = 0; i < killData.length(); i++) {
                result = result + killData.get(i) + "-";
            }
            result = result.substring(0, result.length()-1);
        }
        return result;
    }
    public static String resultTOString(JSONArray jobdata)throws JSONException{
        String jobResultData = "";
        for (int i = 0; i < jobdata.length(); i++ ) {
            String everyData=jobdata.get(i).toString();
            JSONObject everyDataJson = new JSONObject(everyData);
            String city = everyDataJson.getString("city");
            String salary = everyDataJson.getString("salary");
            String positionAdvantage = everyDataJson.getString("positionAdvantage");
            JSONArray skillLables = everyDataJson.getJSONArray("skillLables");
            JSONArray companyLabelList = everyDataJson.getJSONArray("companyLabelList");
            String salaryNew = deleteString(salary,'k');
            String welfare = mergeString(positionAdvantage,companyLabelList);
            String kill = killResult(skillLables);
            if (i == jobdata.length()-1) {
                jobResultData = jobResultData + city + "," +salaryNew + "," + welfare + "," + kill;
            }else {
                jobResultData = jobResultData + city + "," +salaryNew + "," + welfare + "," + kill + "/n";
            }
        }
        return jobResultData;
    }
}
package com.position.clean;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;

import java.io.IOException;

/**
 * @author zyb
 * @date 2021/6/15 - 17:28
 */
public class CleanMapper extends Mapper<LongWritable, Text, Text, NullWritable> {
    @Override
    protected void map(LongWritable key, Text value, Context context)
            throws IOException, InterruptedException {
        String jobResultData = "";
        String reptileData = value.toString();
        String jobData = reptileData.substring(
                reptileData.indexOf("=",reptileData.indexOf("=")+1)+1,
                reptileData.length()-1);
        try {
            JSONObject contentJson = new JSONObject(jobData);
            String contentData = contentJson.getString("content");
            JSONObject positionResultJson = new JSONObject(contentData);
            String positionResultData =
                    positionResultJson.getString("positionResult");
            JSONObject resultJson = new JSONObject(positionResultData);
            JSONArray resultData = resultJson.getJSONArray("result");
            jobResultData = CleanJob.resultTOString(resultData);
            context.write(new Text(jobResultData), NullWritable.get());
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
}
package com.position.clean;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.log4j.BasicConfigurator;

import java.io.IOException;

/**
 * @author zyb
 * @date 2021/6/15 - 17:28
 */
public class CleanMain {
    public static void main(String[] args) throws IOException,
            ClassNotFoundException, InterruptedException {
        BasicConfigurator.configure();
        Configuration conf = new Configuration();
        Job job = new Job(conf, "job");
        job.setJarByClass(CleanMain.class);
        job.setMapperClass(CleanMapper.class);
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(NullWritable.class);
        FileInputFormat.addInputPath(job, new Path("hdfs://centos01:9000//JobData//20210615"));
        FileOutputFormat.setOutputPath(job, new Path("E:/IDEA/out1"));
        //FileInputFormat.setInputPaths(job,new Path(args[0]));
        //FileOutputFormat.setOutputPath(job,new Path(args[1]));
        System.exit(job.waitForCompletion(true) ? 0 : 1);
    }
}

在IDEA上  跑不起来  本地测试不生成文件

不会报错但是会出现这种情况,求大佬们指点谢谢了

  • 写回答

2条回答 默认 最新

  • CSDN专家-sinJack 2021-06-16 12:56
    关注

    首先学会查询日志信息,快速定位关键性的内容。

    在代码中多加点打印日志,方便跟踪问题,debug调试运行也可以,看看具体卡在哪一步。运行不起来跟下你截图中的日志。

    如有帮助,望采纳。点击我回答右上角【采纳】按钮。

     

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题