Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Plain View
HDFS >> mail # user >> Re: Generic output key class


+
Sandy Ryza 2013-02-10, 19:07
Copy link to this message
-
Re: Generic output key class
Why not just write out the int as a numeric string?

On Feb 10, 2013, at 1:07 PM, Sandy Ryza <[EMAIL PROTECTED]> wrote:

> Hi Amit,
>
> One way to accomplish this would be to create a custom writable implementation, TextOrIntWritable, that has fields for both.  It could look something like:
>
> class TextOrIntWritable implements Writable {
>   private boolean isText;
>   private Text text;
>   private IntWritable integer;
>
>   void writeFields(DataOutput out) {
>     out.writeBoolean(isText);
>     if (isText) {
>       text.writeFields(out);
>     } else {
>       integer.writeFields(out);
>     }
>   }
>
>   [... readFields method that works in a similar way]
> }
>
> -Sandy
>
> On Sun, Feb 10, 2013 at 4:00 AM, Amit Sela <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> Has anyone ever used some kind of a "generic output key" for a mapreduce job ?
>
> I have a job running multiple tasks and I want them to be able to use both Text and IntWritable as output key classes.
>
> Any suggestions ?
>
> Thanks,
>
> Amit.
>

Michael Segel  | (m) 312.755.9623

Segel and Associates
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB