org.apache.hadoop.hive.serde2.objectinspector.primitive
Class PrimitiveObjectInspectorUtils

java.lang.Object
  extended by org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils

public class PrimitiveObjectInspectorUtils
extends Object

ObjectInspectorFactory is the primary way to create new ObjectInspector instances. SerDe classes should call the static functions in this library to create an ObjectInspector to return to the caller of SerDe2.getObjectInspector().


Nested Class Summary
static class PrimitiveObjectInspectorUtils.PrimitiveTypeEntry
          TypeEntry stores information about a Hive Primitive TypeInfo.
 
Field Summary
static PrimitiveObjectInspectorUtils.PrimitiveTypeEntry booleanTypeEntry
           
static PrimitiveObjectInspectorUtils.PrimitiveTypeEntry byteTypeEntry
           
static PrimitiveObjectInspectorUtils.PrimitiveTypeEntry doubleTypeEntry
           
static PrimitiveObjectInspectorUtils.PrimitiveTypeEntry floatTypeEntry
           
static PrimitiveObjectInspectorUtils.PrimitiveTypeEntry intTypeEntry
           
static PrimitiveObjectInspectorUtils.PrimitiveTypeEntry longTypeEntry
           
static PrimitiveObjectInspectorUtils.PrimitiveTypeEntry shortTypeEntry
           
static PrimitiveObjectInspectorUtils.PrimitiveTypeEntry stringTypeEntry
           
static PrimitiveObjectInspectorUtils.PrimitiveTypeEntry unknownTypeEntry
           
static PrimitiveObjectInspectorUtils.PrimitiveTypeEntry voidTypeEntry
           
 
Constructor Summary
PrimitiveObjectInspectorUtils()
           
 
Method Summary
static boolean comparePrimitiveObjects(Object o1, PrimitiveObjectInspector oi1, Object o2, PrimitiveObjectInspector oi2)
          Compare 2 primitive objects.
static boolean comparePrimitiveObjectsWithConversion(Object o1, PrimitiveObjectInspector oi1, Object o2, PrimitiveObjectInspector oi2)
          Compare 2 Primitive Objects with their Object Inspector, conversions allowed.
static double convertPrimitiveToDouble(Object o, PrimitiveObjectInspector oi)
          Convert a primitive object to double.
static boolean getBoolean(Object o, PrimitiveObjectInspector oi)
          Get the boolean value out of a primitive object.
static byte getByte(Object o, PrimitiveObjectInspector oi)
          Get the byte value out of a primitive object.
static double getDouble(Object o, PrimitiveObjectInspector oi)
          Get the double value out of a primitive object.
static float getFloat(Object o, PrimitiveObjectInspector oi)
          Get the float value out of a primitive object.
static int getInt(Object o, PrimitiveObjectInspector oi)
          Get the integer value out of a primitive object.
static long getLong(Object o, PrimitiveObjectInspector oi)
          Get the long value out of a primitive object.
static short getShort(Object o, PrimitiveObjectInspector oi)
          Get the short value out of a primitive object.
static String getString(Object o, PrimitiveObjectInspector oi)
          Get the String value out of a primitive object.
static PrimitiveObjectInspectorUtils.PrimitiveTypeEntry getTypeEntryFromPrimitiveCategory(PrimitiveObjectInspector.PrimitiveCategory category)
          Get the typeName from a Java Primitive Type or Java PrimitiveClass.
static PrimitiveObjectInspectorUtils.PrimitiveTypeEntry getTypeEntryFromPrimitiveJava(Class<?> clazz)
          Get the TypeEntry for a Java Primitive Type or Java PrimitiveClass.
static PrimitiveObjectInspectorUtils.PrimitiveTypeEntry getTypeEntryFromPrimitiveJavaClass(Class<?> clazz)
          Get the TypeEntry for a Java Primitive Type or Java PrimitiveClass.
static PrimitiveObjectInspectorUtils.PrimitiveTypeEntry getTypeEntryFromPrimitiveJavaType(Class<?> clazz)
          Get the TypeEntry for a Java Primitive Type or Java PrimitiveClass.
static PrimitiveObjectInspectorUtils.PrimitiveTypeEntry getTypeEntryFromPrimitiveWritableClass(Class<?> clazz)
          Get the TypeEntry for a Primitive Writable Class.
