use of com.qlangtech.tis.plugin.ds.tidb.TiKVDataSourceFactory in project plugins by qlangtech.
the class TestDataXTiDBReader method testTemplateGenerate.
public void testTemplateGenerate() throws Exception {
final String dataXName = "dataXName";
GetColsMeta getColsMeta = new GetColsMeta().invoke();
final TiKVDataSourceFactory dsFactory = getColsMeta.getDataSourceFactory();
DataXTiDBReader dataxReader = new DataXTiDBReader() {
@Override
public TiKVDataSourceFactory getDataSourceFactory() {
return dsFactory;
}
@Override
public Class<?> getOwnerClass() {
return DataXTiDBReader.class;
}
};
dataxReader.template = DataXTiDBReader.getDftTemplate();
dataxReader.setSelectedTabs(TestTiKVDataSourceFactory.createTabOfEmployees());
ReaderTemplate.validateDataXReader("tidb-datax-reader-template-assert.json", dataXName, dataxReader);
}
use of com.qlangtech.tis.plugin.ds.tidb.TiKVDataSourceFactory in project plugins by qlangtech.
the class TisDataXTiDBReader method getTiKVDataSource.
private static final List<IDataSourceDumper> getTiKVDataSource(Configuration config, Optional<Long> regionId) {
List<String> cols = config.getList("column", String.class);
String tableName = config.getString("table");
Configuration connection = config.getConfiguration("connection");
TiKVDataSourceFactory sourceFactory = new TiKVDataSourceFactory();
sourceFactory.pdAddrs = connection.getString("[0].pdAddrs");
sourceFactory.dbName = connection.getString("[0].dbName");
// sourceFactory.datetimeFormat = connection.getBool("datetimeFormat");
if (StringUtils.isBlank(sourceFactory.pdAddrs) || StringUtils.isBlank(sourceFactory.dbName)) {
throw new IllegalStateException("param 'pdAddrs' or 'dbName' can not be null,connection:" + connection.toJSON());
}
List<ColumnMetaData> tableMetadata = sourceFactory.getTableMetadata(tableName);
TISTable table = new TISTable();
table.setTableName(tableName);
table.setReflectCols(tableMetadata.stream().filter((cmeta) -> cols.contains(cmeta.getKey())).collect(Collectors.toList()));
DataDumpers dataDumpers = sourceFactory.getDataDumpers(table, regionId);
List<IDataSourceDumper> dumpers = Lists.newArrayList(dataDumpers.dumpers);
return dumpers;
}
Aggregations