Java Code Examples for com.taobao.tddl.dbsync.binlog.LogBuffer#hasRemaining()

The following examples show how to use com.taobao.tddl.dbsync.binlog.LogBuffer#hasRemaining() . 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 List<TableMapLogEvent.Pair> parse_default_charset(LogBuffer buffer, int length) {
    // stores collation numbers extracted from field.
    int limit = buffer.position() + length;
    this.default_charset = (int) buffer.getPackedLong();
    List<TableMapLogEvent.Pair> datas = new ArrayList<TableMapLogEvent.Pair>();
    while (buffer.hasRemaining() && buffer.position() < limit) {
        int col_index = (int) buffer.getPackedLong();
        int col_charset = (int) buffer.getPackedLong();

        Pair pair = new Pair();
        pair.col_index = col_index;
        pair.col_charset = col_charset;
        datas.add(pair);
    }

    return datas;
}
 
Example 2
Source File: TableMapLogEvent.java    From canal-1.1.3 with Apache License 2.0 6 votes vote down vote up
private void parse_geometry_type(LogBuffer buffer, int length) {
    // stores geometry column's types extracted from field.
    int limit = buffer.position() + length;

    List<Integer> datas = new ArrayList<Integer>();
    while (buffer.hasRemaining() && buffer.position() < limit) {
        int col_type = (int) buffer.getPackedLong();
        datas.add(col_type);
    }

    int index = 0;
    for (int i = 0; i < columnCnt; i++) {
        if (columnInfo[i].type == LogEvent.MYSQL_TYPE_GEOMETRY) {
            columnInfo[i].geoType = datas.get(index);
            index++;
        }
    }
}
 
Example 3
Source File: TableMapLogEvent.java    From canal with Apache License 2.0 6 votes vote down vote up
private List<TableMapLogEvent.Pair> parse_default_charset(LogBuffer buffer, int length) {
    // stores collation numbers extracted from field.
    int limit = buffer.position() + length;
    this.default_charset = (int) buffer.getPackedLong();
    List<TableMapLogEvent.Pair> datas = new ArrayList<TableMapLogEvent.Pair>();
    while (buffer.hasRemaining() && buffer.position() < limit) {
        int col_index = (int) buffer.getPackedLong();
        int col_charset = (int) buffer.getPackedLong();

        Pair pair = new Pair();
        pair.col_index = col_index;
        pair.col_charset = col_charset;
        datas.add(pair);
    }

    return datas;
}
 
Example 4
Source File: TableMapLogEvent.java    From canal with Apache License 2.0 6 votes vote down vote up
private void parse_geometry_type(LogBuffer buffer, int length) {
    // stores geometry column's types extracted from field.
    int limit = buffer.position() + length;

    List<Integer> datas = new ArrayList<Integer>();
    while (buffer.hasRemaining() && buffer.position() < limit) {
        int col_type = (int) buffer.getPackedLong();
        datas.add(col_type);
    }

    int index = 0;
    for (int i = 0; i < columnCnt; i++) {
        if (columnInfo[i].type == LogEvent.MYSQL_TYPE_GEOMETRY) {
            columnInfo[i].geoType = datas.get(index);
            index++;
        }
    }
}
 
Example 5
Source File: GtidLogEvent.java    From canal-1.1.3 with Apache License 2.0 5 votes vote down vote up
public GtidLogEvent(LogHeader header, LogBuffer buffer, FormatDescriptionLogEvent descriptionEvent){
    super(header);

    final int commonHeaderLen = descriptionEvent.commonHeaderLen;
    // final int postHeaderLen = descriptionEvent.postHeaderLen[header.type
    // - 1];

    buffer.position(commonHeaderLen);
    commitFlag = (buffer.getUint8() != 0); // ENCODED_FLAG_LENGTH

    byte[] bs = buffer.getData(ENCODED_SID_LENGTH);
    ByteBuffer bb = ByteBuffer.wrap(bs);
    long high = bb.getLong();
    long low = bb.getLong();
    sid = new UUID(high, low);

    gno = buffer.getLong64();

    // support gtid lastCommitted and sequenceNumber
    // fix bug #776
    if (buffer.hasRemaining() && buffer.remaining() > 16 && buffer.getUint8() == LOGICAL_TIMESTAMP_TYPE_CODE) {
        lastCommitted = buffer.getLong64();
        sequenceNumber = buffer.getLong64();
    }

    // ignore gtid info read
    // sid.copy_from((uchar *)ptr_buffer);
    // ptr_buffer+= ENCODED_SID_LENGTH;
    //
    // // SIDNO is only generated if needed, in get_sidno().
    // spec.gtid.sidno= -1;
    //
    // spec.gtid.gno= uint8korr(ptr_buffer);
    // ptr_buffer+= ENCODED_GNO_LENGTH;
}
 
Example 6
Source File: TableMapLogEvent.java    From canal-1.1.3 with Apache License 2.0 5 votes vote down vote up
private List<Integer> parse_column_charset(LogBuffer buffer, int length) {
    // stores collation numbers extracted from field.
    int limit = buffer.position() + length;
    List<Integer> datas = new ArrayList<Integer>();
    while (buffer.hasRemaining() && buffer.position() < limit) {
        int col_charset = (int) buffer.getPackedLong();
        datas.add(col_charset);
    }

    return datas;
}
 
