-
Notifications
You must be signed in to change notification settings - Fork 819
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to deserialize TABLE_MAP and ROTATE events to byte arrays #29
Comments
I think you can try something similar to: public class CustomRotateEventData extends RotateEventData {
private byte[] data;
public byte[] getData() {
return data;
}
public void setData(byte[] data) {
this.data = data;
}
}
public class CustomRotateEventDataDeserializer extends RotateEventDataDeserializer {
@Override
public RotateEventData deserialize(ByteArrayInputStream inputStream) throws IOException {
byte[] data = inputStream.read(inputStream.available());
RotateEventData eventData = super.deserialize(new ByteArrayInputStream(data));
CustomRotateEventData result = new CustomRotateEventData();
result.setData(data);
result.setBinlogPosition(eventData.getBinlogPosition());
result.setBinlogFilename(eventData.getBinlogFilename());
return result;
}
}
eventDeserializer.setEventDataDeserializer(EventType.ROTATE, new CustomRotateEventDataDeserializer()); Obviously, the same has to be done for TableMapEventData. |
This works, though I don't think it's ideal. If I were to go with this solution, I would have to special case fetching byte data for all rotate and table_map events. I think another solution could be to attach a getData method to the EventDataDeserializer class so that we can have a common interface for accessing byte data for all event types. |
Oh, I know it's far from being ideal. The workaround above I literally wrote while driving back home :) It's something that you can use now and not wait for me to change the internal flow (which is on its way). |
Fix available in 0.1.2-SNAPSHOT. Starting from 0417068 EventDataDeserializer can be specified regardless of the event type (= no special treatment for TABLE_MAP/ROTATE). |
0.1.2 should become available through Maven Central in the next 24h. |
@shyiko oh man, thanks for the quick implementation. I didn't want to sound ungrateful in my original post about your workaround. I just wanted to point out that it would be not ideal. Anyways, it seems like you went the extra step for this issue! cheers! 🍺 |
Not at all, man. I truly appreciate your feedback. 🍻 |
Related to #28 since the library depends on those being deserialized to a specific type.
The text was updated successfully, but these errors were encountered: