use of com.alibaba.otter.shared.etl.model.EventColumn in project otter by alibaba.
the class DbLoadMergerTest method makeUpdateEventData.
private EventData makeUpdateEventData() {
EventData eventData = new EventData();
eventData.setEventType(EventType.UPDATE);
eventData.setSchemaName(SCHEMA_NAME);
eventData.setTableName(TABLE_NAME);
eventData.setTableId(TABLE_ID);
List<EventColumn> keys = new ArrayList<EventColumn>();
keys.add(makeEventColumn(KEY_NAME, KEY_VALUE, true));
eventData.setKeys(keys);
List<EventColumn> columns = new ArrayList<EventColumn>();
int i = 0;
for (String columnName : COLUMN_NAMES2) {
columns.add(makeEventColumn(columnName, columnName + i, false));
i++;
}
eventData.setColumns(columns);
return eventData;
}
use of com.alibaba.otter.shared.etl.model.EventColumn in project otter by alibaba.
the class DbLoadMergerTest method makeEventColumn.
private EventColumn makeEventColumn(String columnName, String columnValue, boolean key) {
EventColumn eventColumn = new EventColumn();
eventColumn.setColumnName(columnName);
eventColumn.setColumnType(COLUMN_TYPE);
eventColumn.setColumnValue(columnValue);
eventColumn.setKey(key);
return eventColumn;
}
use of com.alibaba.otter.shared.etl.model.EventColumn in project otter by alibaba.
the class DbLoadMergerTest method makeDeleteEventData.
private EventData makeDeleteEventData() {
EventData eventData = new EventData();
eventData.setEventType(EventType.DELETE);
eventData.setSchemaName(SCHEMA_NAME);
eventData.setTableName(TABLE_NAME);
eventData.setTableId(TABLE_ID);
List<EventColumn> keys = new ArrayList<EventColumn>();
keys.add(makeEventColumn(KEY_NAME, KEY_VALUE, true));
eventData.setKeys(keys);
return eventData;
}
use of com.alibaba.otter.shared.etl.model.EventColumn in project otter by alibaba.
the class DbLoadMergerTest method testMergeWithSameKeyOfIUD.
/**
* 测试insert+update+delete
*/
@Test
public void testMergeWithSameKeyOfIUD() {
Map<RowKey, EventData> mergeMap = new MapMaker().makeMap();
DbLoadMerger.merge(makeInsertEventData(), mergeMap);
DbLoadMerger.merge(makeUpdateEventData(), mergeMap);
DbLoadMerger.merge(makeDeleteEventData(), mergeMap);
for (Entry<RowKey, EventData> entry : mergeMap.entrySet()) {
RowKey key = entry.getKey();
EventColumn keyColumn = key.getKeys().get(0);
Assert.assertEquals(KEY_VALUE, keyColumn.getColumnValue());
Assert.assertEquals(KEY_NAME, keyColumn.getColumnName());
EventData eventData = entry.getValue();
Assert.assertEquals(SCHEMA_NAME, eventData.getSchemaName());
Assert.assertEquals(TABLE_NAME, eventData.getTableName());
Assert.assertEquals(TABLE_ID, eventData.getTableId());
Assert.assertEquals(EventType.DELETE, eventData.getEventType());
// 不存在oldKeys
Assert.assertEquals(eventData.getOldKeys().size(), 0);
List<EventColumn> columns = eventData.getColumns();
Assert.assertEquals(0, columns.size());
}
}
use of com.alibaba.otter.shared.etl.model.EventColumn in project otter by alibaba.
the class DbLoadMergerTest method makeUpdateEventData.
private EventData makeUpdateEventData(String oldKeyValue, String newKeyValue) {
EventData eventData = new EventData();
eventData.setEventType(EventType.UPDATE);
eventData.setSchemaName(SCHEMA_NAME);
eventData.setTableName(TABLE_NAME);
eventData.setTableId(TABLE_ID);
List<EventColumn> oldKeys = new ArrayList<EventColumn>();
oldKeys.add(makeEventColumn(KEY_NAME, oldKeyValue, true));
List<EventColumn> newKeys = new ArrayList<EventColumn>();
newKeys.add(makeEventColumn(KEY_NAME, newKeyValue, true));
eventData.setKeys(newKeys);
eventData.setOldKeys(oldKeys);
return eventData;
}
Aggregations