datax是一種數(shù)據(jù)同步工具,可以將不同數(shù)據(jù)源之間的數(shù)據(jù)進(jìn)行同步,而在實際應(yīng)用中,我們通常需要將數(shù)據(jù)進(jìn)行轉(zhuǎn)換和映射處理,此時datax的json插件就顯得尤為重要了。
{ "job": { "content": [ { "reader": { "name": "mysqlreader", "parameter": { "column": ["id", "name", "age"], "connection": [ { "jdbcUrl": ["jdbc:mysql://localhost:3306/test"], "table": ["user"] } ], "fetchSize": 10 } }, "transformer": [ { "name": "regex", "parameter": { "columnIndex": [1, 2], "pattern": "[a|b]", "replacement": "c" } } ], "writer": { "name": "mysqlwriter", "parameter": { "column": ["id", "name", "age"], "connection": [ { "jdbcUrl": "jdbc:mysql://localhost:3306/test", "table": "user" } ] } } } ], "setting": { "speed": { "channel": 2 } } } }
上述代碼片段展示了一個簡單的datax job配置,包括了mysqlreader作為數(shù)據(jù)讀取源,regex作為數(shù)據(jù)轉(zhuǎn)換模塊,mysqlwriter作為數(shù)據(jù)寫入目地。json格式使得配置更加清晰易懂,并且datax針對不同的數(shù)據(jù)源和轉(zhuǎn)換模塊都提供了豐富的json配置選項。