com.taobao.tddl.dbsync.binlog.event.TableMapLogEvent.ColumnInfo Java Examples

The following examples show how to use com.taobao.tddl.dbsync.binlog.event.TableMapLogEvent.ColumnInfo. 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 6 votes vote down vote up
public final void fillTable(LogContext context) {
    table = context.getTable(tableId);

    // end of statement check:
    if ((flags & RowsLogEvent.STMT_END_F) != 0) {
        // Now is safe to clear ignored map (clear_tables will also
        // delete original table map events stored in the map).
        context.clearAllTables();
    }

    int jsonColumnCount = 0;
    int columnCnt = table.getColumnCnt();
    ColumnInfo[] columnInfo = table.getColumnInfo();
    for (int i = 0; i < columnCnt; i++) {
        ColumnInfo info = columnInfo[i];
        if (info.type == LogEvent.MYSQL_TYPE_JSON) {
            jsonColumnCount++;
        }
    }
    this.jsonColumnCount = jsonColumnCount;
}
 
Example #2
Source File: MysqlBinlogParsePerformanceTest.java    From canal-1.1.3 with Apache License 2.0 6 votes vote down vote up
public static void parseOneRow(RowsLogEvent event, RowsLogBuffer buffer, BitSet cols, boolean isAfter)
                                                                                                      throws UnsupportedEncodingException {
    TableMapLogEvent map = event.getTable();
    if (map == null) {
        throw new RuntimeException("not found TableMap with tid=" + event.getTableId());
    }

    final int columnCnt = map.getColumnCnt();
    final ColumnInfo[] columnInfo = map.getColumnInfo();
    for (int i = 0; i < columnCnt; i++) {
        if (!cols.get(i)) {
            continue;
        }

        ColumnInfo info = columnInfo[i];
        buffer.nextValue(null, i, info.type, info.meta);
        if (buffer.isNull()) {
        } else {
            buffer.getValue();
        }
    }
}
 
Example #3
Source File: RowsLogEvent.java    From canal with Apache License 2.0 6 votes vote down vote up
public final void fillTable(LogContext context) {
    table = context.getTable(tableId);

    if (table == null) {
        throw new TableIdNotFoundException("not found tableId:" + tableId);
    }

    // end of statement check:
    if ((flags & RowsLogEvent.STMT_END_F) != 0) {
        // Now is safe to clear ignored map (clear_tables will also
        // delete original table map events stored in the map).
        context.clearAllTables();
    }

    int jsonColumnCount = 0;
    int columnCnt = table.getColumnCnt();
    ColumnInfo[] columnInfo = table.getColumnInfo();
    for (int i = 0; i < columnCnt; i++) {
        ColumnInfo info = columnInfo[i];
        if (info.type == LogEvent.MYSQL_TYPE_JSON) {
            jsonColumnCount++;
        }
    }
    this.jsonColumnCount = jsonColumnCount;
}
 
Example #4
Source File: MysqlBinlogParsePerformanceTest.java    From canal with Apache License 2.0 6 votes vote down vote up
public static void parseOneRow(RowsLogEvent event, RowsLogBuffer buffer, BitSet cols, boolean isAfter)
                                                                                                      throws UnsupportedEncodingException {
    TableMapLogEvent map = event.getTable();
    if (map == null) {
        throw new RuntimeException("not found TableMap with tid=" + event.getTableId());
    }

    final int columnCnt = map.getColumnCnt();
    final ColumnInfo[] columnInfo = map.getColumnInfo();
    for (int i = 0; i < columnCnt; i++) {
        if (!cols.get(i)) {
            continue;
        }

        ColumnInfo info = columnInfo[i];
        buffer.nextValue(null, i, info.type, info.meta);
        if (buffer.isNull()) {
        } else {
            buffer.getValue();
        }
    }
}
 
