|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.pig.data.DataType
public class DataType
A class of static final values used to encode data type and a number of static helper funcitons for manipulating data objects. The data type values could be done as an enumeration, but it is done as byte codes instead to save creating objects.
Field Summary | |
---|---|
static byte |
BAG
|
static byte |
BIGCHARARRAY
|
static byte |
BOOLEAN
|
static byte |
BYTE
|
static byte |
BYTEARRAY
|
static byte |
CHARARRAY
|
static byte |
DOUBLE
|
static byte |
ERROR
|
static byte |
FLOAT
|
static byte |
GENERIC_WRITABLECOMPARABLE
|
static byte |
INTEGER
|
static byte |
INTERNALMAP
|
static byte |
LONG
|
static byte |
MAP
|
static byte |
NULL
|
static byte |
TUPLE
|
static byte |
UNKNOWN
|
Constructor Summary | |
---|---|
DataType()
|
Method Summary | |
---|---|
static int |
compare(Object o1,
Object o2)
/** Compare two objects to each other. |
static int |
compare(Object o1,
Object o2,
byte dt1,
byte dt2)
|
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)
|
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 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()
|
static Map<String,Byte> |
genNameToTypeMap()
|
static Map<Byte,String> |
genTypeToNameMap()
|
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)
|
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)
|
static String |
mapToString(Map<String,Object> m)
|
static byte |
mergeType(byte type1,
byte type2)
Merge types if possible |
static int |
numTypes()
|
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 Double |
toDouble(Object o)
If type of object is not known, use this method which in turns call toLong(object,type) after finding type. |
static Double |
toDouble(Object o,
byte type)
Force a data object to a Double, if possible. |
static Float |
toFloat(Object o)
If type of object is not known, use this method which in turns call toFloat(object,type) after finding type. |
static Float |
toFloat(Object o,
byte type)
Force a data object to a Float, if possible. |
static Integer |
toInteger(Object o)
If type of object is not known, use this method, which internally calls toInteger(object,type) |
static Integer |
toInteger(Object o,
byte type)
Force a data object to an Integer, if possible. |
static Long |
toLong(Object o)
If type of object is not known, use this method which in turns call toLong(object,type) after finding type. |
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)
If type of object is not known, use this method which in turns call toString(object,type) after finding type. |
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
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 BYTEARRAY
public static final byte CHARARRAY
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
Constructor Detail |
---|
public DataType()
Method Detail |
---|
public static byte findType(Object o)
o
- Object to test.
public static byte findType(Type t)
t
- Type to examine
public 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 code
public 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 schema
public static boolean isSchemaType(byte dataType)
dataType
- dataType to determine if it has a schema
public static int compare(Object o1, Object o2)
o1
- First objecto2
- Second object
public static int compare(Object o1, Object o2, byte dt1, byte dt2)
public static Integer toInteger(Object o, byte type) throws ExecException
ExecException
- if the type can't be forced to an Integer.public static Integer toInteger(Object o) throws ExecException
o
-
ExecException
public static Long toLong(Object o, byte type) throws ExecException
ExecException
- if the type can't be forced to a Long.public static Long toLong(Object o) throws ExecException
o
-
ExecException
public static Float toFloat(Object o, byte type) throws ExecException
ExecException
- if the type can't be forced to a Float.public static Float toFloat(Object o) throws ExecException
o
-
ExecException
public static Double toDouble(Object o, byte type) throws ExecException
ExecException
- if the type can't be forced to a Double.public static Double toDouble(Object o) throws ExecException
o
-
ExecException
public static String toString(Object o, byte type) throws ExecException
ExecException
- if the type can't be forced to a String.public static String toString(Object o) throws ExecException
o
-
ExecException
public static Map<String,Object> toMap(Object o) throws ExecException
ExecException
- if the type can't be forced to a Double.public static Tuple toTuple(Object o) throws ExecException
ExecException
- if the type can't be forced to a Double.public static DataBag toBag(Object o) throws ExecException
ExecException
- if the type can't be forced to a Double.public static void spillTupleContents(Tuple t, String label)
public static boolean isNumberType(byte t)
public static boolean isUsableType(byte t)
public static byte mergeType(byte type1, byte type2)
type1
- type2
-
public static String mapToString(Map<String,Object> m)
public static boolean equalByteArrays(byte[] lhs, byte[] rhs)
public static Schema.FieldSchema determineFieldSchema(ResourceSchema.ResourceFieldSchema rcFieldSchema) throws ExecException, FrontendException, SchemaMergeException
rcFieldSchema
- the rcFieldSchema we want translated
ExecException,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 determined
ExecException,FrontendException,SchemaMergeException
ExecException
FrontendException
SchemaMergeException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |