本文整理汇总了Java中com.alibaba.otter.canal.protocol.CanalEntry.RowData类的典型用法代码示例。如果您正苦于以下问题:Java RowData类的具体用法?Java RowData怎么用?Java RowData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RowData类属于com.alibaba.otter.canal.protocol.CanalEntry包,在下文中一共展示了RowData类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertProtobufRecord
import com.alibaba.otter.canal.protocol.CanalEntry.RowData; //导入依赖的package包/类
public static <T extends Object> PairWrapper<String, Object> convertProtobufRecord(EntryHeader header, RowData rowData) {
PairWrapper<String, Object> wrapper = new PairWrapper<>();
List<Column> Columns = null;
if(header.isInsert() || header.isUpdate()){
Columns = rowData.getAfterColumnsList();
}else if(header.isDelete()){
Columns = rowData.getBeforeColumnsList();
}
wrapper.addProperties(Constants.MessageBodyKey.POS, header.getPos());
wrapper.addProperties(Constants.MessageBodyKey.OP_TS, header.getTsTime());
Map<String, Object> map = convert2map(Columns);
for (Map.Entry<String, Object> entry : map.entrySet()) {
wrapper.addPair(new Pair<>(entry.getKey(), CharSequence.class.isInstance(entry.getValue())?entry.getValue().toString():entry.getValue()));
}
return wrapper;
}
示例2: createBuilderWithSchema
import com.alibaba.otter.canal.protocol.CanalEntry.RowData; //导入依赖的package包/类
/**
* 创建DBusMessageBuilder对象,同时生成ums schema
*/
private DbusMessageBuilder createBuilderWithSchema(MetaVersion version, MessageEntry msgEntry) {
DbusMessageBuilder builder = new DbusMessageBuilder();
String namespace = builder.buildNameSpace(Utils.getDataSourceNamespace(),
msgEntry.getEntryHeader().getSchemaName(), msgEntry.getEntryHeader().getTableName(),
version.getVersion(), msgEntry.getEntryHeader().getPartitionTableName());
builder.build(DbusMessage.ProtocolType.DATA_INCREMENT_DATA, namespace, table.getBatchId());
EventType eventType = msgEntry.getEntryHeader().getOperType();
RowData rowData = msgEntry.getMsgColumn().getRowDataLst().get(0);
List<Column> columns = Support.getFinalColumns(eventType, rowData);
for (Column column : columns) {
String colType = Support.getColumnType(column);
if (Support.isSupported(colType)) {
builder.appendSchema(column.getName(), DataType.convertMysqlDataType(colType), true);
}
}
return builder;
}
示例3: buildMeta
import com.alibaba.otter.canal.protocol.CanalEntry.RowData; //导入依赖的package包/类
private MetaWrapper buildMeta(MessageEntry msgEntry) {
MetaWrapper metaWrapper = new MetaWrapper();
EntryHeader header = msgEntry.getEntryHeader();
RowData rowData = msgEntry.getMsgColumn().getRowDataLst().get(0);
List<Column> columns = Support.getFinalColumns(header.getOperType(), rowData);
for (Column column : columns) {
MetaWrapper.MetaCell cell = new MetaWrapper.MetaCell();
cell.setColumnName(column.getName());
cell.setDataType(Support.getColumnType(column));
int[] ret = Support.getColumnLengthAndPrecision(column);
cell.setDataLength(ret[0]);
cell.setDataPrecision(ret[1]);
cell.setDataScale(0);
cell.setIsPk(column.getIsKey() ? "Y" : "N");
cell.setNullAble("N");
cell.setDdlTime(new Timestamp(header.getExecuteTime()));
cell.setColumnId(column.getIndex());
cell.setInternalColumnId(column.getIndex());
cell.setHiddenColumn("NO");
cell.setVirtualColumn("NO");
metaWrapper.addMetaCell(cell);
}
return metaWrapper;
}
示例4: buildEvent
import com.alibaba.otter.canal.protocol.CanalEntry.RowData; //导入依赖的package包/类
private Event buildEvent() {
Event event = new Event();
event.setLogIdentity(new LogIdentity());
Header.Builder headBuilder = Header.newBuilder();
headBuilder.setEventLength(1000L);
headBuilder.setExecuteTime(new Date().getTime());
headBuilder.setLogfileName("mysql-bin.000001");
headBuilder.setLogfileOffset(1000L);
headBuilder.setSchemaName("test");
headBuilder.setTableName("ljh");
Entry.Builder entryBuilder = Entry.newBuilder();
entryBuilder.setHeader(headBuilder.build());
entryBuilder.setEntryType(EntryType.ROWDATA);
RowChange.Builder rowChangeBuilder = RowChange.newBuilder();
RowData.Builder rowDataBuilder = RowData.newBuilder();
rowChangeBuilder.addRowDatas(rowDataBuilder.build());
entryBuilder.setStoreValue(rowChangeBuilder.build().toByteString());
Entry entry = entryBuilder.build();
event.setEntry(entry);
return event;
}
示例5: convertProtobufRecordBeforeUpdate
import com.alibaba.otter.canal.protocol.CanalEntry.RowData; //导入依赖的package包/类
public static <T extends Object> PairWrapper<String, Object> convertProtobufRecordBeforeUpdate(EntryHeader header, RowData rowData) {
PairWrapper<String, Object> wrapper = new PairWrapper<>();
List<Column> Columns = rowData.getBeforeColumnsList();
Map<String, Object> map = convert2map(Columns);
for (Map.Entry<String, Object> entry : map.entrySet()) {
wrapper.addPair(new Pair<>(entry.getKey(), CharSequence.class.isInstance(entry.getValue())?entry.getValue().toString():entry.getValue()));
}
return wrapper;
}
示例6: getFinalColumns
import com.alibaba.otter.canal.protocol.CanalEntry.RowData; //导入依赖的package包/类
public static List<Column> getFinalColumns(EventType type, RowData rowData){
List<Column> Columns = null;
if(type == EventType.INSERT || type == EventType.UPDATE){
Columns = rowData.getAfterColumnsList();
}else if(type == EventType.DELETE){
Columns = rowData.getBeforeColumnsList();
}
return Columns;
}
示例7: checkCompatibleLoopback
import com.alibaba.otter.canal.protocol.CanalEntry.RowData; //导入依赖的package包/类
/**
* 检查otter3.0的兼容表处理,主要部分业务使用了3.0的功能,需要考虑兼容支持,后续可删除
*/
private int checkCompatibleLoopback(Pipeline pipeline, RowData rowData) {
// 检查_info字段
// 首先检查下after记录,从无变有的过程,一般出现在事务头
Column infokColumn = getColumnIgnoreCase(rowData.getAfterColumnsList(), compatibleMarkInfoColumn);
// 匹配对应的channel id
if (infokColumn != null && infokColumn.getValue().toUpperCase().endsWith(RETL_CLIENT_FLAG)) {
return 1;
}
infokColumn = getColumnIgnoreCase(rowData.getBeforeColumnsList(), compatibleMarkInfoColumn);
if (infokColumn != null && infokColumn.getValue().toUpperCase().endsWith(RETL_CLIENT_FLAG)) {
return 1;
}
// 检查_id字段
Column markColumn = getColumnIgnoreCase(rowData.getAfterColumnsList(), compatibleMarkIdentifierColumn);
// 匹配对应的channel id
if (markColumn != null && pipeline.getChannelId().equals(Long.parseLong(markColumn.getValue()))) {
return 2;
}
markColumn = getColumnIgnoreCase(rowData.getBeforeColumnsList(), compatibleMarkIdentifierColumn);
if (markColumn != null && pipeline.getChannelId().equals(Long.parseLong(markColumn.getValue()))) {
return 2;
}
return 0;
}
示例8: doSync
import com.alibaba.otter.canal.protocol.CanalEntry.RowData; //导入依赖的package包/类
@Override
protected void doSync(String database, String table, String index, String type, RowData rowData) {
List<Column> columns = rowData.getAfterColumnsList();
String primaryKey = Optional.ofNullable(mappingService.getTablePrimaryKeyMap().get(database + "." + table)).orElse("id");
Column idColumn = columns.stream().filter(column -> column.getIsKey() && primaryKey.equals(column.getName())).findFirst().orElse(null);
if (idColumn == null || StringUtils.isBlank(idColumn.getValue())) {
logger.warn("update_column_find_null_warn update从column中找不到主键,database=" + database + ",table=" + table);
return;
}
logger.debug("update_column_id_info update主键id,database=" + database + ",table=" + table + ",id=" + idColumn.getValue());
Map<String, Object> dataMap = parseColumnsToMap(columns);
elasticsearchService.update(index, type, idColumn.getValue(), dataMap);
logger.debug("update_es_info 同步es插入操作成功!database=" + database + ",table=" + table + ",data=" + dataMap);
}
示例9: doSync
import com.alibaba.otter.canal.protocol.CanalEntry.RowData; //导入依赖的package包/类
@Override
protected void doSync(String database, String table, String index, String type, RowData rowData) {
List<Column> columns = rowData.getAfterColumnsList();
String primaryKey = Optional.ofNullable(mappingService.getTablePrimaryKeyMap().get(database + "." + table)).orElse("id");
Column idColumn = columns.stream().filter(column -> column.getIsKey() && primaryKey.equals(column.getName())).findFirst().orElse(null);
if (idColumn == null || StringUtils.isBlank(idColumn.getValue())) {
logger.warn("insert_column_find_null_warn insert从column中找不到主键,database=" + database + ",table=" + table);
return;
}
logger.debug("insert_column_id_info insert主键id,database=" + database + ",table=" + table + ",id=" + idColumn.getValue());
Map<String, Object> dataMap = parseColumnsToMap(columns);
elasticsearchService.insertById(index, type, idColumn.getValue(), dataMap);
logger.debug("insert_es_info 同步es插入操作成功!database=" + database + ",table=" + table + ",data=" + JsonUtil.toJson(dataMap));
}
示例10: doSync
import com.alibaba.otter.canal.protocol.CanalEntry.RowData; //导入依赖的package包/类
@Override
protected void doSync(String database, String table, String index, String type, RowData rowData) {
List<Column> columns = rowData.getBeforeColumnsList();
String primaryKey = Optional.ofNullable(mappingService.getTablePrimaryKeyMap().get(database + "." + table)).orElse("id");
Column idColumn = columns.stream().filter(column -> column.getIsKey() && primaryKey.equals(column.getName())).findFirst().orElse(null);
if (idColumn == null || StringUtils.isBlank(idColumn.getValue())) {
logger.warn("insert_column_find_null_warn insert从column中找不到主键,database=" + database + ",table=" + table);
return;
}
logger.debug("insert_column_id_info insert主键id,database=" + database + ",table=" + table + ",id=" + idColumn.getValue());
elasticsearchService.deleteById(index, type, idColumn.getValue());
logger.debug("insert_es_info 同步es插入操作成功!database=" + database + ",table=" + table + ",id=" + idColumn.getValue());
}
示例11: getRowDataLst
import com.alibaba.otter.canal.protocol.CanalEntry.RowData; //导入依赖的package包/类
public List<RowData> getRowDataLst() {
return rowDataLst;
}
示例12: setRowDataLst
import com.alibaba.otter.canal.protocol.CanalEntry.RowData; //导入依赖的package包/类
public void setRowDataLst(List<RowData> rowDataLst) {
this.rowDataLst = rowDataLst;
}
示例13: checkLoopback
import com.alibaba.otter.canal.protocol.CanalEntry.RowData; //导入依赖的package包/类
/**
* <pre>
* the table def:
* channel_info varchar
* channel_id varchar
* 每次解析时,每个事务首先获取 retl_mark 下的 channel_info 或 channel_id 字段变更。
* a. 如果存在 channel_info 以 '_SYNC'结尾的字符串 ,则忽略本次事务的数据变更;
* b. 如果不等于,则执行下面的判断。
* i. 如果存在channel_id = "xx",则检查对应的channel_id是否为当前同步的channelId,如果是则忽略。
* ii. 不存在则不处理
* </pre>
*/
private int checkLoopback(Pipeline pipeline, RowData rowData) {
// 检查channel_info字段
// 首先检查下after记录,从无变有的过程,一般出现在事务头
Column infokColumn = getColumnIgnoreCase(rowData.getAfterColumnsList(), pipeline.getParameters()
.getSystemMarkTableInfo());
// 匹配对应的channelInfo,如果以_SYNC结尾,则认为需要忽略
if (infokColumn != null && StringUtils.endsWithIgnoreCase(infokColumn.getValue(), RETL_CLIENT_FLAG)) {
return 1;
}
// 匹配对应的channelInfo,如果相同,则认为需要忽略,并返回2,代表需要进行回环补救check机制,因为这个变更也是otter系统产生的
if (infokColumn != null
&& StringUtils.equalsIgnoreCase(infokColumn.getValue(), pipeline.getParameters().getChannelInfo())) {
return 2;
}
infokColumn = getColumnIgnoreCase(rowData.getBeforeColumnsList(), pipeline.getParameters()
.getSystemMarkTableInfo());
// 匹配对应的channelInfo,如果以_SYNC结尾,则认为需要忽略
if (infokColumn != null && StringUtils.endsWithIgnoreCase(infokColumn.getValue(), RETL_CLIENT_FLAG)) {
return 1;
}
// 匹配对应的channelInfo,如果相同,则认为需要忽略,并返回2,代表需要进行回环补救check机制,因为这个变更也是otter系统产生的
if (infokColumn != null
&& StringUtils.equalsIgnoreCase(infokColumn.getValue(), pipeline.getParameters().getChannelInfo())) {
return 2;
}
// 检查channel_id字段
Column markColumn = getColumnIgnoreCase(rowData.getAfterColumnsList(), pipeline.getParameters()
.getSystemMarkTableColumn());
// 匹配对应的channel id
if (markColumn != null && pipeline.getChannelId().equals(Long.parseLong(markColumn.getValue()))) {
return 2;
}
markColumn = getColumnIgnoreCase(rowData.getBeforeColumnsList(), pipeline.getParameters()
.getSystemMarkTableColumn());
if (markColumn != null && pipeline.getChannelId().equals(Long.parseLong(markColumn.getValue()))) {
return 2;
}
return 0;
}
示例14: doSync
import com.alibaba.otter.canal.protocol.CanalEntry.RowData; //导入依赖的package包/类
protected abstract void doSync(String database, String table, String index, String type, RowData rowData);