hadoop-mapreduce-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aaron Kimball <aa...@cloudera.com>
Subject Re: InputFormat key and value class names
Date Fri, 15 Jan 2010 06:43:35 GMT
The K and V generic qualifiers will be erased at compile time; they're not
available at runtime. Given an instance of K or V (which will, of course, be
provided to your mapper), though, you can easily-enough get its class:

e.g.:

class MyMapper extends Mapper<K1, V1, K2, V2> {
  public void map (K1 k, V1 v, Context c) {
    Class<K1> keyClass = k.getClass();
  }
}

- Aaron

On Fri, Jan 8, 2010 at 10:19 AM, Bassam Tabbara <bassam@symform.com> wrote:

>  Given an InputFormat<K,V> what is the easiest way of retrieving the class
> name of K and V? Is reflection the only way?
>
>
>
> Thanks!
>
> Bassam
>
>
>

Mime
View raw message