Package org.voltdb
Enum Class VoltType
- All Implemented Interfaces:
- Serializable,- Comparable<VoltType>,- Constable
Represents a type for a 
VoltTable column or a SQLStmt
 parameter.
 Note that types in the database don't map 1-1 with types in the
 Java Stored Procedure API. For example,
   VARBINARY has no equivalent java class -- just byte[].
   TIMESTAMP corresponds "best" to VoltDB.TimeStampType but
   also, conveniently, to java.sql.Types.TIMESTAMP.- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic final classSupport class to represent optional value length variability.Nested classes/interfaces inherited from class java.lang.EnumEnum.EnumDesc<E extends Enum<E>>
- 
Enum Constant SummaryEnum ConstantsEnum ConstantDescription8-byte signed 2s-complement long.Boolean type.4-byte long value representing DATEFixed precision=38, scale=12 storing sign and null-status in a preceding byte8-bytes in IEEE 754 "double format".Geography type, for geographical objects (polygons, etc)Point type, for a geographical point (long, lat)Special purpose internal type to describe expectations for parameters to statements that contain syntax like " integer_expr IN ? ".Special purpose internal type to describe expectations for parameters to statements that contain syntax like " varchar_expr IN ? ".4-byte signed 2s-complement integer.Used for uninitialized types in some places.Used to type java null values that have no type.Used for some literal constants parsed by our SQL parser.2-byte signed 2s-complement short.UTF-8 string with up to 32K chars.8-byte long value representing microseconds after the epoch.1-byte signed 2s-complement byte.Array of bytes of variable lengthVoltTable type for Procedure parameters
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final intSize in bytes of the maximum length for a VoltDB field value, presumably aSTRINGorVARBINARYstatic final intSize in characters of the maximum length for a VoltDB field value, using a worst-case estimate of 4 bytes per characterstatic final longNull value forBIGINT.static final org.voltdb.VoltType.NullDateSigilNull value forDATE.static final org.voltdb.VoltType.NullDecimalSigilNull value forDECIMAL.static final doubleNull value forFLOAT.static final org.voltdb.VoltType.NullGeographySigilNull value forGEOGRAPHY.static final intNull value forINTEGER.static final org.voltdb.VoltType.NullPointSigilNull value forGEOGRAPHY_POINT.static final shortNull value forSMALLINT.static final intLength value for a null string.static final org.voltdb.VoltType.NullStringOrVarbinarySigilNull value forSTRINGorVARBINARY.static final org.voltdb.VoltType.NullTimestampSigilNull value forTIMESTAMP.static final byteNull value forTINYINT.
- 
Method SummaryModifier and TypeMethodDescriptionbooleanacceptsArray(Class<?> arrayArgClass) Most VoltTypes are not compatible with an array-typed value.bytesToValue(byte[] value) Converts a byte array with type back to the original partition value.booleancanExactlyRepresentAnyValueOf(VoltType otherType) Indicate whether a value can be assigned to this type without loss of range or precision, important for index key and partition key initialization.static Class<?>classFromByteValue(byte value) Return the java class that is matched to the given value.Class<?>Return the java class that is matched to a givenVoltType.decodeValue(ByteBuffer buffer) Decode a on object of this type frombufferintThe size specifier for columns with a variable-length type is optional in a CREATE TABLE or ALTER TABLE statement.static VoltTypeget(byte val) Statically create an enum value from the corresponding byte.For JDBC, the name(s) of any type-specific parameter(s), e.g.Get the type that will be returned by JDBC's ResultSet.getObject(), which usually corresponds to to VoltTable.get(), except for timestamps.intGet the java.sql.Types type of this type.intGet the number of bytes required to store the fixed length type.intGet the number of bytes required to store the fixed length type.For JDBC, returns the prefix (if any, otherwise null) used with SQL literal constants of this type.For JDBC, returns the suffix (if any, otherwise null) used with SQL literal constants of this type.Non-integer numeric VoltTypes must override this method.intGet the maximum number of bytes required to store the typeReturns the maximum possible value for a numeric type, as a string.Non-integer numeric VoltTypes must override this method.intGet the minimum number of bytes required to store the typeReturns a string representing the most compatible Java class name corresponding to this VoltType.getName()Return the name of this type as a string.intVoltDB treats nullability as orthogonal to type, so all types are nullable.Get a value representing whichever null value is appropriate for the currentVoltTypeenum.intReturns the standard JDBC 'searchable' attribute.charGet a char that uniquely identifies a type.Integer[]Returns precision and radix of this type.bytegetValue()Gets the byte that corresponds to the VoltType (for serialization).static StringhumanReadableSize(int size) String representation ofMAX_VALUE_LENGTH.booleanIs this type an integer type? True forTINYINT,SMALLINT,INTEGER,BIGINT.static booleanisAvroRecord(Class<?> clazz) Tests whether a specified class is an Avro data record (a subclass of the generic Avro record class).booleanIs this type an integer type in the EE? True forTINYINT,SMALLINT,INTEGER,BIGINTandTIMESTAMP.booleanIndividual VoltTypes like String can override to enable this functionality.booleanIs the type a number and is it an exact value (no rounding errors)?booleanVoltTypes for indexable non-numeric values must override.booleanIs this type visible to JDBCbooleanisNumber()Tests whether this Volt type is numeric.booleanVoltTypes with special restrictions about uniqueness support must override.Numeric types are all signed types, so return false.booleanTests whether this type is a variable-length type.static booleanisVoltNullValue(Object obj) Tests whether a supplied value is the null value for this Volt type.Get the corresponding SQL type as for a givenVoltTypeenum.toString()Return the string representation of this type.static VoltTypetypeFromClass(Class<?> cls) Ascertain the most appropriateVoltTypegiven a java class.static VoltTypetypeFromObject(Object obj) Ascertain the most appropriateVoltTypegiven a java object.static VoltTypetypeFromString(String str) Converts string representations to an enum value.static VoltTypeReturns the enum constant of this class with the specified name.static VoltType[]values()Returns an array containing the constants of this enum class, in the order they are declared.static byte[]valueToBytes(Object obj) Converts the object into bytes for hashing.Class<?>Return the java class that is matched to a givenVoltType.Methods inherited from class java.lang.EnumcompareTo, describeConstable, equals, getDeclaringClass, hashCode, name, ordinal, valueOf
- 
Enum Constant Details- 
INVALIDUsed for uninitialized types in some places. Not a valid value for actual user data.
- 
NULLUsed to type java null values that have no type. Not a valid value for actual user data.
- 
NUMERICUsed for some literal constants parsed by our SQL parser. Not a valid value for actual user data. SeeDECIMALfor decimal type.
- 
TINYINT1-byte signed 2s-complement byte. Lowest value means NULL in the database.
- 
SMALLINT2-byte signed 2s-complement short. Lowest value means NULL in the database.
- 
INTEGER4-byte signed 2s-complement integer. Lowest value means NULL in the database.
- 
BIGINT8-byte signed 2s-complement long. Lowest value means NULL in the database.
- 
INLIST_OF_BIGINTSpecial purpose internal type to describe expectations for parameters to statements that contain syntax like " integer_expr IN ? ". This type most commonly occurs as an expected parameter type for such statements. It is not expected to ever be used as a VoltTable column type.
- 
FLOAT8-bytes in IEEE 754 "double format". Some NaN values may represent NULL in the database (TBD).
- 
STRINGUTF-8 string with up to 32K chars. The database supports char arrays and varchars but the API uses strings.
- 
INLIST_OF_STRINGSpecial purpose internal type to describe expectations for parameters to statements that contain syntax like " varchar_expr IN ? ". This type most commonly occurs as an expected parameter type for such statements. It is not expected to ever be used as a VoltTable column type.
- 
TIMESTAMP8-byte long value representing microseconds after the epoch. The epoch is Jan. 1 1970 00:00:00 GMT. Negative values represent time before the epoch. This covers roughly 4000BC to 8000AD.
- 
DATE4-byte long value representing DATE
- 
VOLTTABLEVoltTable type for Procedure parameters
- 
DECIMALFixed precision=38, scale=12 storing sign and null-status in a preceding byte
- 
BOOLEANBoolean type. Not (yet) a valid value for actual user data.
- 
VARBINARYArray of bytes of variable length
- 
GEOGRAPHY_POINTPoint type, for a geographical point (long, lat)
- 
GEOGRAPHYGeography type, for geographical objects (polygons, etc)
 
- 
- 
Field Details- 
MAX_VALUE_LENGTHpublic static final int MAX_VALUE_LENGTHSize in bytes of the maximum length for a VoltDB field value, presumably aSTRINGorVARBINARY- See Also:
 
- 
MAX_VALUE_LENGTH_IN_CHARACTERSpublic static final int MAX_VALUE_LENGTH_IN_CHARACTERSSize in characters of the maximum length for a VoltDB field value, using a worst-case estimate of 4 bytes per character- See Also:
 
- 
NULL_STRING_LENGTHpublic static final int NULL_STRING_LENGTHLength value for a null string.- See Also:
 
- 
NULL_TINYINTpublic static final byte NULL_TINYINTNull value forTINYINT.- See Also:
 
- 
NULL_SMALLINTpublic static final short NULL_SMALLINTNull value forSMALLINT.- See Also:
 
- 
NULL_INTEGERpublic static final int NULL_INTEGERNull value forINTEGER.- See Also:
 
- 
NULL_BIGINTpublic static final long NULL_BIGINTNull value forBIGINT.- See Also:
 
- 
NULL_FLOATpublic static final double NULL_FLOATNull value forFLOAT.- See Also:
 
- 
NULL_TIMESTAMPpublic static final org.voltdb.VoltType.NullTimestampSigil NULL_TIMESTAMPNull value forTIMESTAMP.
- 
NULL_DATEpublic static final org.voltdb.VoltType.NullDateSigil NULL_DATENull value forDATE.
- 
NULL_STRING_OR_VARBINARYpublic static final org.voltdb.VoltType.NullStringOrVarbinarySigil NULL_STRING_OR_VARBINARYNull value forSTRINGorVARBINARY.
- 
NULL_DECIMALpublic static final org.voltdb.VoltType.NullDecimalSigil NULL_DECIMALNull value forDECIMAL.
- 
NULL_POINTpublic static final org.voltdb.VoltType.NullPointSigil NULL_POINTNull value forGEOGRAPHY_POINT.
- 
NULL_GEOGRAPHYpublic static final org.voltdb.VoltType.NullGeographySigil NULL_GEOGRAPHYNull value forGEOGRAPHY.
 
- 
- 
Method Details- 
valuesReturns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
 
- 
valueOfReturns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class has no constant with the specified name
- NullPointerException- if the argument is null
 
- 
isAvroRecordTests whether a specified class is an Avro data record (a subclass of the generic Avro record class).- Parameters:
- clazz- the class to test
- Returns:
- true if clazzis the class of an Avro record
 
- 
humanReadableSizeString representation ofMAX_VALUE_LENGTH.- Parameters:
- size- The size you want to represent in human readable string.
- Returns:
- String representation of Size passed in.
 
- 
getValuepublic byte getValue()Gets the byte that corresponds to the VoltType (for serialization).- Returns:
- A byte representing the VoltType
 
- 
classFromTypeReturn the java class that is matched to a givenVoltType.- Returns:
- A java class object.
- Throws:
- RuntimeException- if a type doesn't have an associated class, such as- INVALID.
- See Also:
 
- 
classFromByteValueReturn the java class that is matched to the given value.- Parameters:
- value- of a VoltType as returned by- getValue()
- Returns:
- The java class.
 
- 
vectorClassFromTypeReturn the java class that is matched to a givenVoltType.- Returns:
- A java class object.
- Throws:
- RuntimeException- if a type doesn't have an associated class, such as- INVALID.
- See Also:
 
- 
getStatically create an enum value from the corresponding byte.- Parameters:
- val- A byte representing an enum value
- Returns:
- The appropriate enum value
 
- 
typeFromStringConverts string representations to an enum value.- Parameters:
- str- A string in the form "TYPENAME" or "VoltType.TYPENAME", e.g. "BIGINT" or "VoltType.VARCHAR"
- Returns:
- One of the valid instances of VoltType
 