Example #5
Source File: BaseLogFetcherTest.java    From canal-1.1.3 with Apache License 2.0 5 votes vote down vote up
protected void parseOneRow(RowsLogEvent event, RowsLogBuffer buffer, BitSet cols, boolean isAfter)
                                                                                                  throws UnsupportedEncodingException {
    TableMapLogEvent map = event.getTable();
    if (map == null) {
        throw new RuntimeException("not found TableMap with tid=" + event.getTableId());
    }

    final int columnCnt = map.getColumnCnt();
    final ColumnInfo[] columnInfo = map.getColumnInfo();

    for (int i = 0; i < columnCnt; i++) {
        if (!cols.get(i)) {
            continue;
        }

        ColumnInfo info = columnInfo[i];
        buffer.nextValue(null , i ,info.type, info.meta);

        if (buffer.isNull()) {
            //
        } else {
            final Serializable value = buffer.getValue();
            if (value instanceof byte[]) {
                System.out.println(new String((byte[]) value));
            } else {
                System.out.println(value);
            }
        }
    }

}
 
Example #6
Source File: DirectLogFetcherTest.java    From canal-1.1.3 with Apache License 2.0 5 votes vote down vote up
protected void parseOneRow(RowsLogEvent event, RowsLogBuffer buffer, BitSet cols, boolean isAfter)
                                                                                                  throws UnsupportedEncodingException {
    TableMapLogEvent map = event.getTable();
    if (map == null) {
        throw new RuntimeException("not found TableMap with tid=" + event.getTableId());
    }

    final int columnCnt = map.getColumnCnt();
    final ColumnInfo[] columnInfo = map.getColumnInfo();

    for (int i = 0; i < columnCnt; i++) {
        if (!cols.get(i)) {
            continue;
        }

        ColumnInfo info = columnInfo[i];
        buffer.nextValue(null, i, info.type, info.meta);

        if (buffer.isNull()) {
            //
        } else {
            final Serializable value = buffer.getValue();
            if (value instanceof byte[]) {
                System.out.println(new String((byte[]) value));
            } else {
                System.out.println(value);
            }
        }
    }

}
 
Example #7
Source File: BaseLogFetcherTest.java    From canal with Apache License 2.0 5 votes vote down vote up
protected void parseOneRow(RowsLogEvent event, RowsLogBuffer buffer, BitSet cols, boolean isAfter)
                                                                                                  throws UnsupportedEncodingException {
    TableMapLogEvent map = event.getTable();
    if (map == null) {
        throw new RuntimeException("not found TableMap with tid=" + event.getTableId());
    }

    final int columnCnt = map.getColumnCnt();
    final ColumnInfo[] columnInfo = map.getColumnInfo();

    for (int i = 0; i < columnCnt; i++) {
        if (!cols.get(i)) {
            continue;
        }

        ColumnInfo info = columnInfo[i];
        buffer.nextValue(null , i ,info.type, info.meta);

        if (buffer.isNull()) {
            //
        } else {
            final Serializable value = buffer.getValue();
            if (value instanceof byte[]) {
                System.out.println(new String((byte[]) value));
            } else {
                System.out.println(value);
            }
        }
    }

}
 
Example #8
Source File: DirectLogFetcherTest.java    From canal with Apache License 2.0 5 votes vote down vote up
protected void parseOneRow(RowsLogEvent event, RowsLogBuffer buffer, BitSet cols, boolean isAfter)
                                                                                                  throws UnsupportedEncodingException {
    TableMapLogEvent map = event.getTable();
    if (map == null) {
        throw new RuntimeException("not found TableMap with tid=" + event.getTableId());
    }

    final int columnCnt = map.getColumnCnt();
    final ColumnInfo[] columnInfo = map.getColumnInfo();

    for (int i = 0; i < columnCnt; i++) {
        if (!cols.get(i)) {
            continue;
        }

        ColumnInfo info = columnInfo[i];
        buffer.nextValue(null, i, info.type, info.meta);

        if (buffer.isNull()) {
            //
        } else {
            final Serializable value = buffer.getValue();
            if (value instanceof byte[]) {
                System.out.println(new String((byte[]) value));
            } else {
                System.out.println(value);
            }
        }
    }

}