Enum PinotDataType

  • All Implemented Interfaces:
    Serializable, Comparable<PinotDataType>

    public enum PinotDataType
    extends Enum<PinotDataType>
    The PinotDataType enum represents the data type of a value in a row from recordReader and provides utility methods to convert value across types if applicable.

    We don't use PinotDataType to maintain type information, but use it to help organize the data and use FieldSpec.DataType to maintain type information separately across various readers.

    NOTE:

    • We will silently lose information if a conversion causes us to do so (e.g. DOUBLE to INT)
    • We will throw exception if a conversion is not possible (e.g. BOOLEAN to INT).
    • We will throw exception if the conversion throws exception (e.g. "foo" -> INT)
    • Enum Constant Detail

      • BOOLEAN

        public static final PinotDataType BOOLEAN
        When converting from BOOLEAN to other types: - Numeric types: - true -> 1 - false -> 0 - String: - true -> "true" - false -> "false" When converting to BOOLEAN from other types: - Numeric types: - 0 -> false - Others -> true - String: - "true" (case-insensitive) -> true - "1" -> true (for backward-compatibility where we used to use integer 1 to represent true) - Others -> false
      • TIMESTAMP

        public static final PinotDataType TIMESTAMP
        When converting from TIMESTAMP to other types: - LONG/DOUBLE: millis since epoch value - String: SQL timestamp format (e.g. "2021-01-01 01:01:01.001") When converting to TIMESTAMP from other types: - LONG/DOUBLE: read long value as millis since epoch - String: - SQL timestamp format (e.g. "2021-01-01 01:01:01.001") - Millis since epoch value (e.g. "1609491661001")
      • CHARACTER_ARRAY

        public static final PinotDataType CHARACTER_ARRAY
      • PRIMITIVE_INT_ARRAY

        public static final PinotDataType PRIMITIVE_INT_ARRAY
      • PRIMITIVE_LONG_ARRAY

        public static final PinotDataType PRIMITIVE_LONG_ARRAY
      • PRIMITIVE_FLOAT_ARRAY

        public static final PinotDataType PRIMITIVE_FLOAT_ARRAY
      • PRIMITIVE_DOUBLE_ARRAY

        public static final PinotDataType PRIMITIVE_DOUBLE_ARRAY
      • TIMESTAMP_ARRAY

        public static final PinotDataType TIMESTAMP_ARRAY
    • Method Detail

      • values

        public static PinotDataType[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (PinotDataType c : PinotDataType.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static PinotDataType valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • toInt

        public int toInt​(Object value)
        NOTE: override toInt(), toLong(), toFloat(), toDouble(), toBoolean(), toTimestamp(), toString(), and toBytes() for single-value types.
      • toLong

        public long toLong​(Object value)
      • toFloat

        public float toFloat​(Object value)
      • toDouble

        public double toDouble​(Object value)
      • toBoolean

        public boolean toBoolean​(Object value)
      • toBytes

        public byte[] toBytes​(Object value)
      • toPrimitiveIntArray

        public int[] toPrimitiveIntArray​(Object value)
      • toIntegerArray

        public Integer[] toIntegerArray​(Object value)
      • toPrimitiveLongArray

        public long[] toPrimitiveLongArray​(Object value)
      • toLongArray

        public Long[] toLongArray​(Object value)
      • toPrimitiveFloatArray

        public float[] toPrimitiveFloatArray​(Object value)
      • toFloatArray

        public Float[] toFloatArray​(Object value)
      • toPrimitiveDoubleArray

        public double[] toPrimitiveDoubleArray​(Object value)
      • toDoubleArray

        public Double[] toDoubleArray​(Object value)
      • toStringArray

        public String[] toStringArray​(Object value)
      • toBytesArray

        public byte[][] toBytesArray​(Object value)
      • toBooleanArray

        public boolean[] toBooleanArray​(Object value)
      • toInternal

        public Object toInternal​(Object value)
        Converts to the internal representation of the value.
        • BOOLEAN -> int
        • TIMESTAMP -> long
      • isSingleValue

        public boolean isSingleValue()
      • getPinotDataTypeForIngestion

        public static PinotDataType getPinotDataTypeForIngestion​(FieldSpec fieldSpec)
        Returns the PinotDataType for the given FieldSpec for data ingestion purpose. Returns object array type for multi-valued types.