- 
typeFromObjectAscertain the most appropriateVoltTypegiven a java object.- Parameters:
- obj- The java object to type.
- Returns:
- A VoltType.
- Throws:
- org.voltdb.VoltTypeException- if none applies.
- See Also:
 
- 
typeFromClassAscertain the most appropriateVoltTypegiven a java class.- Parameters:
- cls- The java class to type.
- Returns:
- A VoltType.
- Throws:
- org.voltdb.VoltTypeException- if none applies.
- See Also:
 
- 
toStringReturn the string representation of this type. Note thatVoltType.typeFromString(voltTypeInstance.toString) == voltTypeInstance.
- 
getNameReturn the name of this type as a string.- Returns:
- the name of the type
 
- 
isVariableLengthpublic boolean isVariableLength()Tests whether this type is a variable-length type.- Returns:
- true if variable length, false if fixed length
 
- 
getLengthInBytesForFixedTypespublic int getLengthInBytesForFixedTypes()Get the number of bytes required to store the fixed length type. Variable-length types will throw a RuntimeException.- Returns:
- An integer value representing a number of bytes.
 
- 
getLengthInBytesForFixedTypesWithoutCheckpublic int getLengthInBytesForFixedTypesWithoutCheck()Get the number of bytes required to store the fixed length type. Variable-length types will return -1.- Returns:
- An integer value representing a number of bytes.
 
- 
getMinLengthInBytespublic int getMinLengthInBytes()Get the minimum number of bytes required to store the type- Returns:
- An integer value representing a number of bytes.
 
- 
getMaxLengthInBytespublic int getMaxLengthInBytes()Get the maximum number of bytes required to store the type- Returns:
- An integer value representing a number of bytes.
 
- 
getLiteralPrefixFor JDBC, returns the prefix (if any, otherwise null) used with SQL literal constants of this type. Individual VoltTypes can override to enable this, typically to return a single quote.- Returns:
- null, or, if overridden for a type, the prefix string.
 
- 
getLiteralSuffixFor JDBC, returns the suffix (if any, otherwise null) used with SQL literal constants of this type. Individual VoltTypes can override to enable this, typically to return a single quote.- Returns:
- null, or, if overridden for a type, the suffix string
 
- 
getCreateParamsFor JDBC, the name(s) of any type-specific parameter(s), e.g. "max_length" used when defining sql columns of this type. FUTURE?: It's not clear what format the JDBC would expect if there were more than one -- maybe comma separated?- Returns:
- null for fixed-length types, usually "max_length" for variable length type
 
- 
isCaseSensitivepublic boolean isCaseSensitive()Individual VoltTypes like String can override to enable this functionality. Normally, other types ignore case when expressed as strings, like in hex values for varbinary, or wkt values for geo types.- Returns:
- false unless overridden for a case sensitivite type like String
 
- 
getMinimumScaleNon-integer numeric VoltTypes must override this method.- Returns:
- 0 for integer types, null for non-numeric, or some other value if overridden for a specific type like DECIMAL
 
- 
getMaximumScaleNon-integer numeric VoltTypes must override this method.- Returns:
- 0 for integer types, null for non-numeric, or some other value if overridden for a specific type like DECIMAL
 
- 
isIndexablepublic boolean isIndexable()VoltTypes for indexable non-numeric values must override.- Returns:
- true if the type is supported by VoltDB indexes
 
- 
isUniqueIndexablepublic boolean isUniqueIndexable()VoltTypes with special restrictions about uniqueness support must override.- Returns:
- true if the type is supported by VoltDB (assume)unique indexes
 
- 
acceptsArrayMost VoltTypes are not compatible with an array-typed value.- Parameters:
- arrayArgClass- a java array class like byte[] or String[]
- Returns:
- false, unless overridden to enable a specific VoltType (like VARBINARY) to support certain specific array types (like byte[]).
- See Also:
 
- 
toSQLStringGet the corresponding SQL type as for a givenVoltTypeenum. For example,STRINGwill probably convert to "VARCHAR".- Returns:
- A string representing the SQL type.
 
- 
isJdbcVisiblepublic boolean isJdbcVisible()Is this type visible to JDBC - Returns:
- JDBC visibility
 
