【问题标题】:How data is constructed in files created by teragen in Hadoop?如何在 Hadoop 中由 teragen 创建的文件中构造数据?
【发布时间】:2023-01-30 01:15:17
【问题描述】:

我试图了解 terasort 的细节。使用Hadoop 的teragen 后,我可以成功创建输入数据文件。

许多在线文档说每一行都包含以下格式的数据:

<10 bytes key><10 bytes rowid><78 bytes filler>\r\n

因此,我下载了第一个文件part-m-00000,然后使用下面的命令将文件的rowid剪切出来:

cut -nb 11-20 part-m-00000 | od -c -w10 -Ad

但是,这是我得到的:

0000000  \0 021   0   0   0   0   0   0   0   0
0000010  \n   0   0   0   0   0   0   0   0   0
0000020   0  \n 021   0   0   0   0   0   0   0
0000030   0   0  \n   0   0   0   0   0   0   0
0000040   0   0   0  \n 021   0   0   0   0   0
0000050   0   0   0   0  \n 021   0   0   0   0
0000060   0   0   0   0   0  \n   0   0   0   0
0000070   0   0   0   0   0   0  \n 021   0   0
0000080   0   0   0   0   0   0   0  \n   0   0
0000090   0   0   0   0   0   0   0   0  \n   0
0000100   0   0   0   0   0   0   0   0   0  \n

显然,结果中并没有像我期望的那样增加行 ID。 我想知道我做错了什么吗?

请看一看,任何提示将不胜感激。谢谢!

【问题讨论】:

    标签: hadoop data-structures terasort


    【解决方案1】:

    我不确定你引用的是什么在线文档,但是TeraGen source code中的评论清楚地说明了生成记录的格式:

    /**
     * Generate the official GraySort input data set.
     * The user specifies the number of rows and the output directory and this
     * class runs a map/reduce program to generate the data.
     * The format of the data is:
     * <ul>
     * <li>(10 bytes key) (constant 2 bytes) (32 bytes rowid) 
     *     (constant 4 bytes) (48 bytes filler) (constant 4 bytes)
     * <li>The rowid is the right justified row id as a hex number.
     * </ul>
     *
     :
    

    我也想知道您正在查看什么文件,因为“常规”teragen 会生成这样的文件(行 ID 由我用“<<”标记):

    [hdfs@mygateway ~]# xxd part-m-00000 | head -40
    0000000: 4a69 6d47 7261 7952 4950 0011 3030 3030  JimGrayRIP..0000  << rowid 0
    0000010: 3030 3030 3030 3030 3030 3030 3030 3030  0000000000000000
    0000020: 3030 3030 3030 3030 3030 3030 8899 aabb  000000000000.... 
    0000030: 3232 3232 3030 3030 3232 3232 3030 3030  2222000022220000
    0000040: 3232 3232 3030 3030 3232 3232 3030 3030  2222000022220000
    0000050: 3232 3232 3030 3030 3030 3030 3131 3131  2222000000001111
    0000060: ccdd eeff 95e0 e482 62b3 edfe 0447 0011  ........b....G..
    0000070: 3030 3030 3030 3030 3030 3030 3030 3030  0000000000000000 << rowid 1 
    0000080: 3030 3030 3030 3030 3030 3030 3030 3031  0000000000000001
    0000090: 8899 aabb 3939 3939 3434 3434 3838 3838  ....999944448888
    00000a0: 3535 3535 4343 4343 3737 3737 3535 3535  5555CCCC77775555
    00000b0: 3535 3535 4242 4242 3636 3636 3434 3434  5555BBBB66664444
    00000c0: 3636 3636 ccdd eeff 4597 9353 dbed 5329  6666....E..S..S)
    00000d0: 365c 0011 3030 3030 3030 3030 3030 3030  6..000000000000 << rowid 2
    00000e0: 3030 3030 3030 3030 3030 3030 3030 3030  0000000000000000
    00000f0: 3030 3032 8899 aabb 4646 4646 3737 3737  0002....FFFF7777 
    0000100: 3939 3939 3535 3535 4646 4646 3131 3131  99995555FFFF1111
    0000110: 3232 3232 3939 3939 3838 3838 3434 3434  2222999988884444
    0000120: 4444 4444 4646 4646 ccdd eeff 882a 02c3  DDDDFFFF.....*..
    0000130: 1536 2b60 765f 0011 3030 3030 3030 3030  .6+`v_..00000000 << etc. etc.
    0000140: 3030 3030 3030 3030 3030 3030 3030 3030  0000000000000000
    0000150: 3030 3030 3030 3033 8899 aabb 3131 3131  00000003....1111
    0000160: 3030 3030 3030 3030 3030 3030 3636 3636  0000000000006666
    0000170: 3838 3838 4242 4242 3333 3333 3333 3333  8888BBBB33333333
    0000180: 4141 4141 3131 3131 4343 4343 ccdd eeff  AAAA1111CCCC....
    0000190: 5c90 ab38 ae52 8962 15d7 0011 3030 3030  ..8.R.b....0000
    00001a0: 3030 3030 3030 3030 3030 3030 3030 3030  0000000000000000
    00001b0: 3030 3030 3030 3030 3030 3034 8899 aabb  000000000004....
    00001c0: 4141 4141 4242 4242 4242 4242 3232 3232  AAAABBBBBBBB2222
    00001d0: 3434 3434 3434 3434 3939 3939 3535 3535  4444444499995555
    00001e0: 4242 4242 3131 3131 3838 3838 4444 4444  BBBB11118888DDDD
    00001f0: ccdd eeff 72dc 0ca5 1e33 3f32 4b7a 0011  ....r....3?2Kz..
    0000200: 3030 3030 3030 3030 3030 3030 3030 3030  0000000000000000
    0000210: 3030 3030 3030 3030 3030 3030 3030 3035  0000000000000005
    0000220: 8899 aabb 3838 3838 3333 3333 4242 4242  ....88883333BBBB
    0000230: 3838 3838 3838 3838 3434 3434 3737 3737  8888888844447777
    0000240: 3232 3232 3737 3737 3939 3939 3030 3030  2222777799990000
    0000250: 3232 3232 ccdd eeff 1043 1af6 a0d8 47b8  2222.....C....G.
    0000260: c55f 0011 3030 3030 3030 3030 3030 3030  ._..000000000000
    0000270: 3030 3030 3030 3030 3030 3030 3030 3030  0000000000000000
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-02-21
      • 1970-01-01
      • 2023-03-03
      • 2021-09-04
      • 1970-01-01
      • 1970-01-01
      • 2016-10-18
      相关资源
      最近更新 更多