gpt4 book ai didi

Hadoop Map Reduce 索引越界

转载 作者:可可西里 更新时间:2023-11-01 15:29:01 26 4
gpt4 key购买 nike

我的程序对于较小的输入运行良好,但是当我增加输入的大小时,第 210 行 (context.nextKeyValue();) 似乎抛出 indexoutofbounds 异常。下面是映射器的设置方法。我在那里调用 nextkeyvalue 一次,因为每个文件的第一行是一个标题。由于标题,拆分文件设置为 false。跟内存有关系吗?如何解决?

即使我已将 maxmapattempt 设置为 3,下面的错误消息也会显示 68 次。顺便说一句,有 55 次拆分。它不应该显示 55 次或者 55*3 吗?或者也许只有 3 个?它是如何工作的?

@Override
protected void setup(Context context) throws IOException, InterruptedException
{
Configuration conf = context.getConfiguration();
DupleSplit fileSplit = (DupleSplit)context.getInputSplit();
//first line is header. Indicates the first digit of the solution.
context.nextKeyValue(); <---- LINE 210
URI[] uris = context.getCacheFiles();

int num_of_colors = Integer.parseInt(conf.get("num_of_colors"));
int order = fileSplit.get_order();
int first_digit = Integer.parseInt(context.getCurrentValue().toString());

//perm_path = conf.get(Integer.toString(num_of_colors - order -1));
int offset = Integer.parseInt(conf.get(Integer.toString(num_of_colors - order -1)));
uri = uris[offset];
Path perm_path = new Path(uri.getPath());
perm_name = perm_path.getName().toString();

String pair_variables = "";
for (int i=1; i<=num_of_colors; i++)
pair_variables += "X_" + i + "_" + (num_of_colors - order) + "\t";
for (int i=1; i<num_of_colors; i++)
pair_variables += "X_" + i + "_" + (num_of_colors - order - first_digit) + "\t";
pair_variables += "X_" + num_of_colors + "_" + (num_of_colors - order - first_digit);
context.write(new Text(pair_variables), null);
}

这是错误日志:

Error: java.lang.IndexOutOfBoundsException
at java.nio.Buffer.checkBounds(Buffer.java:559)
at java.nio.ByteBuffer.get(ByteBuffer.java:668)
at java.nio.DirectByteBuffer.get(DirectByteBuffer.java:279)
at org.apache.hadoop.hdfs.RemoteBlockReader2.read(RemoteBlockReader2.java:168)
at org.apache.hadoop.hdfs.DFSInputStream$ByteArrayStrategy.doRead(DFSInputStream.java:775)
at org.apache.hadoop.hdfs.DFSInputStream.readBuffer(DFSInputStream.java:831)
at org.apache.hadoop.hdfs.DFSInputStream.readWithStrategy(DFSInputStream.java:891)
at org.apache.hadoop.hdfs.DFSInputStream.read(DFSInputStream.java:934)
at java.io.DataInputStream.read(DataInputStream.java:149)
at org.apache.hadoop.mapreduce.lib.input.UncompressedSplitLineReader.fillBuffer(UncompressedSplitLineReader.java:59)
at org.apache.hadoop.util.LineReader.readDefaultLine(LineReader.java:216)
at org.apache.hadoop.util.LineReader.readLine(LineReader.java:174)
at org.apache.hadoop.mapreduce.lib.input.UncompressedSplitLineReader.readLine(UncompressedSplitLineReader.java:91)
at org.apache.hadoop.mapreduce.lib.input.LineRecordReader.skipUtfByteOrderMark(LineRecordReader.java:144)
at org.apache.hadoop.mapreduce.lib.input.LineRecordReader.nextKeyValue(LineRecordReader.java:184)
at org.apache.hadoop.mapred.MapTask$NewTrackingRecordReader.nextKeyValue(MapTask.java:556)
at org.apache.hadoop.mapreduce.task.MapContextImpl.nextKeyValue(MapContextImpl.java:80)
at org.apache.hadoop.mapreduce.lib.map.WrappedMapper$Context.nextKeyValue(WrappedMapper.java:91)
at produce_data_hdfs$input_mapper.setup(produce_data_hdfs.java:210)
at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:143)
at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:787)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:341)
at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:164)
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:1657)
at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:158)

Container killed by the ApplicationMaster.
Container killed on request. Exit code is 143
Container exited with a non-zero exit code 143

最佳答案

我知道这已经晚了几年,但对于任何看到这个的人来说,Hadoop 2.6 有一个从 long 到 int 的不安全类型转换。在许多情况下,这会导致 IOOB 异常。我相信补丁是在 2.7.3 版本中发布的。您可以在 https://issues.apache.org/jira/browse/MAPREDUCE-6635 上阅读相关信息.我希望这可以帮助遇到此问题的任何人。

关于Hadoop Map Reduce 索引越界,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38284800/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com