in spanner-data-validator-java/src/main/java/com/google/migration/partitioning/IntegerPartitionRangeListFetcher.java [112:150]
public List<PartitionRange> getPartitionRangesWithPartitionFilter(String startStr,
String endStr,
Integer partitionCount,
Integer partitionFilterRatio) {
Integer start = Integer.parseInt(startStr);
Integer end = Integer.parseInt(endStr);
Integer fullRange = end - start;
Integer stepSize = fullRange/partitionCount;
if(partitionFilterRatio > 0) {
if(partitionFilterRatio < partitionCount) {
throw new RuntimeException("PartitionFilterRatio < PartitionCount!");
}
}
ArrayList<PartitionRange> bRanges = new ArrayList<>();
// Account for first item
bRanges.add(new PartitionRange(start.toString(), start.toString()));
Integer maxRange = start + 1;
for(Integer i = 0; i < partitionCount - 1; i++) {
Integer minRange = maxRange;
maxRange = minRange + stepSize;
if(partitionFilterRatio > 0 && i % partitionFilterRatio != 0) continue;
PartitionRange range = new PartitionRange(minRange.toString(), maxRange.toString());
bRanges.add(range);
}
PartitionRange range = new PartitionRange(maxRange.toString(), end.toString());
bRanges.add(range);
return bRanges;
}