• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DeleteRowsEventData类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.github.shyiko.mysql.binlog.event.DeleteRowsEventData的典型用法代码示例。如果您正苦于以下问题:Java DeleteRowsEventData类的具体用法?Java DeleteRowsEventData怎么用?Java DeleteRowsEventData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DeleteRowsEventData类属于com.github.shyiko.mysql.binlog.event包,在下文中一共展示了DeleteRowsEventData类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: toRecords

import com.github.shyiko.mysql.binlog.event.DeleteRowsEventData; //导入依赖的package包/类
private List<Record> toRecords(Table table,
                               EventHeader eventHeader,
                               DeleteRowsEventData eventData,
                               SourceOffset offset) {
  List<Record> res = new ArrayList<>(eventData.getRows().size());
  for (Serializable[] row : eventData.getRows()) {
    Record record = recordFactory.create(offset.format());
    Map<String, Field> fields = createHeader(table, eventHeader, offset);
    fields.put(TYPE_FIELD, create("DELETE"));
    record.getHeader().setAttribute(
        OperationType.SDC_OPERATION_TYPE,
        String.valueOf(OperationType.DELETE_CODE)
    );
    List<ColumnValue> columnValues = zipColumnsValues(eventData.getIncludedColumns(), table, row);
    Map<String, Field> data = toMap(columnValues);
    fields.put(OLD_DATA_FIELD, create(data));

    record.set(create(fields));
    res.add(record);
  }
  return res;
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:23,代码来源:RecordConverter.java


示例2: dispatch

import com.github.shyiko.mysql.binlog.event.DeleteRowsEventData; //导入依赖的package包/类
void dispatch(Event evt) {
  Object data = evt.getData();
  if (TableMapEventData.class.isInstance(data)) {
    handleTableMapEvent((TableMapEventData) data);
  } else if (EventType.isWrite(evt.getHeader().getEventType())) {
    handleWriteEvent((WriteRowsEventData) data);
  } else if (EventType.isUpdate(evt.getHeader().getEventType())) {
    handleUpdateEvent((UpdateRowsEventData) data);
  } else if (EventType.isDelete(evt.getHeader().getEventType())) {
    handleDeleteEvent((DeleteRowsEventData) data);
  } else if (QueryEventData.class.isInstance(data)) {
    handleQueryEvent((QueryEventData) data);
  }
}
 
开发者ID:guoyu511,项目名称:vertx-mysql-binlog-client,代码行数:15,代码来源:EventDispatcher.java


示例3: handleDeleteEvent

import com.github.shyiko.mysql.binlog.event.DeleteRowsEventData; //导入依赖的package包/类
private void handleDeleteEvent(DeleteRowsEventData evt) {
  if (lastTableMap == null) {
    throw new IllegalStateException("Missing table map event");
  }
  evt.getRows()
     .forEach(row ->
       handleRowEvent(lastTableMap.getDatabase(), lastTableMap.getTable(),
         "delete", Arrays.asList(row))
     );
  lastTableMap = null;
}
 
开发者ID:guoyu511,项目名称:vertx-mysql-binlog-client,代码行数:12,代码来源:EventDispatcher.java


示例4: handleDeleteRows

import com.github.shyiko.mysql.binlog.event.DeleteRowsEventData; //导入依赖的package包/类
private void handleDeleteRows(DeleteRowsEventData data, List<DataChange> dataChanges) throws JsonProcessingException {
    System.out.println(data);
    TableMapEventData tableData = tableIdToDataMap.get(data.getTableId());
    Pair<String, String> tableUniqueName = new ImmutablePair<String, String>(tableData.getDatabase(), 
            tableData.getTable());
    
    TableMetadata tableMetadata = databaseNameToTableMetadata.get(tableUniqueName);
    // XXX Error handling if tableMetadata == null
    ArrayList<String> columnNames = tableMetadata.getColumnNames();
    List<Integer> primaryKeyIndices = tableMetadata.getPrimaryKeyIndices();
    
    List<Serializable[]> rows = data.getRows();
    for (Serializable[] row: rows) {
        
        Map<String, Serializable> primaryKeyMap = new HashMap<String, Serializable>();
        for (int index : primaryKeyIndices) {
            String columnName = columnNames.get(index);
            Serializable value = row[index];
            primaryKeyMap.put(columnName, value);
        }
       
        DataChange change = new DataChange();
        change.setPayload(null);
        change.setPrimaryKey(primaryKeyMap);
        change.setTableName(tableUniqueName);
        
        dataChanges.add(change);
    }
}
 
开发者ID:TiVo,项目名称:wombat,代码行数:30,代码来源:EventHandler.java


示例5: getColumnCount

import com.github.shyiko.mysql.binlog.event.DeleteRowsEventData; //导入依赖的package包/类
public int getColumnCount() {
    if (this.binlogEventV4 != null) {
        if (binlogEventV4.getHeader().getEventType() == MySQLConstants.DELETE_ROWS_EVENT) {
            return ((DeleteRowsEvent) binlogEventV4).getColumnCount().intValue();
        }
        else {
            return ((DeleteRowsEventV2) binlogEventV4).getColumnCount().intValue();
        }
    }
    else {
        BitSet includedColumns = ((DeleteRowsEventData) binlogConnectorEvent.getData()).getIncludedColumns();
        return includedColumns.cardinality();
    }
}
 
开发者ID:mysql-time-machine,项目名称:replicator,代码行数:15,代码来源:RawBinlogEventDeleteRows.java


示例6: getTableId

import com.github.shyiko.mysql.binlog.event.DeleteRowsEventData; //导入依赖的package包/类
public long getTableId() {
    if (this.binlogEventV4 != null) {
        if (binlogEventV4.getHeader().getEventType() == MySQLConstants.DELETE_ROWS_EVENT) {
            return ((DeleteRowsEvent) binlogEventV4).getTableId();
        }
        else {
            return ((DeleteRowsEventV2) binlogEventV4).getTableId();
        }
    }
    else {
        return ((DeleteRowsEventData) binlogConnectorEvent.getData()).getTableId();
    }
}
 
开发者ID:mysql-time-machine,项目名称:replicator,代码行数:14,代码来源:RawBinlogEventDeleteRows.java


示例7: onEvent

import com.github.shyiko.mysql.binlog.event.DeleteRowsEventData; //导入依赖的package包/类
@Override
public void onEvent(Event event) {
    try {

        EventData data = event.getData();

        if (! (event.getHeader() instanceof EventHeaderV4)) {
            throw new RuntimeException("Header is not V4!");
        }
        System.out.println(event);  

        EventHeaderV4 header = event.getHeader();

        List<DataChange> dataChanges = new ArrayList<DataChange>();
        
        EventType type = header.getEventType();
        if (type == EventType.TABLE_MAP) {
            handleTableMap((TableMapEventData) data);
        } else if (EventType.isWrite(type)) {
            handleWriteRows((WriteRowsEventData) data, dataChanges);
        } else if (EventType.isDelete(type)) {
            handleDeleteRows((DeleteRowsEventData) data, dataChanges);
        } else if (EventType.isUpdate(type)) {
            handleUpdateRows((UpdateRowsEventData) data, dataChanges);
        } else if (type == EventType.QUERY) {
            handleQuery((QueryEventData) data, header);
        } else if (type == EventType.ROTATE) {
            handleRotate((RotateEventData) data);
        } else if (type == EventType.XID) {
            handleXid((XidEventData) data, header);
        }

        for (DataChange change : dataChanges) {
            change.setOffset(this.transactionStartPosition,
                    this.binlogFilename, header.getPosition());
            change.setServerId(this.mysqlServerId);
            outputter.output(change);
        }
        
        outputter.flush();
        
    } catch (Throwable e) {
        // during development, on any and all errors, disconnect.
        // This allows me to learn what errors will happen, and how to
        // handle each one appropriately.
        e.printStackTrace();
        try {
            this.binlogClient.disconnect();
        } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }

    }
}
 
