- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我的映射器实现
public class SimpleMapper extends Mapper<Text, Text, Text, MapWritable> {
@Override
protected void map(Text key, Text value,Context context)
throws IOException, InterruptedException {
MapWritable writable = new LinkedMapWritable();
writable.put("unique_key","one");
writable.put("another_key","two");
context.write(new Text("key"),writable );
}
Reducer 实现是:
public class SimpleReducer extends Reducer<Text, MapWritable, NullWritable, Text> {
@Override
protected void reduce(Text key, Iterable<MapWritable> values,Context context)
throws IOException, InterruptedException {
// The map writables have to be ordered based on the "unique_key" inserted into it
}
我必须使用二级排序吗?还有其他方法吗?
最佳答案
reducer 中的 MapWritable (values) 始终处于不可预测的顺序,此顺序可能会因运行而异,您无法控制它。
但是 Map/Reduce 范式保证的是呈现给 reducer 的键将按排序顺序排列,属于单个键的所有值将进入单个 reducer。
因此,您绝对可以为您的用例使用辅助排序和自定义分区程序。
关于hadoop - 如何维护 Reducer 中 MapWritables 的顺序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24316641/
我有 Java(带有 map-reduce hadoop 库): MapWritable mw; 我需要在 mw 的所有 MapWritable 值上获取迭代器,但是如何? 我会写: Iterator
我对Spark和Scala都不熟悉。我已经在互联网上阅读了一些文章。我可以使用Spark成功地从Elasticsearch获取文档,但是我对如何从文档中提取字段感到困惑。 我做了什么 我有33,617
实际上,我正在尝试实现一种机器学习算法,该算法要求我将 reducer 的输出写入文件,然后在下一个映射器中读取该文件。问题是我正在文件中编写在 reducer 中创建的 MapWritable 对象
我在我的 Hadoop Map Reduce 程序中使用 MapWritable。当我将 MapWritable 映射作为 new Text (mapName.toString()) 发出时,我得到以
我正在尝试安装用于渗透的mapsforge-mapwriter-plugin,但我无法让它工作。 我尝试了普通的基于 shell 的版本和页面上提到的方法:“http://code.google.co
我目前正在尝试反序列化一个自定义对象,其中一个字段是 MapWritable,另一个字段是字符串。序列化似乎工作正常,但无法验证对象是否正在正确重新创建。他是我的字段和 write() readFie
我想传递一个Map从我的映射器到 reducer 。 所以我想要的元组是: 目前,这个可怜人的序列化避免了这一点:我创建了一个简单的 Text使用 Guava -s MapJoiner 和 MapSp
我的映射器实现 public class SimpleMapper extends Mapper { @Override protected void map(Text key, Text value
当我使用 toString() 方法运行我的输出时,我得到: #zombie org.apache.hadoop.io.MapWritable@b779f586 #zombies org
我正在尝试使用 SequenceFile 在两个 mapReduce 程序之间传递数据。我要传递的数据格式为 >。由于某种原因, map 中的某些条目似乎没有从一个程序传递到另一个程序。这是我的代码,
我正在使用 Hadoop 2.6.4,并且正在尝试为单词共现实现 Stripes 映射器。尝试使用 MapWritable 时遇到问题类(class)。当尝试将新的键/值添加到映射中时,添加的任何键都
我是一名优秀的程序员,十分优秀!