From f29cd13b46d9408dad732eedc74ed6e6850fda29 Mon Sep 17 00:00:00 2001 From: Jiri Pechanec Date: Thu, 29 Aug 2024 08:43:54 +0200 Subject: [PATCH] Version 0.31.0 with VECTOR support --- pom.xml | 2 +- .../shyiko/mysql/binlog/event/TableMapEventMetadata.java | 9 +++++++++ .../AbstractRowsEventDataDeserializer.java | 7 +++++++ .../mysql/binlog/event/deserialization/ColumnType.java | 1 + .../deserialization/TableMapEventDataDeserializer.java | 1 + .../TableMapEventMetadataDeserializer.java | 4 ++++ 6 files changed, 23 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a2d03906..82fcc266 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ io.debezium mysql-binlog-connector-java - 0.30.0 + 0.31.0 mysql-binlog-connector-java MySQL Binary Log connector diff --git a/src/main/java/com/github/shyiko/mysql/binlog/event/TableMapEventMetadata.java b/src/main/java/com/github/shyiko/mysql/binlog/event/TableMapEventMetadata.java index 8b4a48ec..a5a3ca4b 100644 --- a/src/main/java/com/github/shyiko/mysql/binlog/event/TableMapEventMetadata.java +++ b/src/main/java/com/github/shyiko/mysql/binlog/event/TableMapEventMetadata.java @@ -37,6 +37,7 @@ public class TableMapEventMetadata implements EventData { private DefaultCharset enumAndSetDefaultCharset; private List enumAndSetColumnCharsets; private BitSet visibility; + private List vectorDimensionality; public BitSet getSignedness() { return signedness; @@ -134,6 +135,14 @@ public void setVisibility(BitSet visibility) { this.visibility = visibility; } + public List getVectorDimensionality() { + return vectorDimensionality; + } + + public void setVectorDimensionality(List vectorDimensionality) { + this.vectorDimensionality = vectorDimensionality; + } + @Override public String toString() { final StringBuilder sb = new StringBuilder(); diff --git a/src/main/java/com/github/shyiko/mysql/binlog/event/deserialization/AbstractRowsEventDataDeserializer.java b/src/main/java/com/github/shyiko/mysql/binlog/event/deserialization/AbstractRowsEventDataDeserializer.java index 89971365..673daa50 100644 --- a/src/main/java/com/github/shyiko/mysql/binlog/event/deserialization/AbstractRowsEventDataDeserializer.java +++ b/src/main/java/com/github/shyiko/mysql/binlog/event/deserialization/AbstractRowsEventDataDeserializer.java @@ -197,6 +197,8 @@ protected Serializable deserializeCell(ColumnType type, int meta, int length, By return deserializeGeometry(meta, inputStream); case JSON: return deserializeJson(meta, inputStream); + case VECTOR: + return deserializeVector(meta, inputStream); default: throw new IOException("Unsupported type " + type); } @@ -403,6 +405,11 @@ protected Serializable deserializeBlob(int meta, ByteArrayInputStream inputStrea return inputStream.read(blobLength); } + protected Serializable deserializeVector(int meta, ByteArrayInputStream inputStream) throws IOException { + int vectorLength = inputStream.readInteger(meta); + return inputStream.read(vectorLength); + } + protected Serializable deserializeEnum(int length, ByteArrayInputStream inputStream) throws IOException { return inputStream.readInteger(length); } diff --git a/src/main/java/com/github/shyiko/mysql/binlog/event/deserialization/ColumnType.java b/src/main/java/com/github/shyiko/mysql/binlog/event/deserialization/ColumnType.java index cc8c9415..bb5e10f3 100644 --- a/src/main/java/com/github/shyiko/mysql/binlog/event/deserialization/ColumnType.java +++ b/src/main/java/com/github/shyiko/mysql/binlog/event/deserialization/ColumnType.java @@ -45,6 +45,7 @@ public enum ColumnType { TIMESTAMP_V2(17), DATETIME_V2(18), TIME_V2(19), + VECTOR(242), JSON(245), NEWDECIMAL(246), ENUM(247), diff --git a/src/main/java/com/github/shyiko/mysql/binlog/event/deserialization/TableMapEventDataDeserializer.java b/src/main/java/com/github/shyiko/mysql/binlog/event/deserialization/TableMapEventDataDeserializer.java index 7ba88bff..c55ece80 100644 --- a/src/main/java/com/github/shyiko/mysql/binlog/event/deserialization/TableMapEventDataDeserializer.java +++ b/src/main/java/com/github/shyiko/mysql/binlog/event/deserialization/TableMapEventDataDeserializer.java @@ -109,6 +109,7 @@ private int[] readMetadata(ByteArrayInputStream inputStream, byte[] columnTypes) case BLOB: case JSON: case GEOMETRY: + case VECTOR: metadata[i] = inputStream.readInteger(1); break; case BIT: diff --git a/src/main/java/com/github/shyiko/mysql/binlog/event/deserialization/TableMapEventMetadataDeserializer.java b/src/main/java/com/github/shyiko/mysql/binlog/event/deserialization/TableMapEventMetadataDeserializer.java index 226427b0..41398d63 100644 --- a/src/main/java/com/github/shyiko/mysql/binlog/event/deserialization/TableMapEventMetadataDeserializer.java +++ b/src/main/java/com/github/shyiko/mysql/binlog/event/deserialization/TableMapEventMetadataDeserializer.java @@ -128,6 +128,9 @@ public TableMapEventMetadata deserialize(ByteArrayInputStream inputStream, int n case VISIBILITY: result.setVisibility(readBooleanList(inputStream, nColumns)); break; + case VECTOR_DIMENSIONALITY: + result.setVectorDimensionality(readIntegers(inputStream)); + break; default: inputStream.enterBlock(remainingBytes); throw new IOException("Unsupported table metadata field type " + code); @@ -212,6 +215,7 @@ private enum MetadataFieldType { ENUM_AND_SET_DEFAULT_CHARSET(10), // Charsets of ENUM and SET columns ENUM_AND_SET_COLUMN_CHARSET(11), // Charsets of ENUM and SET columns VISIBILITY(12), // Column visibility (8.0.23 and newer) + VECTOR_DIMENSIONALITY(13), // Vector column dimensionality (9.0.0 and newer) UNKNOWN_METADATA_FIELD_TYPE( 128); // Returned with binlog-row-metadata=FULL from MySQL 8.0 in some cases