@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 testDeserializeMetadata() throws IOException {
        byte[] data = {
            // SIGNEDNESS
            1,
            // SIGNEDNESS length
            5,
            // 5 bytes for SIGNEDNESS
            -74,
            -39,
            -101,
            97,
            0,
            // COLUMN_CHARSET
            3,
            // COLUMN_CHARSET length
            32,
            // remaining 32 bytes for COLUMN_CHARSET
            33,
            33,
            63,
            33,
            63,
            63,
            63,
            63,
            -4,
            -1,
            0,
            -4,
            -1,
            0,
            -4,
            -1,
            0,
            -4,
            -1,
            0,
            -4,
            -1,
            0,
            -4,
            -1,
            0,
            -4,
            -1,
            0,
            -4,
            -1,
            0
        };

        TableMapEventMetadataDeserializer deserializer = new TableMapEventMetadataDeserializer();

        TableMapEventMetadata metadata =
                deserializer.deserialize(new ByteArrayInputStream(data), 59, 32);

        assertThat(metadata.toString()).isEqualTo(getExpectedTableMapEventMetaData().toString());
    }