Java SDK Documentation
23.4.0
|
Classes | |
enum | MetaType |
Public Member Functions | |
ByteBuffer | asBinaryBytes (Object value, int length, VerticaType type) |
Boolean | asBoolean (Object value, VerticaType type) |
ByteBuffer | asCharBytes (Object value, int length, VerticaType type) |
java.sql.Date | asDate (Object value, VerticaType type) |
Double | asDouble (Object value, VerticaType type) |
Long | asLong (Object value, VerticaType type) |
java.sql.Timestamp | asTimestamp (Object value, VerticaType type) |
Iterator< Object > | getListIterator (Object value) |
Iterator< Map.Entry< String, Object > > | getMapIterator (Object value) |
MetaType | getMetaType (Object value) |
Set< TypeCoercionPolicy > | getPolicy () |
void | setPolicy (Collection< TypeCoercionPolicy > policy) |
An interface which allows for intelligent casting from arbitrary Java Objects to appropriate types for consumption by Vertica. Several default implementations are provided, including:
ByteBuffer com.vertica.sdk.TypeCoercion.asBinaryBytes | ( | Object | value, |
int | length, | ||
VerticaType | type | ||
) |
Coerce a value to bytes. May return null, which is different than an empty array.
Note that the 'binary' type should be padded out to the full length.
value | The value being coerced. |
length | The length of the string-like type. |
type | The target Vertica type, which is a string-like type. |
Implemented in com.vertica.sdk.NoopTypeCoercion, and com.vertica.sdk.NullTypeCoercion.
Boolean com.vertica.sdk.TypeCoercion.asBoolean | ( | Object | value, |
VerticaType | type | ||
) |
Coerce a value to a Boolean. May return null.
value | The value being coerced. |
type | The target Vertica type, which is boolean. |
Implemented in com.vertica.sdk.StandardTypeCoercion, com.vertica.sdk.NoopTypeCoercion, and com.vertica.sdk.NullTypeCoercion.
ByteBuffer com.vertica.sdk.TypeCoercion.asCharBytes | ( | Object | value, |
int | length, | ||
VerticaType | type | ||
) |
Coerce a value to vertica-encoded string bytes. May return null, which is different than the empty string.
Note that the 'char' type should have trailing ASCII spaces removed. To implement this behavior, inspect the type
parameter with VerticaType#isChar().
value | The value to convert, which may be null. |
length | The maximum length (in bytes) of the result. |
type | The target Vertica type, which is some string-like type. |
Implemented in com.vertica.sdk.StandardTypeCoercion, com.vertica.sdk.NoopTypeCoercion, and com.vertica.sdk.NullTypeCoercion.
java.sql.Date com.vertica.sdk.TypeCoercion.asDate | ( | Object | value, |
VerticaType | type | ||
) |
Coerce a value to a Date. May return null.
Note that the java.sql.Date specification requires that the millisecond values wrapped by a java.sql.Date instance must be 'normalized' by setting the hours, minutes, seconds, and milliseconds to zero in the particular time zone with which the instance is associated.
However, that is not required by the Vertica SDK. This 'normalization' will take place later by internal components of the SDK.
value | The value being coerced. |
type | The target Vertica type. |
Implemented in com.vertica.sdk.StandardTypeCoercion, com.vertica.sdk.NoopTypeCoercion, and com.vertica.sdk.NullTypeCoercion.
Double com.vertica.sdk.TypeCoercion.asDouble | ( | Object | value, |
VerticaType | type | ||
) |
Coerce a value to a Double. May return null.
value | The value being coerced. |
type | The target Vertica type. |
Implemented in com.vertica.sdk.StandardTypeCoercion, com.vertica.sdk.NoopTypeCoercion, and com.vertica.sdk.NullTypeCoercion.
Long com.vertica.sdk.TypeCoercion.asLong | ( | Object | value, |
VerticaType | type | ||
) |
Coerce a value to a Long. May return null.
value | The value being coerced. |
type | The target Vertica type. |
Implemented in com.vertica.sdk.StandardTypeCoercion, com.vertica.sdk.NoopTypeCoercion, and com.vertica.sdk.NullTypeCoercion.
java.sql.Timestamp com.vertica.sdk.TypeCoercion.asTimestamp | ( | Object | value, |
VerticaType | type | ||
) |
Coerce a value to a Timestamp. May return null. This is used for timestamp and timestamptz Vertica types.
The timestamp is assumed to represent a moment in the UTC timezone, which is how Vertica stores all timestamp and timestamptz values internally. Implementations should handle any translations related to timezones.
Vertica has microsecond precision for timestamp values. Any further precision on the returned value is ignored.
value | The value being coerced. |
type | The target Vertica type. |
Implemented in com.vertica.sdk.StandardTypeCoercion, com.vertica.sdk.NoopTypeCoercion, and com.vertica.sdk.NullTypeCoercion.
Iterator<Object> com.vertica.sdk.TypeCoercion.getListIterator | ( | Object | value | ) |
Get an iterator of values from some list-like aggregate value. This is only invoked for values which getMetaType(Object) has returned MetaType#LIST.
value | A value that was previously identified as list-like type. |
Implemented in com.vertica.sdk.NoopTypeCoercion, and com.vertica.sdk.NullTypeCoercion.
Iterator<Map.Entry<String,Object> > com.vertica.sdk.TypeCoercion.getMapIterator | ( | Object | value | ) |
Get an iterator of values from some map-like aggregate value. This is only invoked for values which getMetaType(Object) has returned MetaType#MAP.
The elements must have only String keys. Otherwise a ClassCastException will be raised at a later time.
value | A value that was previously identified as map-like type. |
Implemented in com.vertica.sdk.NoopTypeCoercion, and com.vertica.sdk.NullTypeCoercion.
MetaType com.vertica.sdk.TypeCoercion.getMetaType | ( | Object | value | ) |
Determine what genre of type the given value is. This is used when handling aggregate data structures which may include nesting of other aggregate or non-aggregate types.
The response indicates if the given value is a scalar, list, or map type. Alternatively, a response of SKIP indicates that the value should be ignored, as if it did not exist.
value | The value of interest, which may be null. |
Implemented in com.vertica.sdk.NoopTypeCoercion, and com.vertica.sdk.NullTypeCoercion.
Set<TypeCoercionPolicy> com.vertica.sdk.TypeCoercion.getPolicy | ( | ) |
Returns an unmodifiable version of the policy.
Implemented in com.vertica.sdk.NullTypeCoercion.
void com.vertica.sdk.TypeCoercion.setPolicy | ( | Collection< TypeCoercionPolicy > | policy | ) |
Sets the policies for this TypeCoercion instance. Policies generally dictate which scenarios generate exceptions and allow for different error handling choices without implementing a new TypeCoercion class.
policy | The policy collection |
Implemented in com.vertica.sdk.NullTypeCoercion.