Example 7
Source File: TableMapLogEvent.java    From canal-1.1.3 with Apache License 2.0 5 votes vote down vote up
private void parse_column_name(LogBuffer buffer, int length) {
    // stores column names extracted from field
    int limit = buffer.position() + length;
    int index = 0;
    while (buffer.hasRemaining() && buffer.position() < limit) {
        int len = (int) buffer.getPackedLong();
        columnInfo[index++].name = buffer.getFixString(len);
    }
}
 
Example 8
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 9
Source File: TableMapLogEvent.java    From canal-1.1.3 with Apache License 2.0 5 votes vote down vote up
private void parse_simple_pk(LogBuffer buffer, int length) {
    // stores primary key's column information extracted from
    // field. Each column has an index and a prefix which are
    // stored as a unit_pair. prefix is always 0 for
    // SIMPLE_PRIMARY_KEY field.

    int limit = buffer.position() + length;
    while (buffer.hasRemaining() && buffer.position() < limit) {
        int col_index = (int) buffer.getPackedLong();
        columnInfo[col_index].pk = true;
    }
}
 
Example 10
Source File: TableMapLogEvent.java    From canal-1.1.3 with Apache License 2.0 5 votes vote down vote up
private void parse_pk_with_prefix(LogBuffer buffer, int length) {
    // stores primary key's column information extracted from
    // field. Each column has an index and a prefix which are
    // stored as a unit_pair.
    int limit = buffer.position() + length;
    while (buffer.hasRemaining() && buffer.position() < limit) {
        int col_index = (int) buffer.getPackedLong();
        // prefix length, 比如 char(32)
        @SuppressWarnings("unused")
        int col_prefix = (int) buffer.getPackedLong();
        columnInfo[col_index].pk = true;
    }
}
 
Example 11
Source File: GtidLogEvent.java    From canal with Apache License 2.0 5 votes vote down vote up
public GtidLogEvent(LogHeader header, LogBuffer buffer, FormatDescriptionLogEvent descriptionEvent){
    super(header);

    final int commonHeaderLen = descriptionEvent.commonHeaderLen;
    // final int postHeaderLen = descriptionEvent.postHeaderLen[header.type
    // - 1];

    buffer.position(commonHeaderLen);
    commitFlag = (buffer.getUint8() != 0); // ENCODED_FLAG_LENGTH

    byte[] bs = buffer.getData(ENCODED_SID_LENGTH);
    ByteBuffer bb = ByteBuffer.wrap(bs);
    long high = bb.getLong();
    long low = bb.getLong();
    sid = new UUID(high, low);

    gno = buffer.getLong64();

    // support gtid lastCommitted and sequenceNumber
    // fix bug #776
    if (buffer.hasRemaining() && buffer.remaining() > 16 && buffer.getUint8() == LOGICAL_TIMESTAMP_TYPE_CODE) {
        lastCommitted = buffer.getLong64();
        sequenceNumber = buffer.getLong64();
    }

    // ignore gtid info read
    // sid.copy_from((uchar *)ptr_buffer);
    // ptr_buffer+= ENCODED_SID_LENGTH;
    //
    // // SIDNO is only generated if needed, in get_sidno().
    // spec.gtid.sidno= -1;
    //
    // spec.gtid.gno= uint8korr(ptr_buffer);
    // ptr_buffer+= ENCODED_GNO_LENGTH;
}
 
Example 12
Source File: TableMapLogEvent.java    From canal with Apache License 2.0 5 votes vote down vote up
private List<Integer> parse_column_charset(LogBuffer buffer, int length) {
    // stores collation numbers extracted from field.
    int limit = buffer.position() + length;
    List<Integer> datas = new ArrayList<Integer>();
    while (buffer.hasRemaining() && buffer.position() < limit) {
        int col_charset = (int) buffer.getPackedLong();
        datas.add(col_charset);
    }

    return datas;
}
 
Example 13
Source File: TableMapLogEvent.java    From canal with Apache License 2.0 5 votes vote down vote up
private void parse_column_name(LogBuffer buffer, int length) {
    // stores column names extracted from field
    int limit = buffer.position() + length;
    int index = 0;
    while (buffer.hasRemaining() && buffer.position() < limit) {
        int len = (int) buffer.getPackedLong();
        columnInfo[index++].name = buffer.getFixString(len);
    }
}
 
Example 14
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++;
        }
    }
}
 
Example 15
Source File: TableMapLogEvent.java    From canal with Apache License 2.0 5 votes vote down vote up
private void parse_simple_pk(LogBuffer buffer, int length) {
    // stores primary key's column information extracted from
    // field. Each column has an index and a prefix which are
    // stored as a unit_pair. prefix is always 0 for
    // SIMPLE_PRIMARY_KEY field.

    int limit = buffer.position() + length;
    while (buffer.hasRemaining() && buffer.position() < limit) {
        int col_index = (int) buffer.getPackedLong();
        columnInfo[col_index].pk = true;
    }
}
 
Example 16
Source File: TableMapLogEvent.java    From canal with Apache License 2.0 5 votes vote down vote up
private void parse_pk_with_prefix(LogBuffer buffer, int length) {
    // stores primary key's column information extracted from
    // field. Each column has an index and a prefix which are
    // stored as a unit_pair.
    int limit = buffer.position() + length;
    while (buffer.hasRemaining() && buffer.position() < limit) {
        int col_index = (int) buffer.getPackedLong();
        // prefix length, 比如 char(32)
        @SuppressWarnings("unused")
        int col_prefix = (int) buffer.getPackedLong();
        columnInfo[col_index].pk = true;
    }
}