static PrimitiveObjectInspectorUtils.PrimitiveTypeEntry getTypeEntryFromTypeName(String typeName)
          Get the TypeEntry for a Primitive Writable Class.
static String getTypeNameFromPrimitiveJava(Class<?> clazz)
          Get the typeName from a Java Primitive Type or Java PrimitiveClass.
static String getTypeNameFromPrimitiveWritable(Class<?> clazz)
          Get the typeName from a Primitive Writable Class.
static boolean isPrimitiveJava(Class<?> clazz)
          Whether the class is a Java Primitive type or a Java Primitive class.
static boolean isPrimitiveJavaClass(Class<?> clazz)
          Whether the class is a Java Primitive class.
static boolean isPrimitiveJavaType(Class<?> clazz)
          Whether the class is a Java Primitive type.
static boolean isPrimitiveWritableClass(Class<?> clazz)
          Whether the class is a Hive Primitive Writable class.
static Class<?> primitiveJavaTypeToClass(Class<?> clazz)
          Return Whether the class is a Java Primitive type or a Java Primitive class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stringTypeEntry

public static final PrimitiveObjectInspectorUtils.PrimitiveTypeEntry stringTypeEntry

booleanTypeEntry

public static final PrimitiveObjectInspectorUtils.PrimitiveTypeEntry booleanTypeEntry

intTypeEntry

public static final PrimitiveObjectInspectorUtils.PrimitiveTypeEntry intTypeEntry

longTypeEntry

public static final PrimitiveObjectInspectorUtils.PrimitiveTypeEntry longTypeEntry

floatTypeEntry

public static final PrimitiveObjectInspectorUtils.PrimitiveTypeEntry floatTypeEntry

voidTypeEntry

public static final PrimitiveObjectInspectorUtils.PrimitiveTypeEntry voidTypeEntry

doubleTypeEntry

public static final PrimitiveObjectInspectorUtils.PrimitiveTypeEntry doubleTypeEntry

byteTypeEntry

public static final PrimitiveObjectInspectorUtils.PrimitiveTypeEntry byteTypeEntry

shortTypeEntry

public static final PrimitiveObjectInspectorUtils.PrimitiveTypeEntry shortTypeEntry

unknownTypeEntry

public static final PrimitiveObjectInspectorUtils.PrimitiveTypeEntry unknownTypeEntry
Constructor Detail

PrimitiveObjectInspectorUtils

public PrimitiveObjectInspectorUtils()
Method Detail

primitiveJavaTypeToClass

public static Class<?> primitiveJavaTypeToClass(Class<?> clazz)
Return Whether the class is a Java Primitive type or a Java Primitive class.


isPrimitiveJava

public static boolean isPrimitiveJava(Class<?> clazz)
Whether the class is a Java Primitive type or a Java Primitive class.


isPrimitiveJavaType

public static boolean isPrimitiveJavaType(Class<?> clazz)
Whether the class is a Java Primitive type.


isPrimitiveJavaClass

public static boolean isPrimitiveJavaClass(Class<?> clazz)
Whether the class is a Java Primitive class.


isPrimitiveWritableClass

public static boolean isPrimitiveWritableClass(Class<?> clazz)
Whether the class is a Hive Primitive Writable class.


getTypeNameFromPrimitiveJava

public static String getTypeNameFromPrimitiveJava(Class<?> clazz)
Get the typeName from a Java Primitive Type or Java PrimitiveClass.


getTypeNameFromPrimitiveWritable

public static String getTypeNameFromPrimitiveWritable(Class<?> clazz)
Get the typeName from a Primitive Writable Class.


getTypeEntryFromPrimitiveCategory

public static PrimitiveObjectInspectorUtils.PrimitiveTypeEntry getTypeEntryFromPrimitiveCategory(PrimitiveObjectInspector.PrimitiveCategory category)
Get the typeName from a Java Primitive Type or Java PrimitiveClass.


getTypeEntryFromPrimitiveJava

public static PrimitiveObjectInspectorUtils.PrimitiveTypeEntry getTypeEntryFromPrimitiveJava(Class<?> clazz)
Get the TypeEntry for a Java Primitive Type or Java PrimitiveClass.


getTypeEntryFromPrimitiveJavaType

