@Immutable public class MySqlValueConverters extends JdbcValueConverters
This class always uses UTC for the default time zone when converting values without timezone information to values that require
timezones. This is because MySQL TIMESTAMP values are always
stored in UTC (unlike DATETIME values) and
are replicated in this form. Meanwhile, the MySQL Binlog Client library will deserialize these as Timestamp values that have no timezone and, therefore, are presumed to be in UTC.
When the column is properly marked with a Types.TIMESTAMP_WITH_TIMEZONE type, the converters will need to convert
that Timestamp value into an OffsetDateTime using the default time zone, which always is UTC.
AbstractRowsEventDataDeserializerlogger| Constructor and Description |
|---|
MySqlValueConverters(boolean adaptiveTimePrecision)
Create a new instance that always uses UTC for the default time zone when converting values without timezone information
to values that require timezones.
|
MySqlValueConverters(boolean adaptiveTimePrecision,
ZoneOffset defaultOffset)
Create a new instance, and specify the time zone offset that should be used only when converting values without timezone
information to values that require timezones.
|
| Modifier and Type | Method and Description |
|---|---|
protected ByteOrder |
byteOrderOfBitType() |
protected Charset |
charsetFor(Column column)
Return the
Charset instance with the MySQL-specific character set name used by the given column. |
protected Object |
convertEnumToString(List<String> options,
Column column,
org.apache.kafka.connect.data.Field fieldDefn,
Object data)
Converts a value object for a MySQL
ENUM, which is represented in the binlog events as an integer value containing
the index of the enum option. |
ValueConverter |
converter(Column column,
org.apache.kafka.connect.data.Field fieldDefn) |
protected Object |
convertSetToString(List<String> options,
Column column,
org.apache.kafka.connect.data.Field fieldDefn,
Object data)
Converts a value object for a MySQL
SET, which is represented in the binlog events contain a long number in which
every bit corresponds to a different option. |
protected String |
convertSetValue(Column column,
long indexes,
List<String> options) |
protected Object |
convertString(Column column,
org.apache.kafka.connect.data.Field fieldDefn,
Charset columnCharset,
Object data)
|
protected Object |
convertYearToInt(Column column,
org.apache.kafka.connect.data.Field fieldDefn,
Object data)
Converts a value object for a MySQL
YEAR, which appear in the binlog as an integer though returns from
the MySQL JDBC driver as either a short or a Date. |
protected List<String> |
extractEnumAndSetOptions(Column column) |
protected String |
extractEnumAndSetOptionsAsString(Column column) |
protected boolean |
matches(String upperCaseTypeName,
String upperCaseMatch)
Determine if the uppercase form of a column's type exactly matches or begins with the specified prefix.
|
org.apache.kafka.connect.data.SchemaBuilder |
schemaBuilder(Column column) |
convertBigInt, convertBinary, convertBit, convertBits, convertBoolean, convertDateToEpochDays, convertDateToEpochDaysAsDate, convertDecimal, convertDouble, convertFloat, convertInteger, convertNumeric, convertReal, convertRowId, convertSmallInt, convertString, convertTimestampToEpochMicros, convertTimestampToEpochMillis, convertTimestampToEpochMillisAsDate, convertTimestampToEpochNanos, convertTimestampWithZone, convertTimeToMicrosPastMidnight, convertTimeToMillisPastMidnight, convertTimeToMillisPastMidnightAsDate, convertTimeToNanosPastMidnight, convertTimeWithZone, convertTinyInt, handleUnknownData, padLittleEndian, unexpectedBinarypublic MySqlValueConverters(boolean adaptiveTimePrecision)
adaptiveTimePrecision - true if the time, date, and timestamp values should be based upon the precision of the
database columns using io.debezium.time semantic types, or false if they should be fixed to
millisecond precision using Kafka Connect org.apache.kafka.connect.data logical types.public MySqlValueConverters(boolean adaptiveTimePrecision,
ZoneOffset defaultOffset)
adaptiveTimePrecision - true if the time, date, and timestamp values should be based upon the precision of the
database columns using io.debezium.time semantic types, or false if they should be fixed to
millisecond precision using Kafka Connect org.apache.kafka.connect.data logical types.defaultOffset - the zone offset that is to be used when converting non-timezone related values to values that do
have timezones; may be null if UTC is to be usedprotected ByteOrder byteOrderOfBitType()
byteOrderOfBitType in class JdbcValueConverterspublic org.apache.kafka.connect.data.SchemaBuilder schemaBuilder(Column column)
schemaBuilder in interface ValueConverterProviderschemaBuilder in class JdbcValueConverterspublic ValueConverter converter(Column column, org.apache.kafka.connect.data.Field fieldDefn)
converter in interface ValueConverterProviderconverter in class JdbcValueConvertersprotected Charset charsetFor(Column column)
Charset instance with the MySQL-specific character set name used by the given column.column - the column in which the character set is used; never nullCharset, or null if there is no mappingprotected Object convertString(Column column, org.apache.kafka.connect.data.Field fieldDefn, Charset columnCharset, Object data)
column - the column in which the value appearsfieldDefn - the field definition for the SourceRecord's Schema; never nullcolumnCharset - the Java character set in which column byte[] values are encoded; may not be nulldata - the data; may be nullIllegalArgumentException - if the value could not be converted but the column does not allow nullsprotected Object convertYearToInt(Column column, org.apache.kafka.connect.data.Field fieldDefn, Object data)
YEAR, which appear in the binlog as an integer though returns from
the MySQL JDBC driver as either a short or a Date.column - the column definition describing the data value; never nullfieldDefn - the field definition; never nulldata - the data object to be converted into a year literal integer value; never nullIllegalArgumentException - if the value could not be converted but the column does not allow nullsprotected Object convertEnumToString(List<String> options, Column column, org.apache.kafka.connect.data.Field fieldDefn, Object data)
ENUM, which is represented in the binlog events as an integer value containing
the index of the enum option. The MySQL JDBC driver returns a string containing the option,
so this method calculates the same.options - the characters that appear in the same order as defined in the column; may not be nullcolumn - the column definition describing the data value; never nullfieldDefn - the field definition; never nulldata - the data object to be converted into an ENUM literal String valueIllegalArgumentException - if the value could not be converted but the column does not allow nullsprotected Object convertSetToString(List<String> options, Column column, org.apache.kafka.connect.data.Field fieldDefn, Object data)
SET, which is represented in the binlog events contain a long number in which
every bit corresponds to a different option. The MySQL JDBC driver returns a string containing the comma-separated options,
so this method calculates the same.options - the characters that appear in the same order as defined in the column; may not be nullcolumn - the column definition describing the data value; never nullfieldDefn - the field definition; never nulldata - the data object to be converted into an SET literal String value; never nullIllegalArgumentException - if the value could not be converted but the column does not allow nullsprotected boolean matches(String upperCaseTypeName, String upperCaseMatch)
type contains the type name followed by parentheses.upperCaseTypeName - the upper case form of the column's type nameupperCaseMatch - the upper case form of the expected type or prefix of the type; may not be nulltrue if the type matches the specified type, or false otherwiseCopyright © 2016 JBoss by Red Hat. All rights reserved.