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

The following examples show how to use com.taobao.tddl.dbsync.binlog.LogBuffer#getUlong48() . 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: RowsLogEvent.java    From canal-1.1.3 with Apache License 2.0 4 votes vote down vote up
public RowsLogEvent(LogHeader header, LogBuffer buffer, FormatDescriptionLogEvent descriptionEvent, boolean partial){
    super(header);

    final int commonHeaderLen = descriptionEvent.commonHeaderLen;
    final int postHeaderLen = descriptionEvent.postHeaderLen[header.type - 1];
    int headerLen = 0;
    buffer.position(commonHeaderLen + RW_MAPID_OFFSET);
    if (postHeaderLen == 6) {
        /*
         * Master is of an intermediate source tree before 5.1.4. Id is 4
         * bytes
         */
        tableId = buffer.getUint32();
    } else {
        tableId = buffer.getUlong48(); // RW_FLAGS_OFFSET
    }
    flags = buffer.getUint16();

    if (postHeaderLen == FormatDescriptionLogEvent.ROWS_HEADER_LEN_V2) {
        headerLen = buffer.getUint16();
        headerLen -= 2;
        int start = buffer.position();
        int end = start + headerLen;
        for (int i = start; i < end;) {
            switch (buffer.getUint8(i++)) {
                case RW_V_EXTRAINFO_TAG:
                    // int infoLen = buffer.getUint8();
                    buffer.position(i + EXTRA_ROW_INFO_LEN_OFFSET);
                    int checkLen = buffer.getUint8(); // EXTRA_ROW_INFO_LEN_OFFSET
                    int val = checkLen - EXTRA_ROW_INFO_HDR_BYTES;
                    assert (buffer.getUint8() == val); // EXTRA_ROW_INFO_FORMAT_OFFSET
                    for (int j = 0; j < val; j++) {
                        assert (buffer.getUint8() == val); // EXTRA_ROW_INFO_HDR_BYTES
                                                           // + i
                    }
                    break;
                default:
                    i = end;
                    break;
            }
        }
    }

    buffer.position(commonHeaderLen + postHeaderLen + headerLen);
    columnLen = (int) buffer.getPackedLong();
    this.partial = partial;
    columns = buffer.getBitmap(columnLen);

    if (header.type == UPDATE_ROWS_EVENT_V1 || header.type == UPDATE_ROWS_EVENT
        || header.type == PARTIAL_UPDATE_ROWS_EVENT) {
        changeColumns = buffer.getBitmap(columnLen);
    } else {
        changeColumns = columns;
    }

    // XXX: Don't handle buffer in another thread.
    int dataSize = buffer.limit() - buffer.position();
    rowsBuf = buffer.duplicate(dataSize);
}
 
Example 2
Source File: RowsLogEvent.java    From canal with Apache License 2.0 4 votes vote down vote up
public RowsLogEvent(LogHeader header, LogBuffer buffer, FormatDescriptionLogEvent descriptionEvent, boolean partial){
    super(header);

    final int commonHeaderLen = descriptionEvent.commonHeaderLen;
    final int postHeaderLen = descriptionEvent.postHeaderLen[header.type - 1];
    int headerLen = 0;
    buffer.position(commonHeaderLen + RW_MAPID_OFFSET);
    if (postHeaderLen == 6) {
        /*
         * Master is of an intermediate source tree before 5.1.4. Id is 4
         * bytes
         */
        tableId = buffer.getUint32();
    } else {
        tableId = buffer.getUlong48(); // RW_FLAGS_OFFSET
    }
    flags = buffer.getUint16();

    if (postHeaderLen == FormatDescriptionLogEvent.ROWS_HEADER_LEN_V2) {
        headerLen = buffer.getUint16();
        headerLen -= 2;
        int start = buffer.position();
        int end = start + headerLen;
        for (int i = start; i < end;) {
            switch (buffer.getUint8(i++)) {
                case RW_V_EXTRAINFO_TAG:
                    // int infoLen = buffer.getUint8();
                    buffer.position(i + EXTRA_ROW_INFO_LEN_OFFSET);
                    int checkLen = buffer.getUint8(); // EXTRA_ROW_INFO_LEN_OFFSET
                    int val = checkLen - EXTRA_ROW_INFO_HDR_BYTES;
                    assert (buffer.getUint8() == val); // EXTRA_ROW_INFO_FORMAT_OFFSET
                    for (int j = 0; j < val; j++) {
                        assert (buffer.getUint8() == val); // EXTRA_ROW_INFO_HDR_BYTES
                                                           // + i
                    }
                    break;
                default:
                    i = end;
                    break;
            }
        }
    }

    buffer.position(commonHeaderLen + postHeaderLen + headerLen);
    columnLen = (int) buffer.getPackedLong();
    this.partial = partial;
    columns = buffer.getBitmap(columnLen);

    if (header.type == UPDATE_ROWS_EVENT_V1 || header.type == UPDATE_ROWS_EVENT
        || header.type == PARTIAL_UPDATE_ROWS_EVENT) {
        changeColumns = buffer.getBitmap(columnLen);
    } else {
        changeColumns = columns;
    }

    // XXX: Don't handle buffer in another thread.
    int dataSize = buffer.limit() - buffer.position();
    rowsBuf = buffer.duplicate(dataSize);
}