- 
getJdbcSqlTypepublic int getJdbcSqlType()Get the java.sql.Types type of this type.- Returns:
- int representing SQL type of the VoltDB type.
 
- 
getNullablepublic int getNullable()VoltDB treats nullability as orthogonal to type, so all types are nullable.- Returns:
- the jdbc constant representing a nullable type
 
- 
getSearchablepublic int getSearchable()Returns the standard JDBC 'searchable' attribute.- Returns:
- searchable attribute as integer
 
- 
isUnsignedNumeric types are all signed types, so return false. isUnsigned is N/A to other types, so return null. If/when we support unsigned types, their VoltTypes should override this function to return true.- Returns:
- null for non-numeric types, false for numeric, unless overridden by a (hypothetical) unsigned numeric type
 
- 
getJdbcClassGet the type that will be returned by JDBC's ResultSet.getObject(), which usually corresponds to to VoltTable.get(), except for timestamps.- Returns:
- JDBC class name
 
- 
isExactNumericpublic boolean isExactNumeric()Is the type a number and is it an exact value (no rounding errors)?- Returns:
- true for integers and decimals. False for floats and strings and anything else
 
- 
isBackendIntegerTypepublic boolean isBackendIntegerType()Is this type an integer type in the EE? True forTINYINT,SMALLINT,INTEGER,BIGINTandTIMESTAMP.- Returns:
- True if integer type. False if not
 
- 
isAnyIntegerTypepublic boolean isAnyIntegerType()Is this type an integer type? True forTINYINT,SMALLINT,INTEGER,BIGINT.- Returns:
- True if integer type. False if not
 
- 
isNumberpublic boolean isNumber()Tests whether this Volt type is numeric.- Returns:
- true for numeric types, false otherwise
 
- 
canExactlyRepresentAnyValueOfIndicate whether a value can be assigned to this type without loss of range or precision, important for index key and partition key initialization.- Parameters:
- otherType- the type of value to be assigned to this
- Returns:
- true if exact representation possible
 
- 
getSignatureCharpublic char getSignatureChar()Get a char that uniquely identifies a type. Used to create concise schema signatures.- Returns:
- A char representing the type.
 
- 
getTypePrecisionAndRadixReturns precision and radix of this type.- Returns:
- two-element Integer array; Integer[0] is the column size and Integer[1] is the radix
 
- 
defaultLengthForVariableLengthTypepublic int defaultLengthForVariableLengthType()The size specifier for columns with a variable-length type is optional in a CREATE TABLE or ALTER TABLE statement. If no size is specified, VoltDB chooses a default size.- Returns:
- the default size for the given type
 
- 
getMostCompatibleJavaTypeNameReturns a string representing the most compatible Java class name corresponding to this VoltType.- Returns:
- simple name of Java class, or "(unknown?)"
 
- 
getMaxValueForKeyPaddingReturns the maximum possible value for a numeric type, as a string. Intended for use in determining the maximum width of a column when represented as a string.- Returns:
- maximum value for numeric types, or null
 
- 
getNullValueGet a value representing whichever null value is appropriate for the currentVoltTypeenum. For example, if this type isTINYINT, this will return a javabytewith value -128, which is the constant NULL_TINYINT in VoltDB.- Returns:
- A new final instance with value equal to null for a given type.
 
- 
isVoltNullValueTests whether a supplied value is the null value for this Volt type.- Parameters:
- obj- the value to be tested
- Returns:
- true if the value represents the null value
 
- 
valueToBytesConverts the object into bytes for hashing.- Parameters:
- obj- a value to be hashed
- Returns:
- a byte array representation of obj OR null if the obj is java null or any other Volt representation of a null value.
 
- 
bytesToValueConverts a byte array with type back to the original partition value. This is the inverse of @see VoltType#valueToBytes(Object) valueToBytes- Parameters:
- value- Byte array representation of partition parameter.
- Returns:
- Java object of the correct type.
 
- 
decodeValueDecode a on object of this type frombuffer- Parameters:
- buffer- to read object from
- Returns:
- Decoded object
- Throws:
- UnsupportedOperationException- if this type does not support decoding
 
 
-