Skip to content

Commit

Permalink
Backported bbba2c7 from master
Browse files Browse the repository at this point in the history
  • Loading branch information
shyiko committed Oct 6, 2016
1 parent 9e1a448 commit bdce04d
Show file tree
Hide file tree
Showing 10 changed files with 2,015 additions and 13 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
.idea
.iml
.DS_Store
target
target
.classpath
.project
.settings
.vagrant
6 changes: 4 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.github.shyiko</groupId>
<artifactId>mysql-binlog-connector-java</artifactId>
<version>0.3.2-SNAPSHOT</version>
<version>0.5.0</version>

<name>mysql-binlog-connector-java</name>
<description>MySQL Binary Log connector</description>
Expand Down Expand Up @@ -45,7 +45,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<vagrant.bin>vagrant</vagrant.bin>
<vagrant.integration.box>${basedir}/supplement/vagrant/mysql-5.6.12-sandbox-prepackaged</vagrant.integration.box>
<vagrant.integration.box>${basedir}/supplement/vagrant/mysql-5.7.15-sandbox-prepackaged</vagrant.integration.box>
</properties>

<dependencies>
Expand Down Expand Up @@ -207,6 +207,8 @@
-Dvagrant.integration.box=supplement/vagrant/mysql-5.5.27-sandbox-prepackaged
mvn -P coverage verify \
-Dvagrant.integration.box=supplement/vagrant/mysql-5.6.12-sandbox-prepackaged
mvn -P coverage verify \
-Dvagrant.integration.box=supplement/vagrant/mysql-5.7.15-sandbox-prepackaged

# submit coverage report to coveralls
mvn -P coverage coveralls:jacoco -DrepoToken=&lt;coveralls.io&gt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ protected Serializable deserializeCell(ColumnType type, int meta, int length, By
return deserializeSet(length, inputStream);
case GEOMETRY:
return deserializeGeometry(meta, inputStream);
case JSON:
return deserializeJson(meta, inputStream);
default:
throw new IOException("Unsupported type " + type);
}
Expand Down Expand Up @@ -333,6 +335,21 @@ protected Serializable deserializeGeometry(int meta, ByteArrayInputStream inputS
return inputStream.read(dataLength);
}

/**
* Deserialize the {@code JSON} value on the input stream, and return MySQL's internal binary representation
* of the JSON value. See {@link com.github.shyiko.mysql.binlog.event.deserialization.json.JsonBinary} for
* a utility to parse this binary representation into something more useful, including a string representation.
*
* @param meta the number of bytes in which the length of the JSON value is found first on the input stream
* @param inputStream the stream containing the JSON value
* @return the MySQL internal binary representation of the JSON value; may be null
* @throws IOException if there is a problem reading the input stream
*/
protected byte[] deserializeJson(int meta, ByteArrayInputStream inputStream) throws IOException {
int blobLength = inputStream.readInteger(4);
return inputStream.read(blobLength);
}

// checkstyle, please ignore ParameterNumber for the next line
protected Long asUnixTime(int year, int month, int day, int hour, int minute, int second, int millis) {
// https://dev.mysql.com/doc/refman/5.0/en/datetime.html
Expand Down Expand Up @@ -377,7 +394,7 @@ private static int[] split(long value, int divider, int length) {
/**
* see mysql/strings/decimal.c
*/
private static BigDecimal asBigDecimal(int precision, int scale, byte[] value) {
public static BigDecimal asBigDecimal(int precision, int scale, byte[] value) {
boolean positive = (value[0] & 0x80) == 0x80;
value[0] ^= 0x80;
if (!positive) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public enum ColumnType {
TIMESTAMP_V2(17),
DATETIME_V2(18),
TIME_V2(19),
JSON(245),
NEWDECIMAL(246),
ENUM(247),
SET(248),
Expand Down
Loading

0 comments on commit bdce04d

Please sign in to comment.