mapreduce编程模型之partitioner
来源:互联网 发布:淘宝买家秀图片不显示 编辑:程序博客网 时间:2024/05/16 12:14
Partitioner是一个mapreduce的顶级抽象类 用于决定map输出的kv键值对 如何按照job.setnumberruce(n)中设置的n个数进行分区 每个kv落在哪个分区之中 以及如何保证相同的key落在同一个分区中 只有相同的key落在同一个分区中 才能保证 这个相同的key可以被同一个reducer处理
上代码
public static class MyPartitioner extends Partitioner<Text,Text>{ @Override public int getPartition(Text key, Text value, int numPartitions) { if (key.toString().equals("hello")) return 0; else return 1; } }
这是定义了一个partitoner 这个partitioner定义了只有key为hello的时候是落在0分区 其余的都落在1分区 运行测试结果却是如此
hdfs@yksp005206:/home/jumpserver$ hadoop fs -cat /test/wc/output/part-r-00000
hello value[] hello,hello,hello,
hdfs@yksp005206:/home/jumpserver$ hadoop fs -cat /test/wc/output/part-r-00001
hellp value[] hellp,
hive value[] hive,
kylin value[] kylin,
spark value[] spark,
world value[] world,
partitioner的默认实现是hashpartitioner
(key.hashCode() & Integer.MAX_VALUE) % numReduceTasks;
这个的意思是对key进行取hashcode 然后对n进行取余
阅读全文
0 0
- mapreduce编程模型之partitioner
- MapReduce编程之Partitioner
- MapReduce之自定义partitioner
- MapReduce之自定义partitioner
- MapReduce之Partitioner的理解
- hadoop之partitioner编程
- hadoop之Partitioner编程
- Hadoop之MapReduce编程模型
- mapreduce编程模型之WritableComparator
- hadoop初学之MapReduce编程模型学习
- MapReduce编程模型之InputFormat分析(-)
- MapReduce编程模型之InputFormat分析(二)
- 【MongoDB】MongoDB数据库之MapReduce编程模型
- 3.MapReduce高级接口编程(partitioner、sort、combiner)
- partitioner编程
- Partitioner编程
- Partitioner编程
- MapReduce之Partitioner组件源码解析及实例
- Java环境变量配置
- NIO buffer 读写方法介绍
- linux 下安装memcache
- Oracle恢复数据
- 安全性问题
- mapreduce编程模型之partitioner
- javaBean验证框架(1)—概述
- Mediator 中介者模式 --对象行为型模式
- settimeout()用法详解
- Photon_PhotonServer的执行流程_013
- ECMAscript6快速入门-Symbol
- 列表:一个打了激素的数组1
- Scipy:高端科学计算
- PyCharm在MAC上的第一次使用