Java Code Examples for com.alibaba.otter.canal.parse.inbound.TableMeta.FieldMeta#setColumnName()
The following examples show how to use
com.alibaba.otter.canal.parse.inbound.TableMeta.FieldMeta#setColumnName() .
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: TableMetaCache.java From canal-1.1.3 with Apache License 2.0 | 5 votes |
/** * 处理desc table的结果 */ public static List<FieldMeta> parseTableMetaByDesc(ResultSetPacket packet) { Map<String, Integer> nameMaps = new HashMap<String, Integer>(6, 1f); int index = 0; for (FieldPacket fieldPacket : packet.getFieldDescriptors()) { nameMaps.put(fieldPacket.getOriginalName(), index++); } int size = packet.getFieldDescriptors().size(); int count = packet.getFieldValues().size() / packet.getFieldDescriptors().size(); List<FieldMeta> result = new ArrayList<FieldMeta>(); for (int i = 0; i < count; i++) { FieldMeta meta = new FieldMeta(); // 做一个优化,使用String.intern(),共享String对象,减少内存使用 meta.setColumnName(packet.getFieldValues().get(nameMaps.get(COLUMN_NAME) + i * size).intern()); meta.setColumnType(packet.getFieldValues().get(nameMaps.get(COLUMN_TYPE) + i * size)); meta.setNullable(StringUtils.equalsIgnoreCase(packet.getFieldValues().get(nameMaps.get(IS_NULLABLE) + i * size), "YES")); meta.setKey("PRI".equalsIgnoreCase(packet.getFieldValues().get(nameMaps.get(COLUMN_KEY) + i * size))); meta.setUnique("UNI".equalsIgnoreCase(packet.getFieldValues().get(nameMaps.get(COLUMN_KEY) + i * size))); // 特殊处理引号 meta.setDefaultValue(DruidDdlParser.unescapeQuotaName(packet.getFieldValues() .get(nameMaps.get(COLUMN_DEFAULT) + i * size))); meta.setExtra(packet.getFieldValues().get(nameMaps.get(EXTRA) + i * size)); result.add(meta); } return result; }
Example 2
Source File: TableMetaCache.java From canal with Apache License 2.0 | 5 votes |
/** * 处理desc table的结果 */ public static List<FieldMeta> parseTableMetaByDesc(ResultSetPacket packet) { Map<String, Integer> nameMaps = new HashMap<String, Integer>(6, 1f); int index = 0; for (FieldPacket fieldPacket : packet.getFieldDescriptors()) { nameMaps.put(fieldPacket.getOriginalName(), index++); } int size = packet.getFieldDescriptors().size(); int count = packet.getFieldValues().size() / packet.getFieldDescriptors().size(); List<FieldMeta> result = new ArrayList<FieldMeta>(); for (int i = 0; i < count; i++) { FieldMeta meta = new FieldMeta(); // 做一个优化,使用String.intern(),共享String对象,减少内存使用 meta.setColumnName(packet.getFieldValues().get(nameMaps.get(COLUMN_NAME) + i * size).intern()); meta.setColumnType(packet.getFieldValues().get(nameMaps.get(COLUMN_TYPE) + i * size)); meta.setNullable(StringUtils.equalsIgnoreCase(packet.getFieldValues().get(nameMaps.get(IS_NULLABLE) + i * size), "YES")); meta.setKey("PRI".equalsIgnoreCase(packet.getFieldValues().get(nameMaps.get(COLUMN_KEY) + i * size))); meta.setUnique("UNI".equalsIgnoreCase(packet.getFieldValues().get(nameMaps.get(COLUMN_KEY) + i * size))); // 特殊处理引号 meta.setDefaultValue(DruidDdlParser.unescapeQuotaName(packet.getFieldValues() .get(nameMaps.get(COLUMN_DEFAULT) + i * size))); meta.setExtra(packet.getFieldValues().get(nameMaps.get(EXTRA) + i * size)); result.add(meta); } return result; }