@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.
AbstractRowsEventDataDeserializer| 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 Object |
convertEnumToString(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(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(long indexes,
String options) |
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 String |
extractEnumAndSetOptions(Column column,
boolean commaSeparated) |
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, convertBoolean, convertDateToEpochDays, convertDateToEpochDaysAsDate, convertDecimal, convertDouble, convertFloat, convertInteger, convertNumeric, convertReal, convertRowId, convertSmallInt, convertString, convertTimestampToEpochMicros, convertTimestampToEpochMillis, convertTimestampToEpochMillisAsDate, convertTimestampToEpochNanos, convertTimestampWithZone, convertTimeToMicrosPastMidnight, convertTimeToMillisPastMidnight, convertTimeToMillisPastMidnightAsDate, convertTimeToNanosPastMidnight, convertTimeWithZone, convertTinyInt, handleUnknownData, 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 usedpublic 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 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 nullprotected Object convertEnumToString(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 value; never nullprotected Object convertSetToString(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 nullprotected 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 otherwiseprotected String extractEnumAndSetOptions(Column column, boolean commaSeparated)
Copyright © 2016 JBoss by Red Hat. All rights reserved.