@InterfaceAudience.Public @InterfaceStability.Stable public class DataType extends Object
Modifier and Type | Field and Description |
---|---|
static byte |
BAG |
static byte |
BIGCHARARRAY
Internal use only.
|
static byte |
BIGDECIMAL |
static byte |
BIGINTEGER |
static byte |
BOOLEAN |
static byte |
BYTE |
static byte |
BYTEARRAY |
static byte |
CHARARRAY |
static byte |
DATETIME |
static byte |
DOUBLE |
static byte |
ERROR |
static byte |
FLOAT |
static byte |
GENERIC_WRITABLECOMPARABLE
Internal use only; used to store WriteableComparable objects
for creating ordered index in MergeJoin.
|
static byte |
INTEGER |
static byte |
INTERNALMAP
Internal use only.
|
static byte |
LONG |
static byte |
MAP |
static byte |
NULL |
static byte |
TUPLE |
static byte |
UNKNOWN |
Constructor and Description |
---|
DataType() |
Modifier and Type | Method and Description |
---|---|
static boolean |
castable(byte castType,
byte inputType)
Test if one type can cast to the other.
|
static int |
compare(Object o1,
Object o2)
/**
Compare two objects to each other.
|
static int |
compare(Object o1,
Object o2,
byte dt1,
byte dt2)
Same as
compare(Object, Object) , but does not use reflection to determine the type
of passed in objects, relying instead on the caller to provide the appropriate values, as
determined by findType(Object) . |
static Schema.FieldSchema |
determineFieldSchema(Object o)
Determine the field schema of an object
|
static Schema.FieldSchema |
determineFieldSchema(ResourceSchema.ResourceFieldSchema rcFieldSchema)
Determine the field schema of an ResourceFieldSchema
|
static boolean |
equalByteArrays(byte[] lhs,
byte[] rhs)
Test whether two byte arrays (Java byte arrays not Pig byte arrays) are
equal.
|
static byte |
findType(Object o)
Determine the datatype of an object.
|
static byte |
findType(Type t)
Given a Type object determine the data type it represents.
|
static byte |
findTypeByName(String name)
Get the type code from the type name
|
static Class<?> |
findTypeClass(byte dt) |
static String |
findTypeName(byte dt)
Get the type name from the type byte code
|
static String |
findTypeName(Object o)
Get the type name.
|
static byte[] |
genAllTypes()
Get an array of all type values.
|
static Map<String,Byte> |
genNameToTypeMap()
Get a map of type names to type values.
|
static Map<Byte,String> |
genTypeToNameMap()
Get a map of type values to type names.
|
static boolean |
isAtomic(byte dataType)
Determine whether the this data type is atomic.
|
static boolean |
isAtomic(Object o)
Determine whether the this data type is atomic.
|
static boolean |
isComplex(byte dataType)
Determine whether the this data type is complex.
|
static boolean |
isComplex(Object o)
Determine whether the object is complex or atomic.
|
static boolean |
isNumberType(byte t)
Determine if this type is a numeric type.
|
static boolean |
isSchemaType(byte dataType)
Determine whether the this data type can have a schema.
|
static boolean |
isSchemaType(Object o)
Determine whether the this object can have a schema.
|
static boolean |
isUsableType(byte t)
Determine if this is a type that can work can be done on.
|
static String |
mapToString(Map<String,Object> m)
Given a map, turn it into a String.
|
static byte |
mergeType(byte type1,
byte type2)
Merge types if possible.
|
static int |
numTypes()
Return the number of types Pig knows about.
|
static void |
spillTupleContents(Tuple t,
String label)
Purely for debugging
|
static DataBag |
toBag(Object o)
If this object is a bag, return it as a bag.
|
static BigDecimal |
toBigDecimal(Object o) |
static BigDecimal |
toBigDecimal(Object o,
byte type) |
static BigInteger |
toBigInteger(Object o) |
static BigInteger |
toBigInteger(Object o,
byte type) |
static Boolean |
toBoolean(Object o) |
static Boolean |
toBoolean(Object o,
byte type)
Force a data object to a Boolean, if possible.
|
static byte[] |
toBytes(Object o) |
static byte[] |
toBytes(Object o,
byte type) |
static org.joda.time.DateTime |
toDateTime(Object o) |
static org.joda.time.DateTime |
toDateTime(Object o,
byte type)
Force a data object to a DateTime, if possible.
|
static Double |
toDouble(Object o)
Force a data object to a Double, if possible.
|
static Double |
toDouble(Object o,
byte type)
Force a data object to a Double, if possible.
|
static Float |
toFloat(Object o)
Force a data object to a Float, if possible.
|
static Float |
toFloat(Object o,
byte type)
Force a data object to a Float, if possible.
|
static Integer |
toInteger(Object o)
Force a data object to an Integer, if possible.
|
static Integer |
toInteger(Object o,
byte type)
Force a data object to an Integer, if possible.
|
static Long |
toLong(Object o)
Force a data object to a Long, if possible.
|
static Long |
toLong(Object o,
byte type)
Force a data object to a Long, if possible.
|
static Map<String,Object> |
toMap(Object o)
If this object is a map, return it as a map.
|
static String |
toString(Object o)
Force a data object to a String, if possible.
|
static String |
toString(Object o,
byte type)
Force a data object to a String, if possible.
|
static Tuple |
toTuple(Object o)
If this object is a tuple, return it as a tuple.
|
public static final byte UNKNOWN
public static final byte NULL
public static final byte BOOLEAN
public static final byte BYTE
public static final byte INTEGER
public static final byte LONG
public static final byte FLOAT
public static final byte DOUBLE
public static final byte DATETIME
public static final byte BYTEARRAY
public static final byte CHARARRAY
public static final byte BIGINTEGER
public static final byte BIGDECIMAL
public static final byte BIGCHARARRAY
public static final byte MAP
public static final byte TUPLE
public static final byte BAG
public static final byte GENERIC_WRITABLECOMPARABLE
public static final byte INTERNALMAP
public static final byte ERROR
public static byte findType(Object o)
o
- Object to test.public static byte findType(Type t)
t
- Type to examinepublic static int numTypes()
public static byte[] genAllTypes()
public static Map<Byte,String> genTypeToNameMap()
public static Map<String,Byte> genNameToTypeMap()
public static String findTypeName(Object o)
o
- Object to test.public static String findTypeName(byte dt)
dt
- Type byte codepublic static Class<?> findTypeClass(byte dt)
public static byte findTypeByName(String name)
name
- Type namepublic static boolean isComplex(byte dataType)
dataType
- Data type code to test.public static boolean isComplex(Object o)
o
- Object to determine type of.public static boolean isAtomic(byte dataType)
dataType
- Data type code to test.public static boolean isAtomic(Object o)
o
- Object to determine type of.public static boolean isSchemaType(Object o)
o
- Object to determine if it has a schemapublic static boolean isSchemaType(byte dataType)
dataType
- dataType to determine if it has a schemapublic static int compare(Object o1, Object o2)
o1
- First objecto2
- Second objectpublic static int compare(Object o1, Object o2, byte dt1, byte dt2)
compare(Object, Object)
, but does not use reflection to determine the type
of passed in objects, relying instead on the caller to provide the appropriate values, as
determined by findType(Object)
.
Use this version in cases where multiple objects of the same type have to be repeatedly compared.o1
- first objecto2
- second objectdt1
- type, as byte value, of o1dt2
- type, as byte value, of o2public static byte[] toBytes(Object o) throws ExecException
ExecException
public static byte[] toBytes(Object o, byte type) throws ExecException
ExecException
public static Boolean toBoolean(Object o, byte type) throws ExecException
o
- object to casttype
- of the object you are castingExecException
- if the type can't be forced to a Boolean.public static Boolean toBoolean(Object o) throws ExecException
ExecException
public static Integer toInteger(Object o, byte type) throws ExecException
o
- object to casttype
- of the object you are castingExecException
- if the type can't be forced to an Integer.public static Integer toInteger(Object o) throws ExecException
toInteger(Object, byte)
this
method will first determine the type of o and then do the cast.
Use toInteger(Object, byte)
if you already know the type.o
- object to castExecException
- if the type can't be forced to an Integer.public static Long toLong(Object o, byte type) throws ExecException
o
- object to casttype
- of the object you are castingExecException
- if the type can't be forced to a Long.public static Long toLong(Object o) throws ExecException
toLong(Object, byte)
this
method will first determine the type of o and then do the cast.
Use toLong(Object, byte)
if you already know the type.o
- object to castExecException
- if the type can't be forced to an Long.public static Float toFloat(Object o, byte type) throws ExecException
o
- object to casttype
- of the object you are castingExecException
- if the type can't be forced to a Float.public static Float toFloat(Object o) throws ExecException
toFloat(Object, byte)
this
method will first determine the type of o and then do the cast.
Use toFloat(Object, byte)
if you already know the type.o
- object to castExecException
- if the type can't be forced to an Float.public static Double toDouble(Object o, byte type) throws ExecException
o
- object to casttype
- of the object you are castingExecException
- if the type can't be forced to a Double.public static org.joda.time.DateTime toDateTime(Object o, byte type) throws ExecException
o
- object to casttype
- of the object you are castingExecException
- if the type can't be forced to a Boolean.public static org.joda.time.DateTime toDateTime(Object o) throws ExecException
ExecException
public static Double toDouble(Object o) throws ExecException
toDouble(Object, byte)
this
method will first determine the type of o and then do the cast.
Use toDouble(Object, byte)
if you already know the type.o
- object to castExecException
- if the type can't be forced to an Double.public static BigInteger toBigInteger(Object o) throws ExecException
ExecException
public static BigInteger toBigInteger(Object o, byte type) throws ExecException
ExecException
public static BigDecimal toBigDecimal(Object o) throws ExecException
ExecException
public static BigDecimal toBigDecimal(Object o, byte type) throws ExecException
ExecException
public static String toString(Object o, byte type) throws ExecException
o
- object to casttype
- of the object you are castingExecException
- if the type can't be forced to a String.public static String toString(Object o) throws ExecException
toString(Object, byte)
this
method will first determine the type of o and then do the cast.
Use toString(Object, byte)
if you already know the type.o
- object to castExecException
- if the type can't be forced to a String.public static Map<String,Object> toMap(Object o) throws ExecException
o
- object to castExecException
- if the type can't be forced to a Double.public static Tuple toTuple(Object o) throws ExecException
o
- object to castExecException
- if the type can't be forced to a Double.public static DataBag toBag(Object o) throws ExecException
o
- object to castExecException
- if the type can't be forced to a Double.public static void spillTupleContents(Tuple t, String label)
public static boolean isNumberType(byte t)
t
- type (as byte value) to testpublic static boolean isUsableType(byte t)
t
- type (as a byte value) to testpublic static boolean castable(byte castType, byte inputType)
castType
- data type of the cast typeinputType
- data type of the inputpublic static byte mergeType(byte type1, byte type2)
type1
- type2
- public static String mapToString(Map<String,Object> m)
m
- mappublic static boolean equalByteArrays(byte[] lhs, byte[] rhs)
lhs
- byte array 1rhs
- byte array 2public static Schema.FieldSchema determineFieldSchema(ResourceSchema.ResourceFieldSchema rcFieldSchema) throws ExecException, FrontendException, SchemaMergeException
rcFieldSchema
- the rcFieldSchema we want translatedExecException,FrontendException,SchemaMergeException
ExecException
FrontendException
SchemaMergeException
public static Schema.FieldSchema determineFieldSchema(Object o) throws ExecException, FrontendException, SchemaMergeException
o
- the object whose field schema is to be determinedExecException,FrontendException,SchemaMergeException
ExecException
FrontendException
SchemaMergeException
Copyright © 2007-2017 The Apache Software Foundation