Java Code Examples for com.taobao.tddl.dbsync.binlog.LogEvent#MYSQL_TYPE_SET

The following examples show how to use com.taobao.tddl.dbsync.binlog.LogEvent#MYSQL_TYPE_SET . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TableMapLogEvent.java    From canal-1.1.3 with Apache License 2.0 6 votes vote down vote up
private int getRealType(int type, int meta) {
    if (type == LogEvent.MYSQL_TYPE_STRING) {
        if (meta >= 256) {
            int byte0 = meta >> 8;
            if ((byte0 & 0x30) != 0x30) {
                /* a long CHAR() field: see #37426 */
                type = byte0 | 0x30;
            } else {
                switch (byte0) {
                    case LogEvent.MYSQL_TYPE_SET:
                    case LogEvent.MYSQL_TYPE_ENUM:
                    case LogEvent.MYSQL_TYPE_STRING:
                        type = byte0;
                }
            }
        }
    }

    return type;
}
 
Example 2
Source File: TableMapLogEvent.java    From canal with Apache License 2.0 6 votes vote down vote up
private int getRealType(int type, int meta) {
    if (type == LogEvent.MYSQL_TYPE_STRING) {
        if (meta >= 256) {
            int byte0 = meta >> 8;
            if ((byte0 & 0x30) != 0x30) {
                /* a long CHAR() field: see #37426 */
                type = byte0 | 0x30;
            } else {
                switch (byte0) {
                    case LogEvent.MYSQL_TYPE_SET:
                    case LogEvent.MYSQL_TYPE_ENUM:
                    case LogEvent.MYSQL_TYPE_STRING:
                        type = byte0;
                }
            }
        }
    }

    return type;
}
 
Example 3
Source File: TableMapLogEvent.java    From canal-1.1.3 with Apache License 2.0 5 votes vote down vote up
private void parse_set_str_value(LogBuffer buffer, int length, boolean set) {
    // stores SET/ENUM column's string values extracted from
    // field. Each SET/ENUM column's string values are stored
    // into a string separate vector. All of them are stored
    // in 'vec'.
    int limit = buffer.position() + length;
    List<List<String>> datas = new ArrayList<List<String>>();
    while (buffer.hasRemaining() && buffer.position() < limit) {
        int count = (int) buffer.getPackedLong();
        List<String> data = new ArrayList<String>(count);
        for (int i = 0; i < count; i++) {
            int len1 = (int) buffer.getPackedLong();
            data.add(buffer.getFixString(len1));
        }

        datas.add(data);
    }

    int index = 0;
    for (int i = 0; i < columnCnt; i++) {
        if (set && getRealType(columnInfo[i].type, columnInfo[i].meta) == LogEvent.MYSQL_TYPE_SET) {
            columnInfo[i].set_enum_values = datas.get(index);
            index++;
        }

        if (!set && getRealType(columnInfo[i].type, columnInfo[i].meta) == LogEvent.MYSQL_TYPE_ENUM) {
            columnInfo[i].set_enum_values = datas.get(index);
            index++;
        }
    }
}
 
Example 4
Source File: TableMapLogEvent.java    From canal with Apache License 2.0 5 votes vote down vote up
private void parse_set_str_value(LogBuffer buffer, int length, boolean set) {
    // stores SET/ENUM column's string values extracted from
    // field. Each SET/ENUM column's string values are stored
    // into a string separate vector. All of them are stored
    // in 'vec'.
    int limit = buffer.position() + length;
    List<List<String>> datas = new ArrayList<List<String>>();
    while (buffer.hasRemaining() && buffer.position() < limit) {
        int count = (int) buffer.getPackedLong();
        List<String> data = new ArrayList<String>(count);
        for (int i = 0; i < count; i++) {
            int len1 = (int) buffer.getPackedLong();
            data.add(buffer.getFixString(len1));
        }

        datas.add(data);
    }

    int index = 0;
    for (int i = 0; i < columnCnt; i++) {
        if (set && getRealType(columnInfo[i].type, columnInfo[i].meta) == LogEvent.MYSQL_TYPE_SET) {
            columnInfo[i].set_enum_values = datas.get(index);
            index++;
        }

        if (!set && getRealType(columnInfo[i].type, columnInfo[i].meta) == LogEvent.MYSQL_TYPE_ENUM) {
            columnInfo[i].set_enum_values = datas.get(index);
            index++;
        }
    }
}