@Override
public List<IParam> split() {
if(!needSplit) {
List<IParam> paramList = new ArrayList<IParam>() ;
IParam paramNoSplitted = param.clone();
if(sql.isEmpty()&&!tableName.isEmpty()&&!columns.isEmpty()){
String noSplitSql = "";
if(!where.isEmpty()) {
noSplitSql = String.format(SIMPLE_SQL_WITH_WHERE_PATTEN, columns, tableName, where);
} else {
noSplitSql = String.format(SIMPLE_SQL_WITHOUT_WHERE_PATTEN, columns, tableName);
}
noSplitSql = String.format(COPY_SQL,noSplitSql);
paramNoSplitted.putValue(ParamKey.sql, noSplitSql);
paramList.add(paramNoSplitted);
} else {
sql = String.format(COPY_SQL,sql);
paramNoSplitted.putValue(ParamKey.sql, sql);
paramList.add(paramNoSplitted);
}
return paramList;
}
if(partitionName.isEmpty() || partitionValue.isEmpty() || tableName.isEmpty()){
return super.split();
}
logger.info("Greenplum reader start to split");
List<IParam> paramList = new ArrayList<IParam>() ;
List<String> partitionList = getPartitionValueList();
StringBuilder []sqlArray = new StringBuilder[concurrency];
for(int i = 0; i < partitionList.size(); i++){
String sqlSplitted = null;
if(!where.isEmpty()) {
sqlSplitted = String.format(SQL_WITH_WHERE_PATTEN, columns, tableName, where, partitionName,partitionList.get(i));
} else {
sqlSplitted = String.format(SQL_WITHOUT_WHERE_PATTEN, columns, tableName, partitionName,partitionList.get(i));
}
sqlSplitted = String.format(COPY_SQL,sqlSplitted);
int index = (int) (i%concurrency);
if(sqlArray[index] == null){
sqlArray[index] = new StringBuilder();
}
sqlArray[index].append(sqlSplitted).append(";") ;
}
for(int j = 0; j < concurrency; j++){
if(sqlArray[j] == null) {
continue;
}
IParam paramSplitted = param.clone();
paramSplitted.putValue(ParamKey.sql, sqlArray[j].toString());
logger.info(sqlArray[j].toString());
paramList.add(paramSplitted);
}
logger.info("Greenplum reader is splitted successfully");
return paramList;