com.taobao.tddl.dbsync.binlog.event.RowsLogBuffer Java Examples
The following examples show how to use
com.taobao.tddl.dbsync.binlog.event.RowsLogBuffer.
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: MysqlBinlogParsePerformanceTest.java From canal-1.1.3 with Apache License 2.0 | 6 votes |
public static void parseRowsEvent(RowsLogEvent event, AtomicLong sum) { try { RowsLogBuffer buffer = event.getRowsBuf(charset.name()); BitSet columns = event.getColumns(); BitSet changeColumns = event.getChangeColumns(); while (buffer.nextOneRow(columns)) { int type = event.getHeader().getType(); if (LogEvent.WRITE_ROWS_EVENT_V1 == type || LogEvent.WRITE_ROWS_EVENT == type) { parseOneRow(event, buffer, columns, true); } else if (LogEvent.DELETE_ROWS_EVENT_V1 == type || LogEvent.DELETE_ROWS_EVENT == type) { parseOneRow(event, buffer, columns, false); } else { parseOneRow(event, buffer, columns, false); if (!buffer.nextOneRow(changeColumns, true)) { break; } parseOneRow(event, buffer, changeColumns, true); } sum.incrementAndGet(); } } catch (Exception e) { throw new RuntimeException("parse row data failed.", e); } }
Example #2
Source File: MysqlBinlogParsePerformanceTest.java From canal-1.1.3 with Apache License 2.0 | 6 votes |
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: MysqlBinlogParsePerformanceTest.java From canal with Apache License 2.0 | 6 votes |
public static void parseRowsEvent(RowsLogEvent event, AtomicLong sum) { try { RowsLogBuffer buffer = event.getRowsBuf(charset.name()); BitSet columns = event.getColumns(); BitSet changeColumns = event.getChangeColumns(); while (buffer.nextOneRow(columns)) { int type = event.getHeader().getType(); if (LogEvent.WRITE_ROWS_EVENT_V1 == type || LogEvent.WRITE_ROWS_EVENT == type) { parseOneRow(event, buffer, columns, true); } else if (LogEvent.DELETE_ROWS_EVENT_V1 == type || LogEvent.DELETE_ROWS_EVENT == type) { parseOneRow(event, buffer, columns, false); } else { parseOneRow(event, buffer, columns, false); if (!buffer.nextOneRow(changeColumns, true)) { break; } parseOneRow(event, buffer, changeColumns, true); } sum.incrementAndGet(); } } catch (Exception e) { throw new RuntimeException("parse row data failed.", e); } }
Example #4
Source File: MysqlBinlogParsePerformanceTest.java From canal with Apache License 2.0 | 6 votes |
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 |
protected void parseRowsEvent(RowsLogEvent event) { try { System.out.println(String.format("================> binlog[%s:%s] , name[%s,%s]", binlogFileName, event.getHeader().getLogPos() - event.getHeader().getEventLen(), event.getTable().getDbName(), event.getTable().getTableName())); RowsLogBuffer buffer = event.getRowsBuf(charset.name()); BitSet columns = event.getColumns(); BitSet changeColumns = event.getChangeColumns(); while (buffer.nextOneRow(columns)) { // 处理row记录 int type = event.getHeader().getType(); if (LogEvent.WRITE_ROWS_EVENT_V1 == type || LogEvent.WRITE_ROWS_EVENT == type) { // insert的记录放在before字段中 parseOneRow(event, buffer, columns, true); } else if (LogEvent.DELETE_ROWS_EVENT_V1 == type || LogEvent.DELETE_ROWS_EVENT == type) { // delete的记录放在before字段中 parseOneRow(event, buffer, columns, false); } else { // update需要处理before/after System.out.println("-------> before"); parseOneRow(event, buffer, columns, false); if (!buffer.nextOneRow(changeColumns, true)) { break; } System.out.println("-------> after"); parseOneRow(event, buffer, changeColumns, true); } } } catch (Exception e) { throw new RuntimeException("parse row data failed.", e); } }
Example #6
Source File: BaseLogFetcherTest.java From canal-1.1.3 with Apache License 2.0 | 5 votes |
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: DirectLogFetcherTest.java From canal-1.1.3 with Apache License 2.0 | 5 votes |
protected void parseRowsEvent(RowsLogEvent event) { try { System.out.println(String.format("================> binlog[%s:%s] , name[%s,%s]", binlogFileName, event.getHeader().getLogPos() - event.getHeader().getEventLen(), event.getTable().getDbName(), event.getTable().getTableName())); RowsLogBuffer buffer = event.getRowsBuf(charset.name()); BitSet columns = event.getColumns(); BitSet changeColumns = event.getChangeColumns(); while (buffer.nextOneRow(columns)) { // 处理row记录 int type = event.getHeader().getType(); if (LogEvent.WRITE_ROWS_EVENT_V1 == type || LogEvent.WRITE_ROWS_EVENT == type) { // insert的记录放在before字段中 parseOneRow(event, buffer, columns, true); } else if (LogEvent.DELETE_ROWS_EVENT_V1 == type || LogEvent.DELETE_ROWS_EVENT == type) { // delete的记录放在before字段中 parseOneRow(event, buffer, columns, false); } else { // update需要处理before/after System.out.println("-------> before"); parseOneRow(event, buffer, columns, false); if (!buffer.nextOneRow(changeColumns, true)) { break; } System.out.println("-------> after"); parseOneRow(event, buffer, changeColumns, true); } } } catch (Exception e) { throw new RuntimeException("parse row data failed.", e); } }
Example #8
Source File: DirectLogFetcherTest.java From canal-1.1.3 with Apache License 2.0 | 5 votes |
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 #9
Source File: BaseLogFetcherTest.java From canal with Apache License 2.0 | 5 votes |
protected void parseRowsEvent(RowsLogEvent event) { try { System.out.println(String.format("================> binlog[%s:%s] , name[%s,%s]", binlogFileName, event.getHeader().getLogPos() - event.getHeader().getEventLen(), event.getTable().getDbName(), event.getTable().getTableName())); RowsLogBuffer buffer = event.getRowsBuf(charset.name()); BitSet columns = event.getColumns(); BitSet changeColumns = event.getChangeColumns(); while (buffer.nextOneRow(columns)) { // 处理row记录 int type = event.getHeader().getType(); if (LogEvent.WRITE_ROWS_EVENT_V1 == type || LogEvent.WRITE_ROWS_EVENT == type) { // insert的记录放在before字段中 parseOneRow(event, buffer, columns, true); } else if (LogEvent.DELETE_ROWS_EVENT_V1 == type || LogEvent.DELETE_ROWS_EVENT == type) { // delete的记录放在before字段中 parseOneRow(event, buffer, columns, false); } else { // update需要处理before/after System.out.println("-------> before"); parseOneRow(event, buffer, columns, false); if (!buffer.nextOneRow(changeColumns, true)) { break; } System.out.println("-------> after"); parseOneRow(event, buffer, changeColumns, true); } } } catch (Exception e) { throw new RuntimeException("parse row data failed.", e); } }
Example #10
Source File: BaseLogFetcherTest.java From canal with Apache License 2.0 | 5 votes |
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 #11
Source File: DirectLogFetcherTest.java From canal with Apache License 2.0 | 5 votes |
protected void parseRowsEvent(RowsLogEvent event) { try { System.out.println(String.format("================> binlog[%s:%s] , name[%s,%s]", binlogFileName, event.getHeader().getLogPos() - event.getHeader().getEventLen(), event.getTable().getDbName(), event.getTable().getTableName())); RowsLogBuffer buffer = event.getRowsBuf(charset.name()); BitSet columns = event.getColumns(); BitSet changeColumns = event.getChangeColumns(); while (buffer.nextOneRow(columns)) { // 处理row记录 int type = event.getHeader().getType(); if (LogEvent.WRITE_ROWS_EVENT_V1 == type || LogEvent.WRITE_ROWS_EVENT == type) { // insert的记录放在before字段中 parseOneRow(event, buffer, columns, true); } else if (LogEvent.DELETE_ROWS_EVENT_V1 == type || LogEvent.DELETE_ROWS_EVENT == type) { // delete的记录放在before字段中 parseOneRow(event, buffer, columns, false); } else { // update需要处理before/after System.out.println("-------> before"); parseOneRow(event, buffer, columns, false); if (!buffer.nextOneRow(changeColumns, true)) { break; } System.out.println("-------> after"); parseOneRow(event, buffer, changeColumns, true); } } } catch (Exception e) { throw new RuntimeException("parse row data failed.", e); } }
Example #12
Source File: DirectLogFetcherTest.java From canal with Apache License 2.0 | 5 votes |
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); } } } }