TableRef tableRef = getTableRef(conn, ts);
PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class);
final List<HRegionLocation> regions = pconn.getQueryServices().getAllTableRegions(tableRef.getTable().getPhysicalName().getBytes());
PhoenixStatement statement = new PhoenixStatement(pconn);
StatementContext context = new StatementContext(statement, null, scan, new SequenceManager(statement));
DefaultParallelIteratorRegionSplitter splitter = new DefaultParallelIteratorRegionSplitter(context, tableRef, HintNode.EMPTY_HINT_NODE) {
@Override
protected List<HRegionLocation> getAllRegions() throws SQLException {
return DefaultParallelIteratorRegionSplitter.filterRegions(regions, scan.getStartRow(), scan.getStopRow());
}
};
List<KeyRange> keyRanges = splitter.getSplits();
Collections.sort(keyRanges, new Comparator<KeyRange>() {
@Override
public int compare(KeyRange o1, KeyRange o2) {
return Bytes.compareTo(o1.getLowerRange(),o2.getLowerRange());
}