Hi, Chris:
Here is my understand about the file split and Data block.
The HDFS will store your file into multi data blocks, each block will be 64M or 
128M depend on your setting. Of course, the file could contain multi records. 
So the boundary of the record won't match with the block boundary (in fact, 
most of them don't match).It is the responsibility of RecorderReader to figure 
that out. The RecorderReader will be given byte[] of the file split (or block) 
it should handle, and most likely the end of this block won't BE an end of 
Record. So when the RecorderReader read the end of block, it will ALSO continue 
to the first part of byte[] of next block, to build up a whole recorder of last 
one. Based on this contract, the RecorderReader instance which handles the next 
block, will ignore the first part of byte[], as they are just part of a 
previous recorder, and go straight to the starting point of next Record.
The above logic is all based on assuming that the file is split-able. I did a 
project with the log file could contain "embedded newline characters", so the 
TextInputFormat/LineRecorderReader coming from Hadoop won't work in this case, 
and I have to write my own InputFormat/RecorderReader to handle the above 
logic. To make File/InputFormat/RecorderReader support split-able is important 
for performance, as the data can be processed concurrently block by block. But 
some file format, especially compressing formats, like GZIP, do not support 
file split-able. In this case, each file can ONLY be handle by one mapper. If 
you want to store your data into Gzip format, maybe you want to control your 
file size, make it close to the block size.
For data stored in google protocol buffer, you probably have to write your own 
InputFormat/RecorderReader to make it split-able. You can consider LZO format, 
as it is compressing and also support split. You can search the elephant-bird, 
which is a framework from twitter to support google protocol buffer and lzo 
data format, make your life easier.
Thanks
Yong

Date: Sun, 10 Feb 2013 10:36:24 -0500
Subject: Confused about splitting
From: [email protected]
To: [email protected]

I'm a little confused about splitting and readers.
The data in my application is stored in files of google protocol buffers.  
There are multiple protocol buffers per file.  There have been a number of 
simple ways to put multiple protobufs in a single file, usually involving 
writing some kind of length field before.  We did something a little more 
complicated by defining a frame similar to HDLC: frames are enveloped by a 
flag, escapes provided so the flag can't occur within the frame; and there is a 
32-bit CRC-like checksum just before the closing flag.

The protobufs are all a type named RitRecord, and we have our own reader that's 
something like this:
   public interface RitRecordReader {      RitRecord getNext();
    }

The data collection appication stores these things in ordinary flat files (the 
whole thing is run through a GzipOutputFilter first, so the files are 
compressed).  I'm having trouble understanding how to best apply this to HDFS 
for map function consumption.  Our data collector writes 1 megabyte files, but 
I can combine them for map/reduce performance.  To avoid TOO much wasted space 
I was thinking about 16, 32, or 64 MB HDFS blocks (tbd).

What I don't get is this: suppose we have a long file that spans multiple HDFS 
blocks.  I think I end up with problems similar to this guy:
    http://blog.rguha.net/?p=293

where one of my RitRecord objects is half in one HDFS block and half in another 
HDFS block.  If the mapper is assigning tasks to nodes along HDFS blocks then 
I'm going to end up with a problem.  It's not yet clear to me how to solve 
this.  I could make the problem LESS likely with bigger blocks (like the 
default 128MB) but even then, the problem doesn't completely go away (for me, a 
>128MB file is unlikely but not impossible).

--Chris
                                          

Reply via email to