/** * Iterate over keys within the passed range, splitting at an [a,b) boundary. */ public static Iterable<byte[]> iterateOnSplits(final byte[] a, final byte[] b, final int num) { return iterateOnSplits(a, b, false, num); }
/** * 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 inclusive Whether the end of range is prefix-inclusive or is * considered an exclusive boundary. Automatic splits are generally exclusive * and manual splits with an explicit range utilize an inclusive end of range. * @param num Number of times to split range. Pass 1 if you want to split * the range in two; i.e. one split. * @return Array of dividing values */ public static byte[][] split(final byte[] a, final byte[] b, boolean inclusive, final int num) { byte[][] ret = new byte[num + 2][]; int i = 0; Iterable<byte[]> iter = iterateOnSplits(a, b, inclusive, num); if (iter == null) return null; for (byte[] elem : iter) { ret[i++] = elem; } return ret; }
/** * Iterate over keys within the passed range, splitting at an [a,b) boundary. */ public static Iterable<byte[]> iterateOnSplits(final byte[] a, final byte[] b, final int num) { return iterateOnSplits(a, b, false, num); }
/** * Iterate over keys within the passed range, splitting at an [a,b) boundary. */ public static Iterable<byte[]> iterateOnSplits(final byte[] a, final byte[] b, final int num) { return iterateOnSplits(a, b, false, num); }
/** * 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 inclusive Whether the end of range is prefix-inclusive or is * considered an exclusive boundary. Automatic splits are generally exclusive * and manual splits with an explicit range utilize an inclusive end of range. * @param num Number of times to split range. Pass 1 if you want to split * the range in two; i.e. one split. * @return Array of dividing values */ public static byte[][] split(final byte[] a, final byte[] b, boolean inclusive, final int num) { byte[][] ret = new byte[num + 2][]; int i = 0; Iterable<byte[]> iter = iterateOnSplits(a, b, inclusive, num); if (iter == null) return null; for (byte[] elem : iter) { ret[i++] = elem; } return ret; }
/** * 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 inclusive Whether the end of range is prefix-inclusive or is * considered an exclusive boundary. Automatic splits are generally exclusive * and manual splits with an explicit range utilize an inclusive end of range. * @param num Number of times to split range. Pass 1 if you want to split * the range in two; i.e. one split. * @return Array of dividing values */ public static byte[][] split(final byte[] a, final byte[] b, boolean inclusive, final int num) { byte[][] ret = new byte[num + 2][]; int i = 0; Iterable<byte[]> iter = iterateOnSplits(a, b, inclusive, num); if (iter == null) return null; for (byte[] elem : iter) { ret[i++] = elem; } return ret; }