public static void main(String[] args) throws Exception {
Configuration conf = new Configuration(); conf.set("mapred.job.tracker", Constants.HADOOP_MAIN_IP + Constants.MAO_HAO + Constants.HADOOP_MAIN_PORT); if (args.length != 3) {
System.err.println("Usage: Data Deduplication <in> <out> <reduceNum>");
System.exit(2);
}
Job job = new Job(conf, "ETLTld Job");
job.setJarByClass(ETLTldMain.class); job.setMapperClass(ETLTldMapper.class);
job.setReducerClass(ETLTldReducer.class); job.setInputFormatClass(LzoTextInputFormat.class); job.setNumReduceTasks(Integer.parseInt(args[2])); job.setOutputKeyClass(Text.class);
job.setOutputValueClass(Text.class); FileInputFormat.addInputPath(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1])); FileOutputFormat.setCompressOutput(job, true);
FileOutputFormat.setOutputCompressorClass(job, LzopCodec.class);
int result = job.waitForCompletion(true) ? 0 : 1; if (result == 0) {
LzoIndexer lzoIndexer = new LzoIndexer(conf);
lzoIndexer.index(new Path(args[1]));
System.exit(result);
} else if(result == 1
){
System.exit(result);
}
}

如果已经有了lzo文件,可以采用如下方法添加索引:

bin/yarn jar /module/cloudera/parcels/GPLEXTRAS-5.4.0-1.cdh5.4.0.p0.27/lib/hadoop/lib/hadoop-lzo-0.4.15-cdh5.4.0.jar com.hadoop.compression.lzo.DistributedLzoIndexer /user/hive/warehouse/cndns.db/ods_cndns_log/dt=20160803/node=alicn/part-r-00000.lzo

lzo格式默认是不支持splitable的,需要为其添加索引文件,才能支持多个map并行对lzo文件进行处理。

【参考】http://blog.csdn.net/wisgood/article/details/17080361

hadoop输出lzo文件并添加索引的更多相关文章

  1. mapreduce 读写lzo文件

    1.读lzo文件 需要添加以下代码,并导入lzo相关的jar包  job.setInputFormatClass(LzoTextInputFormat.class); 2.写lzo文件 lzo格式默认 ...

  2. 【转】MapReduce读取lzo文件

    1.读lzo文件 需要添加以下代码,并导入lzo相关的jar包 job.setInputFormatClass(LzoTextInputFormat.class); 2.写lzo文件 lzo格式默认是 ...

  3. EXPLAIN sql优化方法(1) 添加索引

    添加索引优化器更高效率地执行语句 假设我们有两个数据表t1和t2,每个有1000行,包含的值从1到1000.下面的查询查找出两个表中值相同的数据行: mysql> SELECT t1.i1, t ...

  4. 对TextFile格式文件的lzo压缩建立index索引

    转自:http://blog.csdn.net/yangbutao/article/details/8519572 hadoop中可以对文件进行压缩,可以采用gzip.lzo.snappy等压缩算法. ...

  5. Solr json,xml等文件数据导入(添加索引)linux下操作

    使用solr-5.3.1\example\exampledocs下的post.jar来完成数据导入 1.将想要导入的文件放在solr-5.3.1\example\exampledocs中,如aaa.x ...

  6. hadoop的lzo支持

    目录 1.下载相关文件: 2.Configure LZO to build a shared library (required) and use a package-specific prefix ...

  7. hadoop支持lzo完整过程

    简介 启用lzo 启用lzo的压缩方式对于小规模集群是很有用处,压缩比率大概能降到原始日志大小的1/3.同时解压缩的速度也比较快. 安装lzo lzo并不是linux系统原生支持,所以需要下载安装软件 ...

  8. Hadoop之HDFS文件操作常有两种方式(转载)

    摘要:Hadoop之HDFS文件操作常有两种方式,命令行方式和JavaAPI方式.本文介绍如何利用这两种方式对HDFS文件进行操作. 关键词:HDFS文件    命令行     Java API HD ...

  9. hadoop对于压缩文件的支持及算法优缺点

    hadoop对于压缩文件的支持及算法优缺点   hadoop对于压缩格式的是透明识别,我们的MapReduce任务的执行是透明的,hadoop能够自动为我们 将压缩的文件解压,而不用我们去关心. 如果 ...

随机推荐

  1. nginx 备忘

    下载 start nginxlocalhost:80

  2. mac SVN 设置代理

    1. 设置代理一种方法:Finder 菜单里面 -> 前往 -> 前往文件夹 -> /Users/username/.subversion -> 编辑文件 servers 在文 ...

  3. 用javascript的isNan()函数,可以判断是否为数字

    var getstockid = $.trim($("#SearchString").val()); if (!isNaN(getstockid)) alert('是数字!'); ...

  4. hmac库 密钥相关的哈希运算消息认证码

    # -*- coding: cp936 -*- #xiaodeng #python 2.7.10 #HMAC是密钥相关的哈希运算消息认证码,HMAC运算利用哈希算法,以一个密钥和一个消息为输入,生成一 ...

  5. shell随机读取一行

    使用shell随机读取文件的一行数据 shuf -n1 file_name

  6. 使用SafeIP隐藏自己的IP

    资料:http://www.cnblogs.com/KeenLeung/p/3482241.html 1.到网上下载SafeIP这个工具,安装,打开 2.选择自己熟悉的语言: 3.到www.ip138 ...

  7. C-常用字符串操作函数详解

    //使用字符串操作应时刻注意字符串或者数组长度!!避免溢出!! 1. size_t strlen(char const *str); //计算字符串长度, 注意返回size_t类型的值, 即unsig ...

  8. Swift3 获取版本号,比较版本大小

    Swift获取应用版本号:version 1.获取本地版本号 /// 获取本地版本号 func getLocalVersion() -> String { var localVersion:St ...

  9. springmvc访问静态资源的springmvc.xml配置

    一. 问题及需求 由于Spring MVC的web.xml文件中关于DispatcherServlet拦截url的配置为"/",拦截了所有的请求,同时*.js,*.jpg等静态资源 ...

  10. Bugtags 让你的 APP 测试轻松、上线安心

    Bug 管理系统再进化 Bugtags 的创业团队,在过去几年,做了很多方向的尝试——没错,是开发了很多 APP. 每一轮迭代,都会被繁琐的 APP 测试困扰:无休止的截屏上传电脑,无数次的开发与测试 ...