指定大小计算分片(ComputeSplitsBySize)接口一般用于计算引擎规划并发度等执行计划。ComputeSplitsBySize 可以将全表数据逻辑上划分成接近指定大小的若干分片,并返回这些分片之间的分割点以及分片所在机器的提示。

示例

private static void describeTable(SyncClient client) {
    // 以200MB划分分片
    ComputeSplitsBySizeRequest request = new ComputeSplitsBySizeRequest(TABLE_NAME, 2);
    ComputeSplitsBySizeResponse response = client.computeSplitsBySize(computeSplitsBySizeRequest);
    System.out.println("ConsumedCapacity=" + response.getConsumedCapacity().jsonize());
    System.out.println("PrimaryKeySchema=" + response.getPrimaryKeySchema());
    System.out.println("RequestId=" + response.getRequestId());
    System.out.println("TraceId=" + response.getTraceId());
    List<Split> splits = response.getSplits();
    System.out.println("splits.size=" + splits.size());
    Iterator<Split> iterator = splits.iterator();
    while (iterator.hasNext()) {
        Split split = iterator.next();
        System.out.println("split.getLocation()=" + split.getLocation());
        // split.getLowerBound()和split.getUpperBound()可以直接灌进RangeRowQueryCriteria交给getRange()或createRangeIterator()
        System.out.println("split.getLowerBound()=" + split.getLowerBound().jsonize());
        System.out.println("split.getUpperBound()=" + split.getUpperBound().jsonize());
    }
}