public static PrimitiveObjectInspectorUtils.PrimitiveTypeEntry getTypeEntryFromPrimitiveJavaType(Class<?> clazz)
Get the TypeEntry for a Java Primitive Type or Java PrimitiveClass.


getTypeEntryFromPrimitiveJavaClass

public static PrimitiveObjectInspectorUtils.PrimitiveTypeEntry getTypeEntryFromPrimitiveJavaClass(Class<?> clazz)
Get the TypeEntry for a Java Primitive Type or Java PrimitiveClass.


getTypeEntryFromPrimitiveWritableClass

public static PrimitiveObjectInspectorUtils.PrimitiveTypeEntry getTypeEntryFromPrimitiveWritableClass(Class<?> clazz)
Get the TypeEntry for a Primitive Writable Class.


getTypeEntryFromTypeName

public static PrimitiveObjectInspectorUtils.PrimitiveTypeEntry getTypeEntryFromTypeName(String typeName)
Get the TypeEntry for a Primitive Writable Class.


comparePrimitiveObjects

public static boolean comparePrimitiveObjects(Object o1,
                                              PrimitiveObjectInspector oi1,
                                              Object o2,
                                              PrimitiveObjectInspector oi2)
Compare 2 primitive objects. Conversion not allowed. Note that NULL does not equal to NULL according to SQL standard.


convertPrimitiveToDouble

public static double convertPrimitiveToDouble(Object o,
                                              PrimitiveObjectInspector oi)
                                       throws NumberFormatException
Convert a primitive object to double.

Throws:
NumberFormatException

comparePrimitiveObjectsWithConversion

public static boolean comparePrimitiveObjectsWithConversion(Object o1,
                                                            PrimitiveObjectInspector oi1,
                                                            Object o2,
                                                            PrimitiveObjectInspector oi2)
Compare 2 Primitive Objects with their Object Inspector, conversions allowed. Note that NULL does not equal to NULL according to SQL standard.


getBoolean

public static boolean getBoolean(Object o,
                                 PrimitiveObjectInspector oi)
                          throws NumberFormatException
Get the boolean value out of a primitive object. Note that NullPointerException will be thrown if o is null. Note that NumberFormatException will be thrown if o is not a valid number.

Throws:
NumberFormatException

getByte

public static byte getByte(Object o,
                           PrimitiveObjectInspector oi)
                    throws NumberFormatException
Get the byte value out of a primitive object. Note that NullPointerException will be thrown if o is null. Note that NumberFormatException will be thrown if o is not a valid number.

Throws:
NumberFormatException

getShort

public static short getShort(Object o,
                             PrimitiveObjectInspector oi)
                      throws NumberFormatException
Get the short value out of a primitive object. Note that NullPointerException will be thrown if o is null. Note that NumberFormatException will be thrown if o is not a valid number.

Throws:
NumberFormatException

getInt

public static int getInt(Object o,
                         PrimitiveObjectInspector oi)
                  throws NumberFormatException
Get the integer value out of a primitive object. Note that NullPointerException will be thrown if o is null. Note that NumberFormatException will be thrown if o is not a valid number.

Throws:
NumberFormatException

getLong

public static long getLong(Object o,
                           PrimitiveObjectInspector oi)
                    throws NumberFormatException
Get the long value out of a primitive object. Note that NullPointerException will be thrown if o is null. Note that NumberFormatException will be thrown if o is not a valid number.

Throws:
NumberFormatException

getDouble

public static double getDouble(Object o,
                               PrimitiveObjectInspector oi)
                        throws NumberFormatException
Get the double value out of a primitive object. Note that NullPointerException will be thrown if o is null. Note that NumberFormatException will be thrown if o is not a valid number.

Throws:
NumberFormatException

getFloat

public static float getFloat(Object o,
                             PrimitiveObjectInspector oi)
                      throws NumberFormatException
Get the float value out of a primitive object. Note that NullPointerException will be thrown if o is null. Note that NumberFormatException will be thrown if o is not a valid number.

Throws:
NumberFormatException

getString

public static String getString(Object o,
                               PrimitiveObjectInspector oi)
                        throws NumberFormatException
Get the String value out of a primitive object. Note that NullPointerException will be thrown if o is null. Note that NumberFormatException will be thrown if o is not a valid number.

Throws:
NumberFormatException


Copyright © 2009 The Apache Software Foundation