public final class ObjectInspectorUtils extends Object
Modifier and Type | Class and Description |
---|---|
static class |
ObjectInspectorUtils.NullValueOption
This enum controls how we interpret null value when compare two objects.
|
static class |
ObjectInspectorUtils.ObjectInspectorCopyOption
This enum controls how we copy primitive objects.
|
static class |
ObjectInspectorUtils.ObjectInspectorObject
This class can be used to wrap Hive objects and put in HashMap or HashSet.
|
Modifier and Type | Method and Description |
---|---|
static int |
compare(Object[] o1,
ObjectInspector[] oi1,
Object[] o2,
ObjectInspector[] oi2)
Compare two arrays of objects with their respective arrays of
ObjectInspectors.
|
static int |
compare(Object[] o1,
ObjectInspector[] oi1,
Object[] o2,
ObjectInspector[] oi2,
boolean[] columnSortOrderIsDesc,
ObjectInspectorUtils.NullValueOption[] nullSortOrder) |
static int |
compare(Object o1,
ObjectInspector oi1,
Object o2,
ObjectInspector oi2)
Compare two objects with their respective ObjectInspectors.
|
static int |
compare(Object o1,
ObjectInspector oi1,
Object o2,
ObjectInspector oi2,
MapEqualComparer mapEqualComparer)
Compare two objects with their respective ObjectInspectors.
|
static int |
compare(Object o1,
ObjectInspector oi1,
Object o2,
ObjectInspector oi2,
MapEqualComparer mapEqualComparer,
ObjectInspectorUtils.NullValueOption nullValueOpt)
Compare two objects with their respective ObjectInspectors.
|
static int |
compareNull(Object o1,
Object o2) |
static boolean |
compareSupported(ObjectInspector oi)
Whether comparison is supported for this type.
|
static boolean |
compareTypes(ObjectInspector o1,
ObjectInspector o2)
Compares two types identified by the given object inspectors.
|
static void |
copyStructToArray(Object o,
ObjectInspector oi,
ObjectInspectorUtils.ObjectInspectorCopyOption objectInspectorOption,
Object[] dest,
int offset) |
static Object |
copyToStandardJavaObject(Object o,
ObjectInspector oi) |
static void |
copyToStandardObject(List<Object> result,
Object row,
StructObjectInspector soi,
ObjectInspectorUtils.ObjectInspectorCopyOption objectInspectorOption)
Copy fields in the input row to the output array of standard objects.
|
static Object[] |
copyToStandardObject(Object[] o,
ObjectInspector[] oi,
ObjectInspectorUtils.ObjectInspectorCopyOption objectInspectorOption)
Returns a deep copy of an array of objects
|
static Object |
copyToStandardObject(Object o,
ObjectInspector oi)
Returns a deep copy of the Object o that can be scanned by a
StandardObjectInspector returned by getStandardObjectInspector(oi).
|
static Object |
copyToStandardObject(Object o,
ObjectInspector oi,
ObjectInspectorUtils.ObjectInspectorCopyOption objectInspectorOption) |
static int |
getBucketHashCode(Object[] bucketFields,
ObjectInspector[] bucketFieldInspectors) |
static int |
getBucketHashCodeOld(Object[] bucketFields,
ObjectInspector[] bucketFieldInspectors)
Deprecated.
|
static int |
getBucketNumber(int hashCode,
int numberOfBuckets)
https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL+BucketedTables
|
static int |
getBucketNumber(Object[] bucketFields,
ObjectInspector[] bucketFieldInspectors,
int totalBuckets)
Computes the bucket number to which the bucketFields belong to
|
static int |
getBucketNumberOld(Object[] bucketFields,
ObjectInspector[] bucketFieldInspectors,
int totalBuckets)
Deprecated.
|
static ConstantObjectInspector |
getConstantObjectInspector(ObjectInspector oi,
Object value) |
static Field[] |
getDeclaredNonStaticFields(Class<?> c)
Get all the declared non-static fields of Class c.
|
static String |
getFieldNames(StructObjectInspector soi)
Get the list of field names as csv from a StructObjectInspector.
|
static String |
getFieldTypes(StructObjectInspector soi)
Get the list of field type as csv from a StructObjectInspector.
|
static String |
getObjectInspectorName(ObjectInspector oi)
Get the class names of the ObjectInspector hierarchy.
|
static ObjectInspector |
getStandardObjectInspector(ObjectInspector oi)
Get the corresponding standard ObjectInspector for an ObjectInspector.
|
static ObjectInspector[] |
getStandardObjectInspector(ObjectInspector[] ois,
ObjectInspectorUtils.ObjectInspectorCopyOption objectInspectorOption)
Get the corresponding standard ObjectInspector array for an array of ObjectInspector.
|
static ObjectInspector |
getStandardObjectInspector(ObjectInspector oi,
ObjectInspectorUtils.ObjectInspectorCopyOption objectInspectorOption) |
static StructField |
getStandardStructFieldRef(String fieldName,
List<? extends StructField> fields) |
static String |
getStandardStructTypeName(StructObjectInspector soi) |
static String |
getStandardUnionTypeName(UnionObjectInspector uoi) |
static int |
getStructSize(ObjectInspector oi) |
static String |
getTypeNameFromJavaClass(Type t)
Get the type name of the Java class.
|
static Object |
getWritableConstantValue(ObjectInspector oi) |
static ObjectInspector |
getWritableObjectInspector(ObjectInspector oi)
Ensures that an ObjectInspector is Writable.
|
static Boolean |
hasAllFieldsSettable(ObjectInspector oi) |
static boolean |
hasAllFieldsSettable(ObjectInspector oi,
Map<ObjectInspector,Boolean> oiSettableProperties) |
static int |
hashCode(Object o,
ObjectInspector objIns) |
static int |
hashCodeMurmur(Object o,
ObjectInspector objIns,
ByteBuffer byteBuffer) |
static boolean |
isConstantObjectInspector(ObjectInspector oi) |
static void |
partialCopyToStandardObject(List<Object> result,
Object row,
int startCol,
int numCols,
StructObjectInspector soi,
ObjectInspectorUtils.ObjectInspectorCopyOption objectInspectorOption)
Copy specified fields in the input row to the output array of standard objects.
|
static boolean |
supportsConstantObjectInspector(ObjectInspector oi) |
static int |
writableArrayHashCode(Object[] keys)
Calculates the hash code for array of Objects that contains writables.
|
public static int writableArrayHashCode(Object[] keys)
public static ObjectInspector getWritableObjectInspector(ObjectInspector oi)
public static ObjectInspector[] getStandardObjectInspector(ObjectInspector[] ois, ObjectInspectorUtils.ObjectInspectorCopyOption objectInspectorOption)
public static ObjectInspector getStandardObjectInspector(ObjectInspector oi)
public static ObjectInspector getStandardObjectInspector(ObjectInspector oi, ObjectInspectorUtils.ObjectInspectorCopyOption objectInspectorOption)
public static void partialCopyToStandardObject(List<Object> result, Object row, int startCol, int numCols, StructObjectInspector soi, ObjectInspectorUtils.ObjectInspectorCopyOption objectInspectorOption)
result
- output list of standard objects.row
- input row.startCol
- starting column number from the input row.numCols
- number of columns to copy.soi
- Object inspector for the to-be-copied columns.public static void copyToStandardObject(List<Object> result, Object row, StructObjectInspector soi, ObjectInspectorUtils.ObjectInspectorCopyOption objectInspectorOption)
result
- output list of standard objects.row
- input row.soi
- Object inspector for the to-be-copied columns.objectInspectorOption
- public static Object[] copyToStandardObject(Object[] o, ObjectInspector[] oi, ObjectInspectorUtils.ObjectInspectorCopyOption objectInspectorOption)
public static Object copyToStandardObject(Object o, ObjectInspector oi)
public static Object copyToStandardJavaObject(Object o, ObjectInspector oi)
public static int getStructSize(ObjectInspector oi) throws SerDeException
SerDeException
public static void copyStructToArray(Object o, ObjectInspector oi, ObjectInspectorUtils.ObjectInspectorCopyOption objectInspectorOption, Object[] dest, int offset) throws SerDeException
SerDeException
public static Object copyToStandardObject(Object o, ObjectInspector oi, ObjectInspectorUtils.ObjectInspectorCopyOption objectInspectorOption)
public static String getStandardStructTypeName(StructObjectInspector soi)
public static String getStandardUnionTypeName(UnionObjectInspector uoi)
public static StructField getStandardStructFieldRef(String fieldName, List<? extends StructField> fields)
public static Field[] getDeclaredNonStaticFields(Class<?> c)
public static String getObjectInspectorName(ObjectInspector oi)
public static int getBucketNumber(Object[] bucketFields, ObjectInspector[] bucketFieldInspectors, int totalBuckets)
bucketFields
- the bucketed fields of the rowbucketFieldInspectors
- the ObjectInspectors for each of the bucketed fieldstotalBuckets
- the number of buckets in the table@Deprecated public static int getBucketNumberOld(Object[] bucketFields, ObjectInspector[] bucketFieldInspectors, int totalBuckets)
bucketFields
- the bucketed fields of the rowbucketFieldInspectors
- the ObjectInspectors for each of the bucketed fieldstotalBuckets
- the number of buckets in the tablepublic static int getBucketNumber(int hashCode, int numberOfBuckets)
hashCode
- as produced by getBucketHashCode(Object[], ObjectInspector[])
@Deprecated public static int getBucketHashCodeOld(Object[] bucketFields, ObjectInspector[] bucketFieldInspectors)
bucketFields
- bucketFieldInspectors
- public static int hashCode(Object o, ObjectInspector objIns)
public static int getBucketHashCode(Object[] bucketFields, ObjectInspector[] bucketFieldInspectors)
public static int hashCodeMurmur(Object o, ObjectInspector objIns, ByteBuffer byteBuffer)
public static int compare(Object[] o1, ObjectInspector[] oi1, Object[] o2, ObjectInspector[] oi2)
public static int compare(Object[] o1, ObjectInspector[] oi1, Object[] o2, ObjectInspector[] oi2, boolean[] columnSortOrderIsDesc, ObjectInspectorUtils.NullValueOption[] nullSortOrder)
public static boolean compareSupported(ObjectInspector oi)
public static int compare(Object o1, ObjectInspector oi1, Object o2, ObjectInspector oi2)
public static int compare(Object o1, ObjectInspector oi1, Object o2, ObjectInspector oi2, MapEqualComparer mapEqualComparer)
public static int compare(Object o1, ObjectInspector oi1, Object o2, ObjectInspector oi2, MapEqualComparer mapEqualComparer, ObjectInspectorUtils.NullValueOption nullValueOpt)
public static String getFieldNames(StructObjectInspector soi)
public static String getFieldTypes(StructObjectInspector soi)
public static String getTypeNameFromJavaClass(Type t)
public static boolean compareTypes(ObjectInspector o1, ObjectInspector o2)
PRIMITIVE
type, the result
is the comparison of their type names.LIST
type, then the result
is recursive call to compare the type of list elements.MAP
type, then the result is a
recursive call to compare the map key and value types.STRUCT
type, then the result
is negative if they do not have the same number of fields. If they do have
the same number of fields, the result is a recursive call to compare each
of the field types.o1
- o2
- public static ConstantObjectInspector getConstantObjectInspector(ObjectInspector oi, Object value)
public static Object getWritableConstantValue(ObjectInspector oi)
public static boolean supportsConstantObjectInspector(ObjectInspector oi)
public static boolean isConstantObjectInspector(ObjectInspector oi)
public static Boolean hasAllFieldsSettable(ObjectInspector oi)
public static boolean hasAllFieldsSettable(ObjectInspector oi, Map<ObjectInspector,Boolean> oiSettableProperties)
oi
- - Input object inspectoroiSettableProperties
- - Lookup map to cache the result.(If no caching, pass null)Copyright © 2022 The Apache Software Foundation. All rights reserved.