Package io.debezium.connector.binlog
Class BinlogUnsignedIntegerConverter
java.lang.Object
io.debezium.connector.binlog.BinlogUnsignedIntegerConverter
A converter for unsigned integer types.
It is intended to convert any integer type value from binlog into the current representation of unsigned
numeric values. The binlog store unsigned numeric values as
insertion value - max data type boundary - 1,
therefore, to calculate the correct unsigned numeric representation, the calculation needs to be inverted
as insertion value + max data type boundary + 1.
See DBZ-228 for more information.- Author:
- Omar Al-Safi, Chris Cranford
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final BigDecimalprivate static final BigDecimalprivate static final longprivate static final longprivate static final intprivate static final intprivate static final intprivate static final intprivate static final shortprivate static final shortMaximum values for unsigned integer types, used to calculate actual value from binlog. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic BigDecimalconvertUnsignedBigint(BigDecimal originalNumber) Convert original value insertion of type 'BIGINT' into the correct BIGINT UNSIGNED representation Note: Unsigned BIGINT (64-bit) is represented in 'BigDecimal' data type.static longconvertUnsignedInteger(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 intconvertUnsignedMediumint(int originalNumber) Convert original value insertion of type 'MEDIUMINT' into the correct MEDIUMINT UNSIGNED representation Note: Unsigned MEDIUMINT (24-bit) is represented in 'Integer' 32-bit data type since the MAX value of Unsigned MEDIUMINT 16777215 < Max value of Integer 2147483647static intconvertUnsignedSmallint(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 shortconvertUnsignedTinyint(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 Details
-
TINYINT_MAX_VALUE
private static final short TINYINT_MAX_VALUEMaximum values for unsigned integer types, used to calculate actual value from binlog. See integer-types- See Also:
-
SMALLINT_MAX_VALUE
private static final int SMALLINT_MAX_VALUE- See Also:
-
MEDIUMINT_MAX_VALUE
private static final int MEDIUMINT_MAX_VALUE- See Also:
-
INT_MAX_VALUE
private static final long INT_MAX_VALUE- See Also:
-
BIGINT_MAX_VALUE
-
TINYINT_CORRECTION
private static final short TINYINT_CORRECTION- See Also:
-
SMALLINT_CORRECTION
private static final int SMALLINT_CORRECTION- See Also:
-
MEDIUMINT_CORRECTION
private static final int MEDIUMINT_CORRECTION- See Also:
-
INT_CORRECTION
private static final long INT_CORRECTION- See Also:
-
BIGINT_CORRECTION
-
-
Constructor Details
-
BinlogUnsignedIntegerConverter
private BinlogUnsignedIntegerConverter()
-
-
Method Details
-
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 (24-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
Convert original value insertion of type 'BIGINT' into the correct BIGINT UNSIGNED representation Note: Unsigned BIGINT (64-bit) is represented in 'BigDecimal' data type. Reference: https://kafka.apache.org/0102/javadoc/org/apache/kafka/connect/data/Schema.Type.html- Parameters:
originalNumber-BigDecimalthe original insertion value- Returns:
BigDecimalthe correct representation of the original insertion value
-