学习日志---partitioner和采样器
发表于:2025-12-03 作者:千家信息网编辑
千家信息网最后更新 2025年12月03日,Mapreduce中:shuffle阶段是在map和reduce之间,可以自定义排序,自定义分区和自定义分组!Mapreduce中,map出的数据是键值对,默认的是hashPatitionner来对m
千家信息网最后更新 2025年12月03日学习日志---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]); //三种采样器 RandomSampler sampler = 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安全错误
数据库的锁怎样保障安全
c 数据库注入
sql数据库升级
南浔服务器530车
门户网络安全检查
互联网 算是高科技吗
暨南大学网络安全考研科目
移动开发和软件开发
网络安全文化建设的重要性
淄博智慧城管软件开发公司
网络安全法新政策
微信棋牌软件开发
电脑数据库可以开发什么业务
宿州汉雅网络技术服务有限公司
租服务器价钱大概
我的世界神奇宝贝服务器推荐等价交换
mysql数据库中文下载
软件开发的三层架构作用
服务器如何映射本地驱动器
光明租房软件开发
宝塔界面里的数据库
关于网络安全防控疫情的诗
汕头微商软件开发哪家好
软件开发极简
全国网络安全员法制竞赛花絮
市政工程项目管理软件开发价格
功夫熊猫游戏软件开发模式
软件开发如何进行审计
数据库安全认证含义
趋势 打印服务器
bms软件开发做什么的