Try following:

partitionColumnValue = (String)(getters.get(i).get(tuple));

On Mon, May 9, 2016 at 10:59 AM, Yogi Devendra <yogideven...@apache.org>
wrote:

> Hi,
>
> I am using code similar to following for generating getters.
> ---
> Class<?> fqcn = tuple.getClass();
> getter = PojoUtils.createGetter(fqcn, "aPartyPhone", String.class);
> logger.debug("getter {}", getter.getClass().getCanonicalName());
> getters.add(getter);
> ---
>
> What should be the return type of this getter? And how should I use this
> getter? I am using it as follows:
> ---
> partitionColumnValue = ((Getter<Object, String>)getters.get(i)).get(tuple);
> ---
>
> and getting following exception.
> ---
> java.lang.ClassCastException: SC cannot be cast to
> com.datatorrent.lib.util.PojoUtils$Getter
> ---
>
> Can you suggest correct way of using this getter? Here is the debug log
> for the same.
> ---
> 2016-05-09 10:41:55,296 DEBUG
> com.datatorrent.contrib.hive.FSPojoToHiveOperator: type
> com.datatorrent.contrib.hive.FSPojoToHiveOperator.FIELD_TYPE
> 2016-05-09 10:41:55,296 DEBUG com.datatorrent.lib.util.PojoUtils: class
> com.datatorrent.solution.objects.CDR aPartyPhone class java.lang.String
> interface com.datatorrent.lib.util.PojoUtils$Getter
> 2016-05-09 10:41:55,296 DEBUG
> com.datatorrent.lib.expression.JavaExpressionParser:
> com.datatorrent.solution.objects.CDR does not have field aPartyPhone.
> Proceeding to locate a getter method.
> 2016-05-09 10:41:55,297 DEBUG com.datatorrent.lib.util.PojoUtils: code:
> return
> ((java.lang.String)((com.datatorrent.solution.objects.CDR)(object)).getAPartyPhone());
> 2016-05-09 10:41:55,300 DEBUG
> com.datatorrent.contrib.hive.FSPojoToHiveOperator: getter SC
> ---
>
> ~ Yogi
>

Reply via email to