A class of static final values used to encode data type and a number of static helper functions 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.
| 49 | * creating objects. |
| 50 | */ |
| 51 | @InterfaceAudience.Public |
| 52 | @InterfaceStability.Stable |
| 53 | public class DataType { |
| 54 | // IMPORTANT! This list can be used to record values of data on disk, |
| 55 | // so do not change the values. You may strand user data. |
| 56 | // IMPORTANT! Order matters here, as compare() below uses the order to |
| 57 | // order unlike datatypes. Don't change this ordering. |
| 58 | // Spaced unevenly to leave room for new entries without changing |
| 59 | // values or creating order issues. |
| 60 | public static final byte UNKNOWN = 0; |
| 61 | public static final byte NULL = 1; |
| 62 | public static final byte BOOLEAN = 5; |
| 63 | public static final byte BYTE = 6; // internal use only |
| 64 | public static final byte INTEGER = 10; |
| 65 | public static final byte LONG = 15; |
| 66 | public static final byte FLOAT = 20; |
| 67 | public static final byte DOUBLE = 25; |
| 68 | public static final byte DATETIME = 30; |
| 69 | public static final byte BYTEARRAY = 50; |
| 70 | public static final byte CHARARRAY = 55; |
| 71 | public static final byte BIGINTEGER = 65; |
| 72 | public static final byte BIGDECIMAL = 70; |
| 73 | /** |
| 74 | * Internal use only. |
| 75 | */ |
| 76 | public static final byte BIGCHARARRAY = 60; //internal use only; for storing/loading chararray bigger than 64K characters in BinStorage |
| 77 | public static final byte MAP = 100; |
| 78 | public static final byte TUPLE = 110; |
| 79 | public static final byte BAG = 120; |
| 80 | |
| 81 | /** |
| 82 | * Internal use only; used to store WriteableComparable objects |
| 83 | * for creating ordered index in MergeJoin. Expecting a object that |
| 84 | * implements Writable interface and has default constructor |
| 85 | */ |
| 86 | public static final byte GENERIC_WRITABLECOMPARABLE = 123; |
| 87 | |
| 88 | /** |
| 89 | * Internal use only. |
| 90 | */ |
| 91 | public static final byte INTERNALMAP = 127; // internal use only; for maps that are object->object. Used by FindQuantiles. |
| 92 | public static final byte ERROR = -1; |
| 93 | |
| 94 | /** |
| 95 | * Determine the datatype of an object. |
| 96 | * @param o Object to test. |
| 97 | * @return byte code of the type, or ERROR if we don't know. |
| 98 | */ |
| 99 | public static byte findType(Object o) { |
| 100 | if (o == null) { |
| 101 | return NULL; |
| 102 | } |
| 103 | |
| 104 | // Try to put the most common first |
| 105 | if (o instanceof DataByteArray) { |
| 106 | return BYTEARRAY; |
| 107 | } else if (o instanceof String) { |
| 108 | return CHARARRAY; |
nothing calls this directly
no outgoing calls
no test coverage detected