开发者ID:TiVo,项目名称:wombat,代码行数:56,代码来源:EventHandler.java


示例8: testOnEventDeleteRows

import com.github.shyiko.mysql.binlog.event.DeleteRowsEventData; //导入依赖的package包/类
public void testOnEventDeleteRows() {
	BinlogEventListener binlogEventListener = new BinlogEventListener(createBinaryLogClient(), createKafkaProducer());
	
	binlogEventListener.onEvent(createTableMapEvent(1, "database", "table"));
	
	EventHeaderV4 eventHeader = new EventHeaderV4();
	eventHeader.setEventType(EventType.EXT_DELETE_ROWS);
	
	DeleteRowsEventData eventData = new DeleteRowsEventData();
	eventData.setTableId(1);
	
	List<Serializable[]> rows = new ArrayList<Serializable[]>();
	
	Serializable[] row = { "1" };
	
	rows.add(row);
	
	eventData.setRows(rows);
	
	binlogEventListener.onEvent(new Event(eventHeader, eventData));
}
 
开发者ID:mrkamel,项目名称:replicaza,代码行数:22,代码来源:BinlogEventListenerTest.java


示例9: onEvent

import com.github.shyiko.mysql.binlog.event.DeleteRowsEventData; //导入依赖的package包/类
@Override
public void onEvent(Event event) {
  LOG.trace("Received event {}", event);
  EventType eventType = event.getHeader().getEventType();
  currentBinLogFileName = client.getBinlogFilename();
  switch (eventType) {
    case TABLE_MAP:
      handleTableMappingEvent((TableMapEventData) event.getData());
      break;
    case PRE_GA_WRITE_ROWS:
    case WRITE_ROWS:
    case EXT_WRITE_ROWS:
      handleRowEvent(event, event.<WriteRowsEventData>getData().getTableId());
      break;
    case PRE_GA_UPDATE_ROWS:
    case UPDATE_ROWS:
    case EXT_UPDATE_ROWS:
      handleRowEvent(event, event.<UpdateRowsEventData>getData().getTableId());
      break;
    case PRE_GA_DELETE_ROWS:
    case DELETE_ROWS:
    case EXT_DELETE_ROWS:
      handleRowEvent(event, event.<DeleteRowsEventData>getData().getTableId());
      break;
    case QUERY:
      QueryEventData queryEventData = event.getData();
      String query = queryEventData.getSql();
      if (isCommit(query)) {
        finishTx();
      } else if (isSchemaChangeQuery(query)) {
        schemaRepository.evictAll();
      }
      break;
    case XID:
      finishTx();
      break;
    case GTID:
      GtidEventData eventData = event.getData();
      currentGtidSet = client.getGtidSet();
      currentTxGtid = eventData.getGtid();
      currentTxEventSeqNo = 0;
      LOG.trace("Started new tx, gtid: {}", currentTxGtid);
      break;
    default:
      // ignore
      break;
  }
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:49,代码来源:BinaryLogConsumer.java



注:本文中的com.github.shyiko.mysql.binlog.event.DeleteRowsEventData类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SslConnector类代码示例发布时间:2022-05-23
下一篇:
Java ExtendedThrowableProxyConverter类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap