hadoop-mapreduce-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Armstrong <john.armstr...@ccri.com>
Subject Re: Can I use MapWritable as a key?
Date Wed, 20 Jul 2011 16:10:35 GMT
On Tue, 19 Jul 2011 17:02:32 -0700, Choonho Son <choonho.son@gmail.com>
wrote:
> is it possible job.setOutputKeyClass(MapWritable.class);

As others have said, MapWritable doesn't implement Comparable, so it can't
be used as a key.  The ArrayWritable of Texts is one idea, but I'd suggest
instead implementing your OWN WritableComparable class MyKey, which would
contain the four strings as member fields.

Just make a Plain Old Java Object, implement Writable by telling it how to
write and read the fields one at a time (and in the same order!), and
implement comparable as usual for POJOs (remember to override .equals() and
.hashCode() too!).  This way you get type-safety as well, and you know
exactly what your keys will look like.

Mime
View raw message