Package io.debezium.connector.mysql
Class MySqlUnsignedIntegerConverter
- java.lang.Object
-
- io.debezium.connector.mysql.MySqlUnsignedIntegerConverter
-
public class MySqlUnsignedIntegerConverter extends Object
A converter API for MySQL Unsigned Integer types. It intends to convert any integer type value from binlog into the correct representation of unsigned numeric MySQL binlog stores unsigned numeric into this format: (insertion value - Maximum data type boundary - 1), therefore to calculate the correct unsigned numeric representation we will inverse the original calculation by applying this calculation: (insertion value + Maximum data type boundary + 1). Please see DBZ-228 for more info- Author:
- Omar Al-Safi
-
-
Field Summary
Fields Modifier and Type Field Description private static BigDecimal
BIGINT_CORRECTION
private static BigDecimal
BIGINT_MAX_VALUE
private static long
INT_CORRECTION
private static long
INT_MAX_VALUE
private static int
MEDIUMINT_CORRECTION
private static int
MEDIUMINT_MAX_VALUE
private static int
SMALLINT_CORRECTION
private static int
SMALLINT_MAX_VALUE
private static short
TINYINT_CORRECTION
private static short
TINYINT_MAX_VALUE
Maximum values for Unsigned Integer Types.
-
Constructor Summary
Constructors Modifier Constructor Description private
MySqlUnsignedIntegerConverter()
Private constructor
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static BigDecimal
convertUnsignedBigint(BigDecimal originalNumber)
Convert original value insertion of type 'BIGINT' into the correct BIGINT UNSIGNED representation Note: Unsigned BIGINT (16-bit) is represented in 'BigDecimal' data type.static long
convertUnsignedInteger(long originalNumber)
Convert original value insertion of type 'INT' into the correct INT UNSIGNED representation Note: Unsigned INT (32-bit) is represented in 'Long' 64-bit data type.static int
convertUnsignedMediumint(int originalNumber)
Convert original value insertion of type 'MEDIUMINT' into the correct MEDIUMINT UNSIGNED representation Note: Unsigned MEDIUMINT (32-bit) is represented in 'Integer' 32-bit data type since the MAX value of Unsigned MEDIUMINT 16777215 < Max value of Integer 2147483647static int
convertUnsignedSmallint(int originalNumber)
Convert original value insertion of type 'SMALLINT' into the correct SMALLINT UNSIGNED representation Note: Unsigned SMALLINT (16-bit) is represented in 'Integer' 32-bit data type.static short
convertUnsignedTinyint(short originalNumber)
Convert original value insertion of type 'TINYINT' into the correct TINYINT UNSIGNED representation Note: Unsigned TINYINT (8-bit) is represented in 'Short' 16-bit data type.
-
-
-
Field Detail
-
TINYINT_MAX_VALUE
private static final short TINYINT_MAX_VALUE
Maximum values for Unsigned Integer Types. Needed in order to calculate actual value of an Unsigned Integer Types from binlog value. Reference to {@link https://dev.mysql.com/doc/refman/5.7/en/integer-types.html}- See Also:
- Constant Field Values
-
SMALLINT_MAX_VALUE
private static final int SMALLINT_MAX_VALUE
- See Also:
- Constant Field Values
-
MEDIUMINT_MAX_VALUE
private static final int MEDIUMINT_MAX_VALUE
- See Also:
- Constant Field Values
-
INT_MAX_VALUE
private static final long INT_MAX_VALUE
- See Also:
- Constant Field Values
-
BIGINT_MAX_VALUE
private static final BigDecimal BIGINT_MAX_VALUE
-
TINYINT_CORRECTION
private static final short TINYINT_CORRECTION
- See Also:
- Constant Field Values
-
SMALLINT_CORRECTION
private static final int SMALLINT_CORRECTION
- See Also:
- Constant Field Values
-
MEDIUMINT_CORRECTION
private static final int MEDIUMINT_CORRECTION
- See Also:
- Constant Field Values
-
INT_CORRECTION
private static final long INT_CORRECTION
- See Also:
- Constant Field Values
-
BIGINT_CORRECTION
private static final BigDecimal BIGINT_CORRECTION
-
-
Method Detail
-
convertUnsignedTinyint
public static short convertUnsignedTinyint(short originalNumber)
Convert original value insertion of type 'TINYINT' into the correct TINYINT UNSIGNED representation Note: Unsigned TINYINT (8-bit) is represented in 'Short' 16-bit data type. Reference: https://kafka.apache.org/0102/javadoc/org/apache/kafka/connect/data/Schema.Type.html
-
convertUnsignedSmallint
public static int convertUnsignedSmallint(int originalNumber)
Convert original value insertion of type 'SMALLINT' into the correct SMALLINT UNSIGNED representation Note: Unsigned SMALLINT (16-bit) is represented in 'Integer' 32-bit data type. Reference: https://kafka.apache.org/0102/javadoc/org/apache/kafka/connect/data/Schema.Type.html
-
convertUnsignedMediumint
public static int convertUnsignedMediumint(int originalNumber)
Convert original value insertion of type 'MEDIUMINT' into the correct MEDIUMINT UNSIGNED representation Note: Unsigned MEDIUMINT (32-bit) is represented in 'Integer' 32-bit data type since the MAX value of Unsigned MEDIUMINT 16777215 < Max value of Integer 2147483647
-
convertUnsignedInteger
public static long convertUnsignedInteger(long originalNumber)
Convert original value insertion of type 'INT' into the correct INT UNSIGNED representation Note: Unsigned INT (32-bit) is represented in 'Long' 64-bit data type. Reference: https://kafka.apache.org/0102/javadoc/org/apache/kafka/connect/data/Schema.Type.html
-
convertUnsignedBigint
public static BigDecimal convertUnsignedBigint(BigDecimal originalNumber)
Convert original value insertion of type 'BIGINT' into the correct BIGINT UNSIGNED representation Note: Unsigned BIGINT (16-bit) is represented in 'BigDecimal' data type. Reference: https://kafka.apache.org/0102/javadoc/org/apache/kafka/connect/data/Schema.Type.html- Parameters:
originalNumber
-BigDecimal
the original insertion value- Returns:
BigDecimal
the correct representation of the original insertion value
-
-