• <tfoot id='Q8fhT'></tfoot>
    <i id='Q8fhT'><tr id='Q8fhT'><dt id='Q8fhT'><q id='Q8fhT'><span id='Q8fhT'><b id='Q8fhT'><form id='Q8fhT'><ins id='Q8fhT'></ins><ul id='Q8fhT'></ul><sub id='Q8fhT'></sub></form><legend id='Q8fhT'></legend><bdo id='Q8fhT'><pre id='Q8fhT'><center id='Q8fhT'></center></pre></bdo></b><th id='Q8fhT'></th></span></q></dt></tr></i><div id='Q8fhT'><tfoot id='Q8fhT'></tfoot><dl id='Q8fhT'><fieldset id='Q8fhT'></fieldset></dl></div>
    <legend id='Q8fhT'><style id='Q8fhT'><dir id='Q8fhT'><q id='Q8fhT'></q></dir></style></legend>

        <small id='Q8fhT'></small><noframes id='Q8fhT'>

          <bdo id='Q8fhT'></bdo><ul id='Q8fhT'></ul>
      1. 使用 ArrayWritable 的序列化似乎以一种有趣的方式

        时间:2023-09-26

        <small id='eIUWu'></small><noframes id='eIUWu'>

          <bdo id='eIUWu'></bdo><ul id='eIUWu'></ul>

              <tbody id='eIUWu'></tbody>
              • <legend id='eIUWu'><style id='eIUWu'><dir id='eIUWu'><q id='eIUWu'></q></dir></style></legend>
                <i id='eIUWu'><tr id='eIUWu'><dt id='eIUWu'><q id='eIUWu'><span id='eIUWu'><b id='eIUWu'><form id='eIUWu'><ins id='eIUWu'></ins><ul id='eIUWu'></ul><sub id='eIUWu'></sub></form><legend id='eIUWu'></legend><bdo id='eIUWu'><pre id='eIUWu'><center id='eIUWu'></center></pre></bdo></b><th id='eIUWu'></th></span></q></dt></tr></i><div id='eIUWu'><tfoot id='eIUWu'></tfoot><dl id='eIUWu'><fieldset id='eIUWu'></fieldset></dl></div>
              • <tfoot id='eIUWu'></tfoot>

                1. 本文介绍了使用 ArrayWritable 的序列化似乎以一种有趣的方式工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在使用 ArrayWritable,有时我需要检查 Hadoop 如何序列化 ArrayWritable,这就是我通过设置 job.setNumReduceTasks(0):

                  I was working with ArrayWritable, at some point I needed to check how Hadoop serializes the ArrayWritable, this is what I got by setting job.setNumReduceTasks(0):

                  0    IntArrayWritable@10f11b8
                  3    IntArrayWritable@544ec1
                  6    IntArrayWritable@fe748f
                  8    IntArrayWritable@1968e23
                  11    IntArrayWritable@14da8f4
                  14    IntArrayWritable@18f6235
                  

                  这是我使用的测试映射器:

                  and this is the test mapper that I was using:

                  public static class MyMapper extends Mapper<LongWritable, Text, LongWritable, IntArrayWritable> {
                  
                      public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
                          int red = Integer.parseInt(value.toString());
                          IntWritable[] a = new IntWritable[100];
                  
                          for (int i =0;i<a.length;i++){
                              a[i] = new IntWritable(red+i);
                          }
                  
                          IntArrayWritable aw = new IntArrayWritable();
                          aw.set(a);
                          context.write(key, aw);
                      }
                  }
                  

                  IntArrayWritable 取自 javadoc 中给出的示例:ArrayWritable.

                  IntArrayWritable is taken from the example given in the javadoc: ArrayWritable.

                  import org.apache.hadoop.io.ArrayWritable;
                  import org.apache.hadoop.io.IntWritable;
                  
                  public class IntArrayWritable extends ArrayWritable {
                      public IntArrayWritable() {
                          super(IntWritable.class);
                      }
                  }
                  

                  我实际上检查了 Hadoop 的源代码,这对我来说毫无意义.ArrayWritable 不应序列化类名,并且无法使用 6/7 十六进制值序列化 100 个 IntWritable 的数组.该应用程序实际上似乎工作得很好,并且reducer反序列化了正确的值......怎么了?我错过了什么?

                  I actually checked on the source code of Hadoop and this makes no sense to me. ArrayWritable should not serialize the class name and there is no way that an array of 100 IntWritable can be serialized using 6/7 hexadecimal values. The application actually seems to work just fine and the reducer deserializes the right values... What is happening? What am I missing?

                  推荐答案

                  问题是您从 MapReduce 作业获得的输出不是该数据的序列化版本.它被翻译成漂亮的打印字符串.

                  The problem is that the output you are getting from your MapReduce job is not the serialized version of that data. It is something that is translated into a pretty printed string.

                  当您将 reducer 的数量设置为零时,您的映射器现在通过输出格式传递,该格式将格式化您的数据,可能会将其转换为可读的字符串.它不会像要被减速器拾取一样将其序列化.

                  When you set the number of reducers to zero, your mappers now get passed through a output format, which will format your data, likely converting it to a readable string. It does not dump it out serialized as if it was going to be picked up by a reducer.

                  这篇关于使用 ArrayWritable 的序列化似乎以一种有趣的方式工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:在 Map reduce java 中跳过 .csv 的第一行 下一篇:Hadoop:JPS 找不到安装的 Java

                  相关文章

                  最新文章

                2. <tfoot id='LgIaA'></tfoot>
                  • <bdo id='LgIaA'></bdo><ul id='LgIaA'></ul>

                    <legend id='LgIaA'><style id='LgIaA'><dir id='LgIaA'><q id='LgIaA'></q></dir></style></legend>
                    <i id='LgIaA'><tr id='LgIaA'><dt id='LgIaA'><q id='LgIaA'><span id='LgIaA'><b id='LgIaA'><form id='LgIaA'><ins id='LgIaA'></ins><ul id='LgIaA'></ul><sub id='LgIaA'></sub></form><legend id='LgIaA'></legend><bdo id='LgIaA'><pre id='LgIaA'><center id='LgIaA'></center></pre></bdo></b><th id='LgIaA'></th></span></q></dt></tr></i><div id='LgIaA'><tfoot id='LgIaA'></tfoot><dl id='LgIaA'><fieldset id='LgIaA'></fieldset></dl></div>
                  1. <small id='LgIaA'></small><noframes id='LgIaA'>