use of com.alibaba.datax.plugin.reader.otsreader.model.OTSRange in project DataX by alibaba.
the class RangeSplit method rangeSplitByPoint.
public static List<OTSRange> rangeSplitByPoint(TableMeta meta, RowPrimaryKey beginPK, RowPrimaryKey endPK, List<PrimaryKeyValue> splits) {
List<OTSRange> results = new ArrayList<OTSRange>();
int pkCount = meta.getPrimaryKey().size();
String partName = Common.getPartitionKey(meta).getName();
PrimaryKeyValue begin = beginPK.getPrimaryKey().get(partName);
PrimaryKeyValue end = endPK.getPrimaryKey().get(partName);
List<PrimaryKeyValue> newSplits = getSplitPoint(begin, end, splits);
if (newSplits.isEmpty()) {
return results;
}
for (int i = 0; i < newSplits.size() - 1; i++) {
OTSRange item = new OTSRange(ParamChecker.checkInputPrimaryKeyAndGet(meta, getCompletePK(pkCount, newSplits.get(i))), ParamChecker.checkInputPrimaryKeyAndGet(meta, getCompletePK(pkCount, newSplits.get(i + 1))));
results.add(item);
}
// replace first and last
OTSRange first = results.get(0);
OTSRange last = results.get(results.size() - 1);
first.setBegin(beginPK);
last.setEnd(endPK);
return results;
}
Aggregations