Split passed range. Expensive operation relatively. Uses BigInteger math. Useful splitting ranges for MapReduce jobs. @param a Beginning of range @param b End of range @param num Number of times to split range. Pass 1 if you want to split the range in two; i.e. o
(final byte[] a, final byte[] b, final int num)
| 1198 | * @return Array of dividing values |
| 1199 | */ |
| 1200 | public static byte[][] split(final byte[] a, final byte[] b, final int num) { |
| 1201 | byte[][] ret = new byte[num + 2][]; |
| 1202 | int i = 0; |
| 1203 | Iterable<byte[]> iter = iterateOnSplits(a, b, num); |
| 1204 | if (iter == null) |
| 1205 | return null; |
| 1206 | for (byte[] elem : iter) { |
| 1207 | ret[i++] = elem; |
| 1208 | } |
| 1209 | return ret; |
| 1210 | } |
| 1211 | |
| 1212 | /** |
| 1213 | * Iterate over keys within the passed inclusive range. |