学习日志---partitioner和采样器
发表于:2025-02-19 作者:千家信息网编辑
千家信息网最后更新 2025年02月19日,Mapreduce中:shuffle阶段是在map和reduce之间,可以自定义排序,自定义分区和自定义分组!Mapreduce中,map出的数据是键值对,默认的是hashPatitionner来对m
千家信息网最后更新 2025年02月19日学习日志---partitioner和采样器
Mapreduce中:
shuffle阶段是在map和reduce之间,可以自定义排序,自定义分区和自定义分组!
Mapreduce中,map出的数据是键值对,默认的是hashPatitionner来对map出的数据进行分区;
分区的方法还有其他几个:
RandomSamplersampler = new InputSampler.RandomSampler (0.5, 3000, 10);IntervalSampler sampler2 = new InputSampler.IntervalSampler (0.333, 10);SplitSampler sampler3 = new InputSampler.SplitSampler (reduceNumber);
实现和细节
public class TotalSortMR { @SuppressWarnings("deprecation") public static int runTotalSortJob(String[] args) throws Exception { Path inputPath = new Path(args[0]); Path outputPath = new Path(args[1]); Path partitionFile = new Path(args[2]); int reduceNumber = Integer.parseInt(args[3]); //三种采样器 RandomSamplersampler = new InputSampler.RandomSampler (1, 3000, 10); IntervalSampler sampler2 = new InputSampler.IntervalSampler (0.333, 10); SplitSampler sampler3 = new InputSampler.SplitSampler (reduceNumber); //任务初始化 Configuration conf = new Configuration(); Job job = Job.getInstance(conf); job.setJobName("Total-Sort"); job.setJarByClass(TotalSortMR.class); job.setInputFormatClass(KeyValueTextInputFormat.class); job.setMapOutputKeyClass(Text.class); job.setMapOutputValueClass(Text.class); job.setNumReduceTasks(reduceNumber); //设置所有的分区类 job.setPartitionerClass(TotalOrderPartitioner.class); //分区类参考的分区文件 TotalOrderPartitioner.setPartitionFile(conf, partitionFile); //分区使用哪种采样器 InputSampler.writePartitionFile(job, sampler); //job的输入和输出路径 FileInputFormat.setInputPaths(job, inputPath); FileOutputFormat.setOutputPath(job, outputPath); outputPath.getFileSystem(conf).delete(outputPath, true); return job.waitForCompletion(true)? 0 : 1; } public static void main(String[] args) throws Exception{ System.exit(runTotalSortJob(args)); }}
job默认的输入格式是TextInputFormat,这个是key-value的形式,key是每行的行标,value是每行的内容。可以更改
job.setInputFormatClass(,....)
一般要设置mapper的输出格式,以备后面使用。
采样器
数据
格式
输入
输出
之间
任务
内容
形式
文件
方法
是在
细节
路径
阶段
分组
参考
排序
日志
学习
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
网络安全钥密不对
数据库怎么降低安全性
维普和知网期刊数据库的异同
期货后续培训答案网络安全法
理性维护网络安全
本地域名服务器是本机吗
网络安全例子素材
软件开发工具主要分类方法
sum like 数据库
文件服务器和数据库存储文件
服务器管理员可以更换吗
战地1服务器都没有人了
采购需要了解的数据库
上海大学数据库2实验
剑灵个服务器地址
计算机3级网络技术考试时间
菏泽服务器运维管理系统销售
安全网络安全宣传画
黑莓Q10软件开发
网络安全和通信安全
计算机网络技术对未来的规划
网络技术属于信息技术范畴吗
常州网络安全警察办公地址
网络安全法规定县
武昌订制软件开发团队
青海盐湖环境数据库
不同的战斗服务器
计算机3级网络技术考试时间
计算机网络技术专业从零开始
sql 怎么停用数据库