com.taobao.tddl.dbsync.binlog.event.RowsLogEvent Java Examples
The following examples show how to use
com.taobao.tddl.dbsync.binlog.event.RowsLogEvent.
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: MysqlMultiStageCoprocessor.java From canal with Apache License 2.0 | 6 votes |
@Override public void onEvent(MessageEvent event) throws Exception { try { if (event.isNeedDmlParse()) { int eventType = event.getEvent().getHeader().getType(); CanalEntry.Entry entry = null; switch (eventType) { case LogEvent.ROWS_QUERY_LOG_EVENT: entry = logEventConvert.parse(event.getEvent(), false); break; default: // 单独解析dml事件 entry = logEventConvert.parseRowsEvent((RowsLogEvent) event.getEvent(), event.getTable()); } event.setEntry(entry); } } catch (Throwable e) { exception = new CanalParseException(e); throw exception; } }
Example #4
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 #5
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 #6
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 #7
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 #8
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 #9
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 #10
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 #11
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 #12
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 #13
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); } } } }
Example #14
Source File: LogEventConvert.java From canal-1.1.3 with Apache License 2.0 | 4 votes |
public Entry parseRowsEvent(RowsLogEvent event) { return parseRowsEvent(event, null); }
Example #15
Source File: LogEventConvert.java From canal with Apache License 2.0 | 4 votes |
public Entry parseRowsEvent(RowsLogEvent event) { return parseRowsEvent(event, null); }