org.apache.hadoop.hive.ql.udf.generic
Class GenericUDFUtils.ReturnObjectInspectorResolver

java.lang.Object
  extended by org.apache.hadoop.hive.ql.udf.generic.GenericUDFUtils.ReturnObjectInspectorResolver
Enclosing class:
GenericUDFUtils

public static class GenericUDFUtils.ReturnObjectInspectorResolver
extends Object

This class helps to find the return ObjectInspector for a GenericUDF. In many cases like CASE and IF, the GenericUDF is returning a value out of several possibilities. However these possibilities may not always have the same ObjectInspector. This class will help detect whether all possibilities have exactly the same ObjectInspector. If not, then we need to convert the Objects to the same ObjectInspector. A special case is when some values are constant NULL. In this case we can use the same ObjectInspector.


Constructor Summary
GenericUDFUtils.ReturnObjectInspectorResolver()
           
GenericUDFUtils.ReturnObjectInspectorResolver(boolean allowTypeConversion)
           
 
Method Summary
 Object convertIfNecessary(Object o, ObjectInspector oi)
          Convert the return Object if necessary (when the ObjectInspectors of different possibilities are not all the same).
 ObjectInspector get()
          Returns the ObjectInspector of the return value.
 boolean update(ObjectInspector oi)
          Update returnObjectInspector and valueInspectorsAreTheSame based on the ObjectInspector seen.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericUDFUtils.ReturnObjectInspectorResolver

public GenericUDFUtils.ReturnObjectInspectorResolver()

GenericUDFUtils.ReturnObjectInspectorResolver

public GenericUDFUtils.ReturnObjectInspectorResolver(boolean allowTypeConversion)
Method Detail

update

public boolean update(ObjectInspector oi)
               throws UDFArgumentTypeException
Update returnObjectInspector and valueInspectorsAreTheSame based on the ObjectInspector seen.

Returns:
false if there is a type mismatch
Throws:
UDFArgumentTypeException

get

public ObjectInspector get()
Returns the ObjectInspector of the return value.


convertIfNecessary

public Object convertIfNecessary(Object o,
                                 ObjectInspector oi)
Convert the return Object if necessary (when the ObjectInspectors of different possibilities are not all the same).



Copyright © 2014 The Apache Software Foundation. All rights reserved.