hadoop-mapreduce-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajesh putta <rajesh.p...@gmail.com>
Subject Re: Can I use MapWritable as a key?
Date Wed, 20 Jul 2011 05:24:30 GMT
As per my knowledege is concerned
MapWritable doesn't implement Comparable, so I think it cannot be used as a
key. If u want that functionality, then u have to have a subclass that
implements Comparable and there u will define your key comparison logic.or
the other option would be to use SortedMapWritable as key.

Thanks& Regards
Rajesh Putta
M Tech CSE

On Wed, Jul 20, 2011 at 5:32 AM, Choonho Son <choonho.son@gmail.com> wrote:

> I am newbie.
> Most of example shows that,
> job.setOutputKeyClass(Text.class);
> is it possible job.setOutputKeyClass(MapWritable.class);
> because my key is combination of values(src IP, src Port, dst Port,
> dst IP), so I want to use MapWritable as a key.
> example code is like:
> MapWritable mkey = new MapWritable();
> MapWritable mval = new MapWritable();
> mkey.put(new Text("sip"), new Text(array[3]));
> mkey.put(new Text("sport"), new Text(array[5]));
> mkey.put(new Text("proto"), new Text(array[7]));
> mkey.put(new Text("dport"), new Text(array[6]));
> mkey.put(new Text("dip"), new Text(array[4]));
> mval.put(new Text("bcount"), new IntWritable(bcount));
> mval.put(new Text("pcount"), new IntWritable(pcount));
> context.write(mkey, mval);

View raw message