@Override
    public TableMapEventData deserialize(ByteArrayInputStream inputStream) throws IOException {
        TableMapEventData eventData = new TableMapEventData();
        eventData.setTableId(inputStream.readLong(6));
        inputStream.skip(3); // 2 bytes reserved for future use + 1 for the length of database name
        eventData.setDatabase(inputStream.readZeroTerminatedString());
        inputStream.skip(1); // table name
        eventData.setTable(inputStream.readZeroTerminatedString());
        int numberOfColumns = inputStream.readPackedInteger();
        eventData.setColumnTypes(inputStream.read(numberOfColumns));
        inputStream.readPackedInteger(); // metadata length
        eventData.setColumnMetadata(readMetadata(inputStream, eventData.getColumnTypes()));
        eventData.setColumnNullability(inputStream.readBitSet(numberOfColumns, true));
        int metadataLength = inputStream.available();
        TableMapEventMetadata metadata = null;
        if (metadataLength > 0) {
            metadata =
                    metadataDeserializer.deserialize(
                            new ByteArrayInputStream(inputStream.read(metadataLength)),
                            eventData.getColumnTypes().length,
                            numericColumnCount(eventData.getColumnTypes()));
        }
        eventData.setEventMetadata(metadata);
        return eventData;
    }
@Test
    public void testDeserialize() throws IOException {
        TableMapEventDataDeserializer deserializer = new TableMapEventDataDeserializer();
        // The Table_map_event data. See its format at
        // https://dev.mysql.com/doc/dev/mysql-server/latest/classbinary__log_1_1Table__map__event.html
        byte[] data = {
            // table_id : 6 bytes
            1,
            0,
            0,
            0,
            0,
            0,
            // flags : 2 bytes
            1,
            0,
            // database_name string length : 1 byte
            6,
            // database_name null-terminated string, end with 0
            116,
            101,
            115,
            116,
            68,
            98,
            0,
            // table_name string length : 1 byte
            9,
            // table_name null-terminated string, end with 0
            116,
            101,
            115,
            116,
            84,
            97,
            98,
            108,
            101,
            0,
            // column_count
            3,
            // column_type list
            8,
            1,
            20,
            // metadata_length
            1,
            // metadata
            8,
            // null_bits
            80,
            // optional metadata fields stored in Type, Length, Value(TLV) format.
            // Type takes 1 byte. Length is a packed integer value. Values takes Length bytes.

            // SIGNEDNESS
            1,
            1,
            0,
            // DEFAULT_CHARSET
            2,
            1,
            45
        };
        TableMapEventData eventData = deserializer.deserialize(new ByteArrayInputStream(data));
        assertThat(eventData.toString()).isEqualTo(getExpectedEventData().toString());
    }