com.github.shyiko.mysql.binlog.event.deserialization
Class AbstractRowsEventDataDeserializer<T extends EventData>

java.lang.Object
  extended by com.github.shyiko.mysql.binlog.event.deserialization.AbstractRowsEventDataDeserializer<T>
Type Parameters:
T - event data this deserializer is responsible for
All Implemented Interfaces:
EventDataDeserializer<T>
Direct Known Subclasses:
DeleteRowsEventDataDeserializer, UpdateRowsEventDataDeserializer, WriteRowsEventDataDeserializer

public abstract class AbstractRowsEventDataDeserializer<T extends EventData>
extends Object
implements EventDataDeserializer<T>

Whole class is basically a mix of open-replicator's AbstractRowEventParser and MySQLUtils. Main purpose here is to ease rows deserialization.

Current ColumnType to java type mapping is following:

 ColumnType.TINY: Integer
 ColumnType.SHORT: Integer
 ColumnType.LONG: Integer
 ColumnType.INT24: Integer
 ColumnType.YEAR: Integer
 ColumnType.ENUM: Integer
 ColumnType.SET: Long
 ColumnType.LONGLONG: Long
 ColumnType.FLOAT: Float
 ColumnType.DOUBLE: Double
 ColumnType.BIT: java.util.BitSet
 ColumnType.DATETIME: java.util.Date
 ColumnType.DATETIME_V2: java.util.Date
 ColumnType.NEWDECIMAL: java.math.BigDecimal
 ColumnType.TIMESTAMP: java.sql.Timestamp
 ColumnType.TIMESTAMP_V2: java.sql.Timestamp
 ColumnType.DATE: java.sql.Date
 ColumnType.TIME: java.sql.Time
 ColumnType.TIME_V2: java.sql.Time
 ColumnType.VARCHAR: String
 ColumnType.VAR_STRING: String
 ColumnType.STRING: String
 ColumnType.BLOB: byte[]
 ColumnType.GEOMETRY: byte[]
 
At the moment ColumnType.GEOMETRY is unsupported.

Author:
Stanley Shyiko

Constructor Summary
AbstractRowsEventDataDeserializer(Map<Long,TableMapEventData> tableMapEventByTableId)
           
 
Method Summary
static BigDecimal asBigDecimal(int precision, int scale, byte[] value)
          see mysql/strings/decimal.c
protected  Long asUnixTime(int year, int month, int day, int hour, int minute, int second, int millis)
           
protected  Serializable deserializeBit(int meta, ByteArrayInputStream inputStream)
           
protected  Serializable deserializeBlob(int meta, ByteArrayInputStream inputStream)
           
protected  Serializable deserializeCell(ColumnType type, int meta, int length, ByteArrayInputStream inputStream)
           
protected  Serializable deserializeDate(ByteArrayInputStream inputStream)
           
protected  Serializable deserializeDatetime(ByteArrayInputStream inputStream)
           
protected  Serializable deserializeDatetimeV2(int meta, ByteArrayInputStream inputStream)
           
protected  Serializable deserializeDouble(ByteArrayInputStream inputStream)
           
protected  Serializable deserializeEnum(int length, ByteArrayInputStream inputStream)
           
protected  Serializable deserializeFloat(ByteArrayInputStream inputStream)
           
protected  int deserializeFractionalSeconds(int meta, ByteArrayInputStream inputStream)
           
protected  Serializable deserializeGeometry(int meta, ByteArrayInputStream inputStream)
           
protected  Serializable deserializeInt24(ByteArrayInputStream inputStream)
           
protected  byte[] deserializeJson(int meta, ByteArrayInputStream inputStream)
          Deserialize the JSON value on the input stream, and return MySQL's internal binary representation of the JSON value.
protected  Serializable deserializeLong(ByteArrayInputStream inputStream)
           
protected  Serializable deserializeLongLong(ByteArrayInputStream inputStream)
           
protected  Serializable deserializeNewDecimal(int meta, ByteArrayInputStream inputStream)
           
protected  Serializable[] deserializeRow(long tableId, BitSet includedColumns, ByteArrayInputStream inputStream)
           
protected  Serializable deserializeSet(int length, ByteArrayInputStream inputStream)
           
protected  Serializable deserializeShort(ByteArrayInputStream inputStream)
           
protected  Serializable deserializeString(int length, ByteArrayInputStream inputStream)
           
protected  Serializable deserializeTime(ByteArrayInputStream inputStream)
           
protected  Serializable deserializeTimestamp(ByteArrayInputStream inputStream)
           
protected  Serializable deserializeTimestampV2(int meta, ByteArrayInputStream inputStream)
           
protected  Serializable deserializeTimeV2(int meta, ByteArrayInputStream inputStream)
           
protected  Serializable deserializeTiny(ByteArrayInputStream inputStream)
           
protected  Serializable deserializeVarString(int meta, ByteArrayInputStream inputStream)
           
protected  Serializable deserializeYear(ByteArrayInputStream inputStream)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.github.shyiko.mysql.binlog.event.deserialization.EventDataDeserializer
deserialize
 

Constructor Detail

AbstractRowsEventDataDeserializer

public AbstractRowsEventDataDeserializer(Map<Long,TableMapEventData> tableMapEventByTableId)
Method Detail

deserializeRow

protected Serializable[] deserializeRow(long tableId,
                                        BitSet includedColumns,
                                        ByteArrayInputStream inputStream)
                                 throws IOException
Throws:
IOException

deserializeCell

protected Serializable deserializeCell(ColumnType type,
                                       int meta,
                                       int length,
                                       ByteArrayInputStream inputStream)
                                throws IOException
Throws:
IOException

deserializeBit

protected Serializable deserializeBit(int meta,
                                      ByteArrayInputStream inputStream)
                               throws IOException
Throws:
IOException

deserializeTiny

protected Serializable deserializeTiny(ByteArrayInputStream inputStream)
                                throws IOException
Throws:
IOException

deserializeShort

protected Serializable deserializeShort(ByteArrayInputStream inputStream)
                                 throws IOException
Throws:
IOException

deserializeInt24

protected Serializable deserializeInt24(ByteArrayInputStream inputStream)
                                 throws IOException
Throws:
IOException

deserializeLong

protected Serializable deserializeLong(ByteArrayInputStream inputStream)
                                throws IOException
Throws:
IOException

deserializeLongLong

protected Serializable deserializeLongLong(ByteArrayInputStream inputStream)
                                    throws IOException
Throws:
IOException

deserializeFloat

protected Serializable deserializeFloat(ByteArrayInputStream inputStream)
                                 throws IOException
Throws:
IOException

deserializeDouble

protected Serializable deserializeDouble(ByteArrayInputStream inputStream)
                                  throws IOException
Throws:
IOException

deserializeNewDecimal

protected Serializable deserializeNewDecimal(int meta,
                                             ByteArrayInputStream inputStream)
                                      throws IOException
Throws:
IOException

deserializeDate

protected Serializable deserializeDate(ByteArrayInputStream inputStream)
                                throws IOException
Throws:
IOException

deserializeTime

protected Serializable deserializeTime(ByteArrayInputStream inputStream)
                                throws IOException
Throws:
IOException

deserializeTimeV2

protected Serializable deserializeTimeV2(int meta,
                                         ByteArrayInputStream inputStream)
                                  throws IOException
Throws:
IOException

deserializeTimestamp

protected Serializable deserializeTimestamp(ByteArrayInputStream inputStream)
                                     throws IOException
Throws:
IOException

deserializeTimestampV2

protected Serializable deserializeTimestampV2(int meta,
                                              ByteArrayInputStream inputStream)
                                       throws IOException
Throws:
IOException

deserializeDatetime

protected Serializable deserializeDatetime(ByteArrayInputStream inputStream)
                                    throws IOException
Throws:
IOException

deserializeDatetimeV2

protected Serializable deserializeDatetimeV2(int meta,
                                             ByteArrayInputStream inputStream)
                                      throws IOException
Throws:
IOException

deserializeYear

protected Serializable deserializeYear(ByteArrayInputStream inputStream)
                                throws IOException
Throws:
IOException

deserializeString

protected Serializable deserializeString(int length,
                                         ByteArrayInputStream inputStream)
                                  throws IOException
Throws:
IOException

deserializeVarString

protected Serializable deserializeVarString(int meta,
                                            ByteArrayInputStream inputStream)
                                     throws IOException
Throws:
IOException

deserializeBlob

protected Serializable deserializeBlob(int meta,
                                       ByteArrayInputStream inputStream)
                                throws IOException
Throws:
IOException

deserializeEnum

protected Serializable deserializeEnum(int length,
                                       ByteArrayInputStream inputStream)
                                throws IOException
Throws:
IOException

deserializeSet

protected Serializable deserializeSet(int length,
                                      ByteArrayInputStream inputStream)
                               throws IOException
Throws:
IOException

deserializeGeometry

protected Serializable deserializeGeometry(int meta,
                                           ByteArrayInputStream inputStream)
                                    throws IOException
Throws:
IOException

deserializeJson

protected byte[] deserializeJson(int meta,
                                 ByteArrayInputStream inputStream)
                          throws IOException
Deserialize the JSON value on the input stream, and return MySQL's internal binary representation of the JSON value. See JsonBinary for a utility to parse this binary representation into something more useful, including a string representation.

Parameters:
meta - the number of bytes in which the length of the JSON value is found first on the input stream
inputStream - the stream containing the JSON value
Returns:
the MySQL internal binary representation of the JSON value; may be null
Throws:
IOException - if there is a problem reading the input stream

asUnixTime

protected Long asUnixTime(int year,
                          int month,
                          int day,
                          int hour,
                          int minute,
                          int second,
                          int millis)

deserializeFractionalSeconds

protected int deserializeFractionalSeconds(int meta,
                                           ByteArrayInputStream inputStream)
                                    throws IOException
Throws:
IOException

asBigDecimal

public static BigDecimal asBigDecimal(int precision,
                                      int scale,
                                      byte[] value)
see mysql/strings/decimal.c



Copyright © 2016. All Rights Reserved.