LongWritable are simply another basic type which over-rides both the Writable and WritableComparable interfaces. This means that the LongWritable type can be used a key or a value input or output. It for example could allow one to output decimal values from a mapper, and then average those values, and output them as a long to a file. Although this could be done using text and simply parsing out the value every time, its much easier, and efficient to use a long type.
In the WordCount example specifically, the key value is a LongWritable. This is becuase it reads in text files using TextInputFormat which uses offset within a file as a key, and the text read in starting at the offset, as the value. Having that as a key value is not useful for counting words, thus it is not used. This is simply the way this format is written, and one can write their own input format class to provide other useful functionality. Steve Han wrote: > > Hi there, > > In the example WordCount.java,in class Map code,no objects that were > created > by LongWritable and all work seems to be done by class Text.What is > LongWritable's affects to the implementation of class Map. > > Thanks a lot. > > -- > Regards, > Steve Han > Originale Inc. > > -- View this message in context: http://www.nabble.com/What-role-does-LongWritable-play-in-class-Map-implementation--tp16977287p16992735.html Sent from the Hadoop core-user mailing list archive at Nabble.com.
