- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个mapper.py和reducer.py来处理输入文件,该文件只是具有以下格式的常规linux文件:
ID \t time \t duration \t Description \t status
#!/usr/bin/env python
import sys
import re
for line in sys.stdin:
#remove leading and trailing whitespace
line = line.strip()
#split the line into portions
portions = re.split(r'\t+',line)
#take the first column (which is block number) to emit as key
block = portions[0]
print '%s\t%s\t%s\t%s\t%s' % (block,portions[1],portions[2],portions[3],portions[4])
#!/usr/bin/env python
from operator import itemgetter
import sys
bitmapStr=""
current_block=None
block=start=duration=precision=status=""
round=0 #interval is every 11 mins or 660 seconds
for line in sys.stdin:
line=line.strip()
block,start,duration,precision,status=line.split('\t')
if current_block == block:
duration = int(duration)
while round < duration:
if(status.islower()):
bitmapStr=bitmapStr+"1"
else:
bitmapStr=bitmapStr+"0"
round = round + 660
#amount of time exceed this block record
round = round - duration
else:
if current_block:
print '%s\t%s' % (current_block,bitmapStr)
round=0
bitmapStr=""
current_block=block
duration = int(duration)
while round < duration:
if(status.islower()):
bitmapStr=bitmapStr+"1"
else:
bitmapStr=bitmapStr+"0"
round = round + 660
#amount of time exceed this block record
round = round - duration
if current_block == block:
print '%s\t%s' % (current_block,bitmapStr)
cat small_data_sample | ./mapper.py | sort -k1,1 | ./reducer.py
#output is working as I expect
Error: java.lang.RuntimeException: PipeMapRed.waitOutputThreads(): subprocess failed with code 1
at org.apache.hadoop.streaming.PipeMapRed.waitOutputThreads(PipeMapRed.java:320)
at org.apache.hadoop.streaming.PipeMapRed.mapRedFinished(PipeMapRed.java:533)
at org.apache.hadoop.streaming.PipeMapper.close(PipeMapper.java:130)
at org.apache.hadoop.mapred.MapRunner.run(MapRunner.java:61)
at org.apache.hadoop.streaming.PipeMapRunner.run(PipeMapRunner.java:34)
at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:430)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:342)
at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:167)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:415)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1556)
at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:162)
bin/hadoop jar hadoop-streaming.jar \
-D mapred.output.key.comparator.class=org.apache.hadoop.mapred.lib.KeyFieldBasedPartitioner \
-D mapred.text.key.partitioner.options='-k1,1' \
-D mapred.output.key.comparator.class=org.apache.hadoop.mapred.lib.KeyFieldBasedComparator -D mapred.text.key.comparator.options='-k1,1 -k2,2n' \
-D stream.num.map.output.key.fields=2 \
-input $hadoop_dir/data/sample \
-output $hadoop_dir/data/data_test1-output \
-mapper $dir/calBitmap_mapper.py \
-reducer $dir/calBitmap_reducer.py \
-partitioner org.apache.hadoop.mapred.lib.KeyFieldBasedPartitioner
最佳答案
我找到了解决我的错误的方法。正是在mapper中,我对其他类型的输入没有特别注意。我的某些输入的前几行是注释,因此,由于索引超出范围,部分数组失败。为了解决这个问题,我添加了一个检查:
if len(portions) == 5: #make sure it has 5 elements in there
print '%s\t%s\t%s\t%s\t%s' % (block,portions[1],portions[2],portions[3],portions[4])
关于python - 尽管python脚本在本地工作,但运行MapReduce代码时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28513455/
我正在处理一个处理大量数据的项目,所以我最近发现了 MapReduce,在我进一步深入研究之前,我想确保我的期望是正确的。 与数据的交互将通过 Web 界面进行,因此响应时间在这里至关重要,我认为 1
我正在阅读有关 Hadoop 以及它的容错性的文章。我阅读了 HDFS 并阅读了如何处理主节点和从节点的故障。但是,我找不到任何提及 mapreduce 如何执行容错的文档。特别是,当包含 Job T
我正在尝试在我的 Ubuntu 桌面上使用最新的 Hadoop 版本 2.6.0、Java SDK 1.70 来模拟 Hadoop 环境。我用必要的环境参数配置了 hadoop,它的所有进程都已启动并
就目前情况而言,这个问题不太适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、民意调查或扩展讨论。如果您觉得这个问题可以改进并可能重新开放,visit
我只是想针对我们正在做的一些数据分析工作来评估 HBase。 HBase 将包含我们的事件数据。键为 eventId + 时间。我们想要对日期范围内的几种事件类型 (4-5) 进行分析。事件类型总数约
是否有一种快速算法可以在 MapReduce 框架上运行以从巨大的整数集中查找中位数? 最佳答案 我会这样做。这是顺序快速选择的一种并行版本。 (某些映射/归约工具可能不会让您轻松完成任务...) 从
我正在尝试对大型分布式数据集执行一些数值计算。该算法非常适合 MapReduce 模型,具有以下附加属性:与输入数据相比,映射步骤的输出尺寸较小。数据可以被视为只读,并且静态分布在节点上(故障转移时的
假设我在 RavenDb 中有给定的文档结构 public class Car { public string Manufacturer {get;set;} public int B
我刚刚开始使用 mongo 和 map/reduce,在使用 pymongo 时我遇到了以下错误,而在直接使用 mongo 命令行时我没有得到(我意识到有一个类似的问题这个,但我的似乎更基本)。 我直
*基本上我正在尝试按过去一小时内的得分对对象进行排序。 我正在尝试为我的数据库中的对象生成每小时投票总和。投票嵌入到每个对象中。对象架构如下所示: { _id: ObjectId sc
我们怎样才能使我们的 MapReduce 查询更快? 我们使用五节点 Riak 数据库集群构建了一个应用程序。 我们的数据模型由三个部分组成:比赛、联赛和球队。 比赛包含联赛和球队的链接: 型号 va
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 6 年前。
有没有什么方法可以在运行时获取应用程序 ID - 例如 - 带有 yarn 的 wordcount 示例命令? 我希望使用 yarn 从另一个进程启 Action 业命令,并通过 YARN REST
如何在Hadoop Map-reduce程序中使用机器学习算法?我想使用分类算法、决策树、聚类算法。除了 Mahout 之外,请提出一些想法。 最佳答案 您可以编写自己的MapReduce程序,并在m
虽然 MapReduce 可能不是实现图像处理中使用的算法的最佳方式,但出于好奇,如果我作为初学者尝试使用它们,这将是最简单的实现方式。 最佳答案 Hadoop 非常适合处理大量 IO。因此,例如,您
我只是想验证我对这些参数及其关系的理解,如果我错了请通知我。 mapreduce.reduce.shuffle.input.buffer.percent 告诉分配给 reducer 的整个洗牌阶段的内
HBase 需要 mapreduce/yarn,还是只需要 hdfs? 对于 HBase 的基本用法,例如创建表、插入数据、扫描/获取数据,我看不出有任何理由使用 mapreduce/yarn。 请帮
我问了一些关于提高 Hive 查询性能的问题。一些答案与映射器和化简器的数量有关。我尝试了多个映射器和化简器,但在执行过程中没有发现任何差异。不知道为什么,可能是我没有以正确的方式去做,或者我错过了别
我是 mapreduce 和 hadoop 的新手。我阅读了 mapreduce 的示例和设计模式... 好的,我们可以进入正题了。我们正在开发一种软件,可以监控系统并定期捕获它们的 CPU 使用
我正在使用 Microsoft MapReduce SDK 启动仅 Mapper 作业。 调用 hadoop.MapReduceJob.ExecuteJob 立即抛出“响应状态代码不表示成功:404(
我是一名优秀的程序员,十分优秀!