MapReduce执行警告WARN mapreduce.JobResourceUploader

WARN mapreduce.JobResourceUploader: Hadoop command-line option parsing not performed. Implement the Tool interface and execute your application with ToolRunner to remedy this.

这个警告的意思是代码里用的运行方式过时了,推荐使用继承Configured实现Tool接口的方式来实现它

如下:

 

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;

import java.io.IOException;

public class WordCountUpMR extends Configured implements Tool {

    //Map
    public static class WordCountMapper extends Mapper<LongWritable, Text, Text, LongWritable> {

        @Override
        protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
            String linData = value.toString();
            //切割条件
            String[] words = linData.split(",");
            for (String word : words) {
                context.write(new Text(word), new LongWritable(1));
            }
        }
    }

    //Reduce
    public static class WordCountReducer extends Reducer<Text, LongWritable, Text, LongWritable> {

        @Override
        protected void reduce(Text key, Iterable<LongWritable> values, Context context) throws IOException, InterruptedException {
            long count = 0;
            for (LongWritable value : values) {
                count += value.get();
            }
            context.write(key, new LongWritable(count));
        }
    }

    //Driver
    public int run(String args[]) throws Exception {
        //create job
        Job job = Job.getInstance(this.getConf(), "name01");

        //设置程序的主类
        job.setJarByClass(this.getClass());

        //设置Map和Reduce   程序代码
        job.setMapperClass(WordCountMapper.class);
        job.setReducerClass(WordCountReducer.class);

        //设置Map输出的key   value的类型
        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(LongWritable.class);

        //设置Reduce输出的key   value的类型
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(LongWritable.class);

        //设置去哪里读取数据input
        FileInputFormat.addInputPath(job, new Path(args[0]));

        //设置最终结果写到哪里去(输出路径)output
        FileOutputFormat.setOutputPath(job, new Path(args[1]));

        //提交任务commit
        boolean isSuccess = job.waitForCompletion(true);
        return (isSuccess) ? 0 : 1;
    }

    public static void main(String[] args) {
        Configuration configuration = new Configuration();
        try {
            //判断输出目录是否存在,若存在,则删除
            Path fileOutPath = new Path(args[1]);
            FileSystem fileSystem = FileSystem.get(configuration);
            if (fileSystem.exists(fileOutPath)) {
                fileSystem.delete(fileOutPath, true);
            }
            int status = ToolRunner.run(configuration, new WordCountUpMR(), args);
            System.exit(status);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}

执行结果:

金融新闻情绪分析数据集合_Financial-News-Sentiment-Analysis-Dataset 该数据集系统收录了专业财经媒体发布的新闻报道文本,并依据金融市场的情绪影响维度进行多层级标注。数据来源涵盖主流财经报刊、权威证券分析报告及上市公司公告等专业渠道,所有文本均经过金融领域专家的双重交叉验证,确保情绪标签与市场实际反应的对应准确性。 标注体系采用五级分类标准:强烈看涨、温和看涨、中性、温和看跌、强烈看跌,每个类别均附有基于历史行情数据的量化验证指标。数据时间跨度涵盖2015至2022年完整市场周期,包含牛熊市转换、政策调整期、黑天鹅事件等典型市场环境下的情绪样本,共计12.8万条标注记录。 除基础情绪标签外,数据集还提供行业板块关联、市值规模匹配、波动率区间等辅助维度,支持研究者在控制变量条件下进行情绪传导机制分析。所有文本均已完成去标识化处理,剔除广告内容及重复条目,并建立专业金融术语标准化词表以确保分析一致性。 该资源适用于构建基于深度学习的金融市场情绪监测模型,亦可作为量化投资策略的因子验证基础,相关技术文档详细说明了数据采集流程、标注质量控制方法及统计特征描述。资源来源于网络分享,仅用于学习交流使用,请勿用于商业,如有侵权请联系我删除!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值