hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [05/19] hbase-site git commit: Published site at 82d554e3783372cc6b05489452c815b57c06f6cd.
Date Thu, 27 Apr 2017 22:53:12 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/f9332e6e/devapidocs/src-html/org/apache/hadoop/hbase/util/Bytes.LexicographicalComparerHolder.UnsafeComparer.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/util/Bytes.LexicographicalComparerHolder.UnsafeComparer.html b/devapidocs/src-html/org/apache/hadoop/hbase/util/Bytes.LexicographicalComparerHolder.UnsafeComparer.html
index 3c7d6b4..3dea877 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/util/Bytes.LexicographicalComparerHolder.UnsafeComparer.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/util/Bytes.LexicographicalComparerHolder.UnsafeComparer.html
@@ -1583,1089 +1583,1084 @@
 <span class="sourceLineNo">1575</span>            length1 == length2) {<a name="line.1575"></a>
 <span class="sourceLineNo">1576</span>          return 0;<a name="line.1576"></a>
 <span class="sourceLineNo">1577</span>        }<a name="line.1577"></a>
-<span class="sourceLineNo">1578</span>        final int minLength = Math.min(length1, length2);<a name="line.1578"></a>
-<span class="sourceLineNo">1579</span>        final int minWords = minLength / SIZEOF_LONG;<a name="line.1579"></a>
-<span class="sourceLineNo">1580</span>        final long offset1Adj = offset1 + UnsafeAccess.BYTE_ARRAY_BASE_OFFSET;<a name="line.1580"></a>
-<span class="sourceLineNo">1581</span>        final long offset2Adj = offset2 + UnsafeAccess.BYTE_ARRAY_BASE_OFFSET;<a name="line.1581"></a>
-<span class="sourceLineNo">1582</span><a name="line.1582"></a>
-<span class="sourceLineNo">1583</span>        /*<a name="line.1583"></a>
-<span class="sourceLineNo">1584</span>         * Compare 8 bytes at a time. Benchmarking shows comparing 8 bytes at a<a name="line.1584"></a>
-<span class="sourceLineNo">1585</span>         * time is no slower than comparing 4 bytes at a time even on 32-bit.<a name="line.1585"></a>
-<span class="sourceLineNo">1586</span>         * On the other hand, it is substantially faster on 64-bit.<a name="line.1586"></a>
-<span class="sourceLineNo">1587</span>         */<a name="line.1587"></a>
-<span class="sourceLineNo">1588</span>        // This is the end offset of long parts.<a name="line.1588"></a>
-<span class="sourceLineNo">1589</span>        int j = minWords &lt;&lt; 3; // Same as minWords * SIZEOF_LONG<a name="line.1589"></a>
-<span class="sourceLineNo">1590</span>        for (int i = 0; i &lt; j; i += SIZEOF_LONG) {<a name="line.1590"></a>
-<span class="sourceLineNo">1591</span>          long lw = theUnsafe.getLong(buffer1, offset1Adj + (long) i);<a name="line.1591"></a>
-<span class="sourceLineNo">1592</span>          long rw = theUnsafe.getLong(buffer2, offset2Adj + (long) i);<a name="line.1592"></a>
-<span class="sourceLineNo">1593</span>          long diff = lw ^ rw;<a name="line.1593"></a>
-<span class="sourceLineNo">1594</span>          if (diff != 0) {<a name="line.1594"></a>
-<span class="sourceLineNo">1595</span>              return lessThanUnsignedLong(lw, rw) ? -1 : 1;<a name="line.1595"></a>
-<span class="sourceLineNo">1596</span>          }<a name="line.1596"></a>
-<span class="sourceLineNo">1597</span>        }<a name="line.1597"></a>
-<span class="sourceLineNo">1598</span>        int offset = j;<a name="line.1598"></a>
-<span class="sourceLineNo">1599</span><a name="line.1599"></a>
-<span class="sourceLineNo">1600</span>        if (minLength - offset &gt;= SIZEOF_INT) {<a name="line.1600"></a>
-<span class="sourceLineNo">1601</span>          int il = theUnsafe.getInt(buffer1, offset1Adj + offset);<a name="line.1601"></a>
-<span class="sourceLineNo">1602</span>          int ir = theUnsafe.getInt(buffer2, offset2Adj + offset);<a name="line.1602"></a>
-<span class="sourceLineNo">1603</span>          if (il != ir) {<a name="line.1603"></a>
-<span class="sourceLineNo">1604</span>            return lessThanUnsignedInt(il, ir) ? -1: 1;<a name="line.1604"></a>
-<span class="sourceLineNo">1605</span>          }<a name="line.1605"></a>
-<span class="sourceLineNo">1606</span>          offset += SIZEOF_INT;<a name="line.1606"></a>
-<span class="sourceLineNo">1607</span>        }<a name="line.1607"></a>
-<span class="sourceLineNo">1608</span>        if (minLength - offset &gt;= SIZEOF_SHORT) {<a name="line.1608"></a>
-<span class="sourceLineNo">1609</span>          short sl = theUnsafe.getShort(buffer1, offset1Adj + offset);<a name="line.1609"></a>
-<span class="sourceLineNo">1610</span>          short sr = theUnsafe.getShort(buffer2, offset2Adj + offset);<a name="line.1610"></a>
-<span class="sourceLineNo">1611</span>          if (sl != sr) {<a name="line.1611"></a>
-<span class="sourceLineNo">1612</span>            return lessThanUnsignedShort(sl, sr) ? -1: 1;<a name="line.1612"></a>
-<span class="sourceLineNo">1613</span>          }<a name="line.1613"></a>
-<span class="sourceLineNo">1614</span>          offset += SIZEOF_SHORT;<a name="line.1614"></a>
-<span class="sourceLineNo">1615</span>        }<a name="line.1615"></a>
-<span class="sourceLineNo">1616</span>        if (minLength - offset == 1) {<a name="line.1616"></a>
-<span class="sourceLineNo">1617</span>          int a = (buffer1[(int)(offset1 + offset)] &amp; 0xff);<a name="line.1617"></a>
-<span class="sourceLineNo">1618</span>          int b = (buffer2[(int)(offset2 + offset)] &amp; 0xff);<a name="line.1618"></a>
-<span class="sourceLineNo">1619</span>          if (a != b) {<a name="line.1619"></a>
-<span class="sourceLineNo">1620</span>            return a - b;<a name="line.1620"></a>
-<span class="sourceLineNo">1621</span>          }<a name="line.1621"></a>
-<span class="sourceLineNo">1622</span>        }<a name="line.1622"></a>
-<span class="sourceLineNo">1623</span>        return length1 - length2;<a name="line.1623"></a>
-<span class="sourceLineNo">1624</span>      }<a name="line.1624"></a>
-<span class="sourceLineNo">1625</span>    }<a name="line.1625"></a>
-<span class="sourceLineNo">1626</span>  }<a name="line.1626"></a>
-<span class="sourceLineNo">1627</span><a name="line.1627"></a>
-<span class="sourceLineNo">1628</span>  /**<a name="line.1628"></a>
-<span class="sourceLineNo">1629</span>   * @param left left operand<a name="line.1629"></a>
-<span class="sourceLineNo">1630</span>   * @param right right operand<a name="line.1630"></a>
-<span class="sourceLineNo">1631</span>   * @return True if equal<a name="line.1631"></a>
-<span class="sourceLineNo">1632</span>   */<a name="line.1632"></a>
-<span class="sourceLineNo">1633</span>  public static boolean equals(final byte [] left, final byte [] right) {<a name="line.1633"></a>
-<span class="sourceLineNo">1634</span>    // Could use Arrays.equals?<a name="line.1634"></a>
-<span class="sourceLineNo">1635</span>    //noinspection SimplifiableConditionalExpression<a name="line.1635"></a>
-<span class="sourceLineNo">1636</span>    if (left == right) return true;<a name="line.1636"></a>
-<span class="sourceLineNo">1637</span>    if (left == null || right == null) return false;<a name="line.1637"></a>
-<span class="sourceLineNo">1638</span>    if (left.length != right.length) return false;<a name="line.1638"></a>
-<span class="sourceLineNo">1639</span>    if (left.length == 0) return true;<a name="line.1639"></a>
+<span class="sourceLineNo">1578</span>        final int stride = 8;<a name="line.1578"></a>
+<span class="sourceLineNo">1579</span>        final int minLength = Math.min(length1, length2);<a name="line.1579"></a>
+<span class="sourceLineNo">1580</span>        int strideLimit = minLength &amp; ~(stride - 1);<a name="line.1580"></a>
+<span class="sourceLineNo">1581</span>        final long offset1Adj = offset1 + UnsafeAccess.BYTE_ARRAY_BASE_OFFSET;<a name="line.1581"></a>
+<span class="sourceLineNo">1582</span>        final long offset2Adj = offset2 + UnsafeAccess.BYTE_ARRAY_BASE_OFFSET;<a name="line.1582"></a>
+<span class="sourceLineNo">1583</span>        int i;<a name="line.1583"></a>
+<span class="sourceLineNo">1584</span><a name="line.1584"></a>
+<span class="sourceLineNo">1585</span>        /*<a name="line.1585"></a>
+<span class="sourceLineNo">1586</span>         * Compare 8 bytes at a time. Benchmarking on x86 shows a stride of 8 bytes is no slower<a name="line.1586"></a>
+<span class="sourceLineNo">1587</span>         * than 4 bytes even on 32-bit. On the other hand, it is substantially faster on 64-bit.<a name="line.1587"></a>
+<span class="sourceLineNo">1588</span>         */<a name="line.1588"></a>
+<span class="sourceLineNo">1589</span>        for (i = 0; i &lt; strideLimit; i += stride) {<a name="line.1589"></a>
+<span class="sourceLineNo">1590</span>          long lw = theUnsafe.getLong(buffer1, offset1Adj + (long) i);<a name="line.1590"></a>
+<span class="sourceLineNo">1591</span>          long rw = theUnsafe.getLong(buffer2, offset2Adj + (long) i);<a name="line.1591"></a>
+<span class="sourceLineNo">1592</span>          if (lw != rw) {<a name="line.1592"></a>
+<span class="sourceLineNo">1593</span>            if(!UnsafeAccess.littleEndian) {<a name="line.1593"></a>
+<span class="sourceLineNo">1594</span>              return ((lw + Long.MIN_VALUE) &lt; (rw + Long.MIN_VALUE)) ? -1 : 1;<a name="line.1594"></a>
+<span class="sourceLineNo">1595</span>            }<a name="line.1595"></a>
+<span class="sourceLineNo">1596</span><a name="line.1596"></a>
+<span class="sourceLineNo">1597</span>            /*<a name="line.1597"></a>
+<span class="sourceLineNo">1598</span>             * We want to compare only the first index where left[index] != right[index]. This<a name="line.1598"></a>
+<span class="sourceLineNo">1599</span>             * corresponds to the least significant nonzero byte in lw ^ rw, since lw and rw are<a name="line.1599"></a>
+<span class="sourceLineNo">1600</span>             * little-endian. Long.numberOfTrailingZeros(diff) tells us the least significant<a name="line.1600"></a>
+<span class="sourceLineNo">1601</span>             * nonzero bit, and zeroing out the first three bits of L.nTZ gives us the shift to get<a name="line.1601"></a>
+<span class="sourceLineNo">1602</span>             * that least significant nonzero byte. This comparison logic is based on UnsignedBytes<a name="line.1602"></a>
+<span class="sourceLineNo">1603</span>             * comparator from guava v21<a name="line.1603"></a>
+<span class="sourceLineNo">1604</span>             */<a name="line.1604"></a>
+<span class="sourceLineNo">1605</span>            int n = Long.numberOfTrailingZeros(lw ^ rw) &amp; ~0x7;<a name="line.1605"></a>
+<span class="sourceLineNo">1606</span>            return ((int) ((lw &gt;&gt;&gt; n) &amp; 0xFF)) - ((int) ((rw &gt;&gt;&gt; n) &amp; 0xFF));<a name="line.1606"></a>
+<span class="sourceLineNo">1607</span>          }<a name="line.1607"></a>
+<span class="sourceLineNo">1608</span>        }<a name="line.1608"></a>
+<span class="sourceLineNo">1609</span><a name="line.1609"></a>
+<span class="sourceLineNo">1610</span>        // The epilogue to cover the last (minLength % stride) elements.<a name="line.1610"></a>
+<span class="sourceLineNo">1611</span>        for (; i &lt; minLength; i++) {<a name="line.1611"></a>
+<span class="sourceLineNo">1612</span>          int a = (buffer1[offset1 + i] &amp; 0xFF);<a name="line.1612"></a>
+<span class="sourceLineNo">1613</span>          int b = (buffer2[offset2 + i] &amp; 0xFF);<a name="line.1613"></a>
+<span class="sourceLineNo">1614</span>          if (a != b) {<a name="line.1614"></a>
+<span class="sourceLineNo">1615</span>            return a - b;<a name="line.1615"></a>
+<span class="sourceLineNo">1616</span>          }<a name="line.1616"></a>
+<span class="sourceLineNo">1617</span>        }<a name="line.1617"></a>
+<span class="sourceLineNo">1618</span>        return length1 - length2;<a name="line.1618"></a>
+<span class="sourceLineNo">1619</span>      }<a name="line.1619"></a>
+<span class="sourceLineNo">1620</span>    }<a name="line.1620"></a>
+<span class="sourceLineNo">1621</span>  }<a name="line.1621"></a>
+<span class="sourceLineNo">1622</span><a name="line.1622"></a>
+<span class="sourceLineNo">1623</span>  /**<a name="line.1623"></a>
+<span class="sourceLineNo">1624</span>   * @param left left operand<a name="line.1624"></a>
+<span class="sourceLineNo">1625</span>   * @param right right operand<a name="line.1625"></a>
+<span class="sourceLineNo">1626</span>   * @return True if equal<a name="line.1626"></a>
+<span class="sourceLineNo">1627</span>   */<a name="line.1627"></a>
+<span class="sourceLineNo">1628</span>  public static boolean equals(final byte [] left, final byte [] right) {<a name="line.1628"></a>
+<span class="sourceLineNo">1629</span>    // Could use Arrays.equals?<a name="line.1629"></a>
+<span class="sourceLineNo">1630</span>    //noinspection SimplifiableConditionalExpression<a name="line.1630"></a>
+<span class="sourceLineNo">1631</span>    if (left == right) return true;<a name="line.1631"></a>
+<span class="sourceLineNo">1632</span>    if (left == null || right == null) return false;<a name="line.1632"></a>
+<span class="sourceLineNo">1633</span>    if (left.length != right.length) return false;<a name="line.1633"></a>
+<span class="sourceLineNo">1634</span>    if (left.length == 0) return true;<a name="line.1634"></a>
+<span class="sourceLineNo">1635</span><a name="line.1635"></a>
+<span class="sourceLineNo">1636</span>    // Since we're often comparing adjacent sorted data,<a name="line.1636"></a>
+<span class="sourceLineNo">1637</span>    // it's usual to have equal arrays except for the very last byte<a name="line.1637"></a>
+<span class="sourceLineNo">1638</span>    // so check that first<a name="line.1638"></a>
+<span class="sourceLineNo">1639</span>    if (left[left.length - 1] != right[right.length - 1]) return false;<a name="line.1639"></a>
 <span class="sourceLineNo">1640</span><a name="line.1640"></a>
-<span class="sourceLineNo">1641</span>    // Since we're often comparing adjacent sorted data,<a name="line.1641"></a>
-<span class="sourceLineNo">1642</span>    // it's usual to have equal arrays except for the very last byte<a name="line.1642"></a>
-<span class="sourceLineNo">1643</span>    // so check that first<a name="line.1643"></a>
-<span class="sourceLineNo">1644</span>    if (left[left.length - 1] != right[right.length - 1]) return false;<a name="line.1644"></a>
-<span class="sourceLineNo">1645</span><a name="line.1645"></a>
-<span class="sourceLineNo">1646</span>    return compareTo(left, right) == 0;<a name="line.1646"></a>
-<span class="sourceLineNo">1647</span>  }<a name="line.1647"></a>
-<span class="sourceLineNo">1648</span><a name="line.1648"></a>
-<span class="sourceLineNo">1649</span>  public static boolean equals(final byte[] left, int leftOffset, int leftLen,<a name="line.1649"></a>
-<span class="sourceLineNo">1650</span>                               final byte[] right, int rightOffset, int rightLen) {<a name="line.1650"></a>
-<span class="sourceLineNo">1651</span>    // short circuit case<a name="line.1651"></a>
-<span class="sourceLineNo">1652</span>    if (left == right &amp;&amp;<a name="line.1652"></a>
-<span class="sourceLineNo">1653</span>        leftOffset == rightOffset &amp;&amp;<a name="line.1653"></a>
-<span class="sourceLineNo">1654</span>        leftLen == rightLen) {<a name="line.1654"></a>
-<span class="sourceLineNo">1655</span>      return true;<a name="line.1655"></a>
-<span class="sourceLineNo">1656</span>    }<a name="line.1656"></a>
-<span class="sourceLineNo">1657</span>    // different lengths fast check<a name="line.1657"></a>
-<span class="sourceLineNo">1658</span>    if (leftLen != rightLen) {<a name="line.1658"></a>
-<span class="sourceLineNo">1659</span>      return false;<a name="line.1659"></a>
-<span class="sourceLineNo">1660</span>    }<a name="line.1660"></a>
-<span class="sourceLineNo">1661</span>    if (leftLen == 0) {<a name="line.1661"></a>
-<span class="sourceLineNo">1662</span>      return true;<a name="line.1662"></a>
-<span class="sourceLineNo">1663</span>    }<a name="line.1663"></a>
+<span class="sourceLineNo">1641</span>    return compareTo(left, right) == 0;<a name="line.1641"></a>
+<span class="sourceLineNo">1642</span>  }<a name="line.1642"></a>
+<span class="sourceLineNo">1643</span><a name="line.1643"></a>
+<span class="sourceLineNo">1644</span>  public static boolean equals(final byte[] left, int leftOffset, int leftLen,<a name="line.1644"></a>
+<span class="sourceLineNo">1645</span>                               final byte[] right, int rightOffset, int rightLen) {<a name="line.1645"></a>
+<span class="sourceLineNo">1646</span>    // short circuit case<a name="line.1646"></a>
+<span class="sourceLineNo">1647</span>    if (left == right &amp;&amp;<a name="line.1647"></a>
+<span class="sourceLineNo">1648</span>        leftOffset == rightOffset &amp;&amp;<a name="line.1648"></a>
+<span class="sourceLineNo">1649</span>        leftLen == rightLen) {<a name="line.1649"></a>
+<span class="sourceLineNo">1650</span>      return true;<a name="line.1650"></a>
+<span class="sourceLineNo">1651</span>    }<a name="line.1651"></a>
+<span class="sourceLineNo">1652</span>    // different lengths fast check<a name="line.1652"></a>
+<span class="sourceLineNo">1653</span>    if (leftLen != rightLen) {<a name="line.1653"></a>
+<span class="sourceLineNo">1654</span>      return false;<a name="line.1654"></a>
+<span class="sourceLineNo">1655</span>    }<a name="line.1655"></a>
+<span class="sourceLineNo">1656</span>    if (leftLen == 0) {<a name="line.1656"></a>
+<span class="sourceLineNo">1657</span>      return true;<a name="line.1657"></a>
+<span class="sourceLineNo">1658</span>    }<a name="line.1658"></a>
+<span class="sourceLineNo">1659</span><a name="line.1659"></a>
+<span class="sourceLineNo">1660</span>    // Since we're often comparing adjacent sorted data,<a name="line.1660"></a>
+<span class="sourceLineNo">1661</span>    // it's usual to have equal arrays except for the very last byte<a name="line.1661"></a>
+<span class="sourceLineNo">1662</span>    // so check that first<a name="line.1662"></a>
+<span class="sourceLineNo">1663</span>    if (left[leftOffset + leftLen - 1] != right[rightOffset + rightLen - 1]) return false;<a name="line.1663"></a>
 <span class="sourceLineNo">1664</span><a name="line.1664"></a>
-<span class="sourceLineNo">1665</span>    // Since we're often comparing adjacent sorted data,<a name="line.1665"></a>
-<span class="sourceLineNo">1666</span>    // it's usual to have equal arrays except for the very last byte<a name="line.1666"></a>
-<span class="sourceLineNo">1667</span>    // so check that first<a name="line.1667"></a>
-<span class="sourceLineNo">1668</span>    if (left[leftOffset + leftLen - 1] != right[rightOffset + rightLen - 1]) return false;<a name="line.1668"></a>
+<span class="sourceLineNo">1665</span>    return LexicographicalComparerHolder.BEST_COMPARER.<a name="line.1665"></a>
+<span class="sourceLineNo">1666</span>      compareTo(left, leftOffset, leftLen, right, rightOffset, rightLen) == 0;<a name="line.1666"></a>
+<span class="sourceLineNo">1667</span>  }<a name="line.1667"></a>
+<span class="sourceLineNo">1668</span><a name="line.1668"></a>
 <span class="sourceLineNo">1669</span><a name="line.1669"></a>
-<span class="sourceLineNo">1670</span>    return LexicographicalComparerHolder.BEST_COMPARER.<a name="line.1670"></a>
-<span class="sourceLineNo">1671</span>      compareTo(left, leftOffset, leftLen, right, rightOffset, rightLen) == 0;<a name="line.1671"></a>
-<span class="sourceLineNo">1672</span>  }<a name="line.1672"></a>
-<span class="sourceLineNo">1673</span><a name="line.1673"></a>
-<span class="sourceLineNo">1674</span><a name="line.1674"></a>
-<span class="sourceLineNo">1675</span>  /**<a name="line.1675"></a>
-<span class="sourceLineNo">1676</span>   * @param a left operand<a name="line.1676"></a>
-<span class="sourceLineNo">1677</span>   * @param buf right operand<a name="line.1677"></a>
-<span class="sourceLineNo">1678</span>   * @return True if equal<a name="line.1678"></a>
-<span class="sourceLineNo">1679</span>   */<a name="line.1679"></a>
-<span class="sourceLineNo">1680</span>  public static boolean equals(byte[] a, ByteBuffer buf) {<a name="line.1680"></a>
-<span class="sourceLineNo">1681</span>    if (a == null) return buf == null;<a name="line.1681"></a>
-<span class="sourceLineNo">1682</span>    if (buf == null) return false;<a name="line.1682"></a>
-<span class="sourceLineNo">1683</span>    if (a.length != buf.remaining()) return false;<a name="line.1683"></a>
-<span class="sourceLineNo">1684</span><a name="line.1684"></a>
-<span class="sourceLineNo">1685</span>    // Thou shalt not modify the original byte buffer in what should be read only operations.<a name="line.1685"></a>
-<span class="sourceLineNo">1686</span>    ByteBuffer b = buf.duplicate();<a name="line.1686"></a>
-<span class="sourceLineNo">1687</span>    for (byte anA : a) {<a name="line.1687"></a>
-<span class="sourceLineNo">1688</span>      if (anA != b.get()) {<a name="line.1688"></a>
-<span class="sourceLineNo">1689</span>        return false;<a name="line.1689"></a>
-<span class="sourceLineNo">1690</span>      }<a name="line.1690"></a>
-<span class="sourceLineNo">1691</span>    }<a name="line.1691"></a>
-<span class="sourceLineNo">1692</span>    return true;<a name="line.1692"></a>
-<span class="sourceLineNo">1693</span>  }<a name="line.1693"></a>
-<span class="sourceLineNo">1694</span><a name="line.1694"></a>
-<span class="sourceLineNo">1695</span><a name="line.1695"></a>
-<span class="sourceLineNo">1696</span>  /**<a name="line.1696"></a>
-<span class="sourceLineNo">1697</span>   * Return true if the byte array on the right is a prefix of the byte<a name="line.1697"></a>
-<span class="sourceLineNo">1698</span>   * array on the left.<a name="line.1698"></a>
-<span class="sourceLineNo">1699</span>   */<a name="line.1699"></a>
-<span class="sourceLineNo">1700</span>  public static boolean startsWith(byte[] bytes, byte[] prefix) {<a name="line.1700"></a>
-<span class="sourceLineNo">1701</span>    return bytes != null &amp;&amp; prefix != null &amp;&amp;<a name="line.1701"></a>
-<span class="sourceLineNo">1702</span>      bytes.length &gt;= prefix.length &amp;&amp;<a name="line.1702"></a>
-<span class="sourceLineNo">1703</span>      LexicographicalComparerHolder.BEST_COMPARER.<a name="line.1703"></a>
-<span class="sourceLineNo">1704</span>        compareTo(bytes, 0, prefix.length, prefix, 0, prefix.length) == 0;<a name="line.1704"></a>
-<span class="sourceLineNo">1705</span>  }<a name="line.1705"></a>
-<span class="sourceLineNo">1706</span><a name="line.1706"></a>
-<span class="sourceLineNo">1707</span>  /**<a name="line.1707"></a>
-<span class="sourceLineNo">1708</span>   * @param b bytes to hash<a name="line.1708"></a>
-<span class="sourceLineNo">1709</span>   * @return Runs {@link WritableComparator#hashBytes(byte[], int)} on the<a name="line.1709"></a>
-<span class="sourceLineNo">1710</span>   * passed in array.  This method is what {@link org.apache.hadoop.io.Text}<a name="line.1710"></a>
-<span class="sourceLineNo">1711</span>   * use calculating hash code.<a name="line.1711"></a>
-<span class="sourceLineNo">1712</span>   */<a name="line.1712"></a>
-<span class="sourceLineNo">1713</span>  public static int hashCode(final byte [] b) {<a name="line.1713"></a>
-<span class="sourceLineNo">1714</span>    return hashCode(b, b.length);<a name="line.1714"></a>
-<span class="sourceLineNo">1715</span>  }<a name="line.1715"></a>
-<span class="sourceLineNo">1716</span><a name="line.1716"></a>
-<span class="sourceLineNo">1717</span>  /**<a name="line.1717"></a>
-<span class="sourceLineNo">1718</span>   * @param b value<a name="line.1718"></a>
-<span class="sourceLineNo">1719</span>   * @param length length of the value<a name="line.1719"></a>
-<span class="sourceLineNo">1720</span>   * @return Runs {@link WritableComparator#hashBytes(byte[], int)} on the<a name="line.1720"></a>
-<span class="sourceLineNo">1721</span>   * passed in array.  This method is what {@link org.apache.hadoop.io.Text}<a name="line.1721"></a>
-<span class="sourceLineNo">1722</span>   * use calculating hash code.<a name="line.1722"></a>
-<span class="sourceLineNo">1723</span>   */<a name="line.1723"></a>
-<span class="sourceLineNo">1724</span>  public static int hashCode(final byte [] b, final int length) {<a name="line.1724"></a>
-<span class="sourceLineNo">1725</span>    return WritableComparator.hashBytes(b, length);<a name="line.1725"></a>
-<span class="sourceLineNo">1726</span>  }<a name="line.1726"></a>
-<span class="sourceLineNo">1727</span><a name="line.1727"></a>
-<span class="sourceLineNo">1728</span>  /**<a name="line.1728"></a>
-<span class="sourceLineNo">1729</span>   * @param b bytes to hash<a name="line.1729"></a>
-<span class="sourceLineNo">1730</span>   * @return A hash of &lt;code&gt;b&lt;/code&gt; as an Integer that can be used as key in<a name="line.1730"></a>
-<span class="sourceLineNo">1731</span>   * Maps.<a name="line.1731"></a>
-<span class="sourceLineNo">1732</span>   */<a name="line.1732"></a>
-<span class="sourceLineNo">1733</span>  public static Integer mapKey(final byte [] b) {<a name="line.1733"></a>
-<span class="sourceLineNo">1734</span>    return hashCode(b);<a name="line.1734"></a>
-<span class="sourceLineNo">1735</span>  }<a name="line.1735"></a>
-<span class="sourceLineNo">1736</span><a name="line.1736"></a>
-<span class="sourceLineNo">1737</span>  /**<a name="line.1737"></a>
-<span class="sourceLineNo">1738</span>   * @param b bytes to hash<a name="line.1738"></a>
-<span class="sourceLineNo">1739</span>   * @param length length to hash<a name="line.1739"></a>
-<span class="sourceLineNo">1740</span>   * @return A hash of &lt;code&gt;b&lt;/code&gt; as an Integer that can be used as key in<a name="line.1740"></a>
-<span class="sourceLineNo">1741</span>   * Maps.<a name="line.1741"></a>
-<span class="sourceLineNo">1742</span>   */<a name="line.1742"></a>
-<span class="sourceLineNo">1743</span>  public static Integer mapKey(final byte [] b, final int length) {<a name="line.1743"></a>
-<span class="sourceLineNo">1744</span>    return hashCode(b, length);<a name="line.1744"></a>
-<span class="sourceLineNo">1745</span>  }<a name="line.1745"></a>
-<span class="sourceLineNo">1746</span><a name="line.1746"></a>
-<span class="sourceLineNo">1747</span>  /**<a name="line.1747"></a>
-<span class="sourceLineNo">1748</span>   * @param a lower half<a name="line.1748"></a>
-<span class="sourceLineNo">1749</span>   * @param b upper half<a name="line.1749"></a>
-<span class="sourceLineNo">1750</span>   * @return New array that has a in lower half and b in upper half.<a name="line.1750"></a>
-<span class="sourceLineNo">1751</span>   */<a name="line.1751"></a>
-<span class="sourceLineNo">1752</span>  public static byte [] add(final byte [] a, final byte [] b) {<a name="line.1752"></a>
-<span class="sourceLineNo">1753</span>    return add(a, b, EMPTY_BYTE_ARRAY);<a name="line.1753"></a>
-<span class="sourceLineNo">1754</span>  }<a name="line.1754"></a>
-<span class="sourceLineNo">1755</span><a name="line.1755"></a>
-<span class="sourceLineNo">1756</span>  /**<a name="line.1756"></a>
-<span class="sourceLineNo">1757</span>   * @param a first third<a name="line.1757"></a>
-<span class="sourceLineNo">1758</span>   * @param b second third<a name="line.1758"></a>
-<span class="sourceLineNo">1759</span>   * @param c third third<a name="line.1759"></a>
-<span class="sourceLineNo">1760</span>   * @return New array made from a, b and c<a name="line.1760"></a>
-<span class="sourceLineNo">1761</span>   */<a name="line.1761"></a>
-<span class="sourceLineNo">1762</span>  public static byte [] add(final byte [] a, final byte [] b, final byte [] c) {<a name="line.1762"></a>
-<span class="sourceLineNo">1763</span>    byte [] result = new byte[a.length + b.length + c.length];<a name="line.1763"></a>
-<span class="sourceLineNo">1764</span>    System.arraycopy(a, 0, result, 0, a.length);<a name="line.1764"></a>
-<span class="sourceLineNo">1765</span>    System.arraycopy(b, 0, result, a.length, b.length);<a name="line.1765"></a>
-<span class="sourceLineNo">1766</span>    System.arraycopy(c, 0, result, a.length + b.length, c.length);<a name="line.1766"></a>
-<span class="sourceLineNo">1767</span>    return result;<a name="line.1767"></a>
-<span class="sourceLineNo">1768</span>  }<a name="line.1768"></a>
-<span class="sourceLineNo">1769</span><a name="line.1769"></a>
-<span class="sourceLineNo">1770</span>  /**<a name="line.1770"></a>
-<span class="sourceLineNo">1771</span>   * @param arrays all the arrays to concatenate together.<a name="line.1771"></a>
-<span class="sourceLineNo">1772</span>   * @return New array made from the concatenation of the given arrays.<a name="line.1772"></a>
-<span class="sourceLineNo">1773</span>   */<a name="line.1773"></a>
-<span class="sourceLineNo">1774</span>  public static byte [] add(final byte [][] arrays) {<a name="line.1774"></a>
-<span class="sourceLineNo">1775</span>    int length = 0;<a name="line.1775"></a>
+<span class="sourceLineNo">1670</span>  /**<a name="line.1670"></a>
+<span class="sourceLineNo">1671</span>   * @param a left operand<a name="line.1671"></a>
+<span class="sourceLineNo">1672</span>   * @param buf right operand<a name="line.1672"></a>
+<span class="sourceLineNo">1673</span>   * @return True if equal<a name="line.1673"></a>
+<span class="sourceLineNo">1674</span>   */<a name="line.1674"></a>
+<span class="sourceLineNo">1675</span>  public static boolean equals(byte[] a, ByteBuffer buf) {<a name="line.1675"></a>
+<span class="sourceLineNo">1676</span>    if (a == null) return buf == null;<a name="line.1676"></a>
+<span class="sourceLineNo">1677</span>    if (buf == null) return false;<a name="line.1677"></a>
+<span class="sourceLineNo">1678</span>    if (a.length != buf.remaining()) return false;<a name="line.1678"></a>
+<span class="sourceLineNo">1679</span><a name="line.1679"></a>
+<span class="sourceLineNo">1680</span>    // Thou shalt not modify the original byte buffer in what should be read only operations.<a name="line.1680"></a>
+<span class="sourceLineNo">1681</span>    ByteBuffer b = buf.duplicate();<a name="line.1681"></a>
+<span class="sourceLineNo">1682</span>    for (byte anA : a) {<a name="line.1682"></a>
+<span class="sourceLineNo">1683</span>      if (anA != b.get()) {<a name="line.1683"></a>
+<span class="sourceLineNo">1684</span>        return false;<a name="line.1684"></a>
+<span class="sourceLineNo">1685</span>      }<a name="line.1685"></a>
+<span class="sourceLineNo">1686</span>    }<a name="line.1686"></a>
+<span class="sourceLineNo">1687</span>    return true;<a name="line.1687"></a>
+<span class="sourceLineNo">1688</span>  }<a name="line.1688"></a>
+<span class="sourceLineNo">1689</span><a name="line.1689"></a>
+<span class="sourceLineNo">1690</span><a name="line.1690"></a>
+<span class="sourceLineNo">1691</span>  /**<a name="line.1691"></a>
+<span class="sourceLineNo">1692</span>   * Return true if the byte array on the right is a prefix of the byte<a name="line.1692"></a>
+<span class="sourceLineNo">1693</span>   * array on the left.<a name="line.1693"></a>
+<span class="sourceLineNo">1694</span>   */<a name="line.1694"></a>
+<span class="sourceLineNo">1695</span>  public static boolean startsWith(byte[] bytes, byte[] prefix) {<a name="line.1695"></a>
+<span class="sourceLineNo">1696</span>    return bytes != null &amp;&amp; prefix != null &amp;&amp;<a name="line.1696"></a>
+<span class="sourceLineNo">1697</span>      bytes.length &gt;= prefix.length &amp;&amp;<a name="line.1697"></a>
+<span class="sourceLineNo">1698</span>      LexicographicalComparerHolder.BEST_COMPARER.<a name="line.1698"></a>
+<span class="sourceLineNo">1699</span>        compareTo(bytes, 0, prefix.length, prefix, 0, prefix.length) == 0;<a name="line.1699"></a>
+<span class="sourceLineNo">1700</span>  }<a name="line.1700"></a>
+<span class="sourceLineNo">1701</span><a name="line.1701"></a>
+<span class="sourceLineNo">1702</span>  /**<a name="line.1702"></a>
+<span class="sourceLineNo">1703</span>   * @param b bytes to hash<a name="line.1703"></a>
+<span class="sourceLineNo">1704</span>   * @return Runs {@link WritableComparator#hashBytes(byte[], int)} on the<a name="line.1704"></a>
+<span class="sourceLineNo">1705</span>   * passed in array.  This method is what {@link org.apache.hadoop.io.Text}<a name="line.1705"></a>
+<span class="sourceLineNo">1706</span>   * use calculating hash code.<a name="line.1706"></a>
+<span class="sourceLineNo">1707</span>   */<a name="line.1707"></a>
+<span class="sourceLineNo">1708</span>  public static int hashCode(final byte [] b) {<a name="line.1708"></a>
+<span class="sourceLineNo">1709</span>    return hashCode(b, b.length);<a name="line.1709"></a>
+<span class="sourceLineNo">1710</span>  }<a name="line.1710"></a>
+<span class="sourceLineNo">1711</span><a name="line.1711"></a>
+<span class="sourceLineNo">1712</span>  /**<a name="line.1712"></a>
+<span class="sourceLineNo">1713</span>   * @param b value<a name="line.1713"></a>
+<span class="sourceLineNo">1714</span>   * @param length length of the value<a name="line.1714"></a>
+<span class="sourceLineNo">1715</span>   * @return Runs {@link WritableComparator#hashBytes(byte[], int)} on the<a name="line.1715"></a>
+<span class="sourceLineNo">1716</span>   * passed in array.  This method is what {@link org.apache.hadoop.io.Text}<a name="line.1716"></a>
+<span class="sourceLineNo">1717</span>   * use calculating hash code.<a name="line.1717"></a>
+<span class="sourceLineNo">1718</span>   */<a name="line.1718"></a>
+<span class="sourceLineNo">1719</span>  public static int hashCode(final byte [] b, final int length) {<a name="line.1719"></a>
+<span class="sourceLineNo">1720</span>    return WritableComparator.hashBytes(b, length);<a name="line.1720"></a>
+<span class="sourceLineNo">1721</span>  }<a name="line.1721"></a>
+<span class="sourceLineNo">1722</span><a name="line.1722"></a>
+<span class="sourceLineNo">1723</span>  /**<a name="line.1723"></a>
+<span class="sourceLineNo">1724</span>   * @param b bytes to hash<a name="line.1724"></a>
+<span class="sourceLineNo">1725</span>   * @return A hash of &lt;code&gt;b&lt;/code&gt; as an Integer that can be used as key in<a name="line.1725"></a>
+<span class="sourceLineNo">1726</span>   * Maps.<a name="line.1726"></a>
+<span class="sourceLineNo">1727</span>   */<a name="line.1727"></a>
+<span class="sourceLineNo">1728</span>  public static Integer mapKey(final byte [] b) {<a name="line.1728"></a>
+<span class="sourceLineNo">1729</span>    return hashCode(b);<a name="line.1729"></a>
+<span class="sourceLineNo">1730</span>  }<a name="line.1730"></a>
+<span class="sourceLineNo">1731</span><a name="line.1731"></a>
+<span class="sourceLineNo">1732</span>  /**<a name="line.1732"></a>
+<span class="sourceLineNo">1733</span>   * @param b bytes to hash<a name="line.1733"></a>
+<span class="sourceLineNo">1734</span>   * @param length length to hash<a name="line.1734"></a>
+<span class="sourceLineNo">1735</span>   * @return A hash of &lt;code&gt;b&lt;/code&gt; as an Integer that can be used as key in<a name="line.1735"></a>
+<span class="sourceLineNo">1736</span>   * Maps.<a name="line.1736"></a>
+<span class="sourceLineNo">1737</span>   */<a name="line.1737"></a>
+<span class="sourceLineNo">1738</span>  public static Integer mapKey(final byte [] b, final int length) {<a name="line.1738"></a>
+<span class="sourceLineNo">1739</span>    return hashCode(b, length);<a name="line.1739"></a>
+<span class="sourceLineNo">1740</span>  }<a name="line.1740"></a>
+<span class="sourceLineNo">1741</span><a name="line.1741"></a>
+<span class="sourceLineNo">1742</span>  /**<a name="line.1742"></a>
+<span class="sourceLineNo">1743</span>   * @param a lower half<a name="line.1743"></a>
+<span class="sourceLineNo">1744</span>   * @param b upper half<a name="line.1744"></a>
+<span class="sourceLineNo">1745</span>   * @return New array that has a in lower half and b in upper half.<a name="line.1745"></a>
+<span class="sourceLineNo">1746</span>   */<a name="line.1746"></a>
+<span class="sourceLineNo">1747</span>  public static byte [] add(final byte [] a, final byte [] b) {<a name="line.1747"></a>
+<span class="sourceLineNo">1748</span>    return add(a, b, EMPTY_BYTE_ARRAY);<a name="line.1748"></a>
+<span class="sourceLineNo">1749</span>  }<a name="line.1749"></a>
+<span class="sourceLineNo">1750</span><a name="line.1750"></a>
+<span class="sourceLineNo">1751</span>  /**<a name="line.1751"></a>
+<span class="sourceLineNo">1752</span>   * @param a first third<a name="line.1752"></a>
+<span class="sourceLineNo">1753</span>   * @param b second third<a name="line.1753"></a>
+<span class="sourceLineNo">1754</span>   * @param c third third<a name="line.1754"></a>
+<span class="sourceLineNo">1755</span>   * @return New array made from a, b and c<a name="line.1755"></a>
+<span class="sourceLineNo">1756</span>   */<a name="line.1756"></a>
+<span class="sourceLineNo">1757</span>  public static byte [] add(final byte [] a, final byte [] b, final byte [] c) {<a name="line.1757"></a>
+<span class="sourceLineNo">1758</span>    byte [] result = new byte[a.length + b.length + c.length];<a name="line.1758"></a>
+<span class="sourceLineNo">1759</span>    System.arraycopy(a, 0, result, 0, a.length);<a name="line.1759"></a>
+<span class="sourceLineNo">1760</span>    System.arraycopy(b, 0, result, a.length, b.length);<a name="line.1760"></a>
+<span class="sourceLineNo">1761</span>    System.arraycopy(c, 0, result, a.length + b.length, c.length);<a name="line.1761"></a>
+<span class="sourceLineNo">1762</span>    return result;<a name="line.1762"></a>
+<span class="sourceLineNo">1763</span>  }<a name="line.1763"></a>
+<span class="sourceLineNo">1764</span><a name="line.1764"></a>
+<span class="sourceLineNo">1765</span>  /**<a name="line.1765"></a>
+<span class="sourceLineNo">1766</span>   * @param arrays all the arrays to concatenate together.<a name="line.1766"></a>
+<span class="sourceLineNo">1767</span>   * @return New array made from the concatenation of the given arrays.<a name="line.1767"></a>
+<span class="sourceLineNo">1768</span>   */<a name="line.1768"></a>
+<span class="sourceLineNo">1769</span>  public static byte [] add(final byte [][] arrays) {<a name="line.1769"></a>
+<span class="sourceLineNo">1770</span>    int length = 0;<a name="line.1770"></a>
+<span class="sourceLineNo">1771</span>    for (int i = 0; i &lt; arrays.length; i++) {<a name="line.1771"></a>
+<span class="sourceLineNo">1772</span>      length += arrays[i].length;<a name="line.1772"></a>
+<span class="sourceLineNo">1773</span>    }<a name="line.1773"></a>
+<span class="sourceLineNo">1774</span>    byte [] result = new byte[length];<a name="line.1774"></a>
+<span class="sourceLineNo">1775</span>    int index = 0;<a name="line.1775"></a>
 <span class="sourceLineNo">1776</span>    for (int i = 0; i &lt; arrays.length; i++) {<a name="line.1776"></a>
-<span class="sourceLineNo">1777</span>      length += arrays[i].length;<a name="line.1777"></a>
-<span class="sourceLineNo">1778</span>    }<a name="line.1778"></a>
-<span class="sourceLineNo">1779</span>    byte [] result = new byte[length];<a name="line.1779"></a>
-<span class="sourceLineNo">1780</span>    int index = 0;<a name="line.1780"></a>
-<span class="sourceLineNo">1781</span>    for (int i = 0; i &lt; arrays.length; i++) {<a name="line.1781"></a>
-<span class="sourceLineNo">1782</span>      System.arraycopy(arrays[i], 0, result, index, arrays[i].length);<a name="line.1782"></a>
-<span class="sourceLineNo">1783</span>      index += arrays[i].length;<a name="line.1783"></a>
-<span class="sourceLineNo">1784</span>    }<a name="line.1784"></a>
-<span class="sourceLineNo">1785</span>    return result;<a name="line.1785"></a>
-<span class="sourceLineNo">1786</span>  }<a name="line.1786"></a>
-<span class="sourceLineNo">1787</span><a name="line.1787"></a>
-<span class="sourceLineNo">1788</span>  /**<a name="line.1788"></a>
-<span class="sourceLineNo">1789</span>   * @param a array<a name="line.1789"></a>
-<span class="sourceLineNo">1790</span>   * @param length amount of bytes to grab<a name="line.1790"></a>
-<span class="sourceLineNo">1791</span>   * @return First &lt;code&gt;length&lt;/code&gt; bytes from &lt;code&gt;a&lt;/code&gt;<a name="line.1791"></a>
-<span class="sourceLineNo">1792</span>   */<a name="line.1792"></a>
-<span class="sourceLineNo">1793</span>  public static byte [] head(final byte [] a, final int length) {<a name="line.1793"></a>
-<span class="sourceLineNo">1794</span>    if (a.length &lt; length) {<a name="line.1794"></a>
-<span class="sourceLineNo">1795</span>      return null;<a name="line.1795"></a>
-<span class="sourceLineNo">1796</span>    }<a name="line.1796"></a>
-<span class="sourceLineNo">1797</span>    byte [] result = new byte[length];<a name="line.1797"></a>
-<span class="sourceLineNo">1798</span>    System.arraycopy(a, 0, result, 0, length);<a name="line.1798"></a>
-<span class="sourceLineNo">1799</span>    return result;<a name="line.1799"></a>
-<span class="sourceLineNo">1800</span>  }<a name="line.1800"></a>
-<span class="sourceLineNo">1801</span><a name="line.1801"></a>
-<span class="sourceLineNo">1802</span>  /**<a name="line.1802"></a>
-<span class="sourceLineNo">1803</span>   * @param a array<a name="line.1803"></a>
-<span class="sourceLineNo">1804</span>   * @param length amount of bytes to snarf<a name="line.1804"></a>
-<span class="sourceLineNo">1805</span>   * @return Last &lt;code&gt;length&lt;/code&gt; bytes from &lt;code&gt;a&lt;/code&gt;<a name="line.1805"></a>
-<span class="sourceLineNo">1806</span>   */<a name="line.1806"></a>
-<span class="sourceLineNo">1807</span>  public static byte [] tail(final byte [] a, final int length) {<a name="line.1807"></a>
-<span class="sourceLineNo">1808</span>    if (a.length &lt; length) {<a name="line.1808"></a>
-<span class="sourceLineNo">1809</span>      return null;<a name="line.1809"></a>
-<span class="sourceLineNo">1810</span>    }<a name="line.1810"></a>
-<span class="sourceLineNo">1811</span>    byte [] result = new byte[length];<a name="line.1811"></a>
-<span class="sourceLineNo">1812</span>    System.arraycopy(a, a.length - length, result, 0, length);<a name="line.1812"></a>
-<span class="sourceLineNo">1813</span>    return result;<a name="line.1813"></a>
-<span class="sourceLineNo">1814</span>  }<a name="line.1814"></a>
-<span class="sourceLineNo">1815</span><a name="line.1815"></a>
-<span class="sourceLineNo">1816</span>  /**<a name="line.1816"></a>
-<span class="sourceLineNo">1817</span>   * @param a array<a name="line.1817"></a>
-<span class="sourceLineNo">1818</span>   * @param length new array size<a name="line.1818"></a>
-<span class="sourceLineNo">1819</span>   * @return Value in &lt;code&gt;a&lt;/code&gt; plus &lt;code&gt;length&lt;/code&gt; prepended 0 bytes<a name="line.1819"></a>
-<span class="sourceLineNo">1820</span>   */<a name="line.1820"></a>
-<span class="sourceLineNo">1821</span>  public static byte [] padHead(final byte [] a, final int length) {<a name="line.1821"></a>
-<span class="sourceLineNo">1822</span>    byte [] padding = new byte[length];<a name="line.1822"></a>
-<span class="sourceLineNo">1823</span>    for (int i = 0; i &lt; length; i++) {<a name="line.1823"></a>
-<span class="sourceLineNo">1824</span>      padding[i] = 0;<a name="line.1824"></a>
-<span class="sourceLineNo">1825</span>    }<a name="line.1825"></a>
-<span class="sourceLineNo">1826</span>    return add(padding,a);<a name="line.1826"></a>
-<span class="sourceLineNo">1827</span>  }<a name="line.1827"></a>
-<span class="sourceLineNo">1828</span><a name="line.1828"></a>
-<span class="sourceLineNo">1829</span>  /**<a name="line.1829"></a>
-<span class="sourceLineNo">1830</span>   * @param a array<a name="line.1830"></a>
-<span class="sourceLineNo">1831</span>   * @param length new array size<a name="line.1831"></a>
-<span class="sourceLineNo">1832</span>   * @return Value in &lt;code&gt;a&lt;/code&gt; plus &lt;code&gt;length&lt;/code&gt; appended 0 bytes<a name="line.1832"></a>
-<span class="sourceLineNo">1833</span>   */<a name="line.1833"></a>
-<span class="sourceLineNo">1834</span>  public static byte [] padTail(final byte [] a, final int length) {<a name="line.1834"></a>
-<span class="sourceLineNo">1835</span>    byte [] padding = new byte[length];<a name="line.1835"></a>
-<span class="sourceLineNo">1836</span>    for (int i = 0; i &lt; length; i++) {<a name="line.1836"></a>
-<span class="sourceLineNo">1837</span>      padding[i] = 0;<a name="line.1837"></a>
-<span class="sourceLineNo">1838</span>    }<a name="line.1838"></a>
-<span class="sourceLineNo">1839</span>    return add(a,padding);<a name="line.1839"></a>
-<span class="sourceLineNo">1840</span>  }<a name="line.1840"></a>
-<span class="sourceLineNo">1841</span><a name="line.1841"></a>
-<span class="sourceLineNo">1842</span>  /**<a name="line.1842"></a>
-<span class="sourceLineNo">1843</span>   * Split passed range.  Expensive operation relatively.  Uses BigInteger math.<a name="line.1843"></a>
-<span class="sourceLineNo">1844</span>   * Useful splitting ranges for MapReduce jobs.<a name="line.1844"></a>
-<span class="sourceLineNo">1845</span>   * @param a Beginning of range<a name="line.1845"></a>
-<span class="sourceLineNo">1846</span>   * @param b End of range<a name="line.1846"></a>
-<span class="sourceLineNo">1847</span>   * @param num Number of times to split range.  Pass 1 if you want to split<a name="line.1847"></a>
-<span class="sourceLineNo">1848</span>   * the range in two; i.e. one split.<a name="line.1848"></a>
-<span class="sourceLineNo">1849</span>   * @return Array of dividing values<a name="line.1849"></a>
-<span class="sourceLineNo">1850</span>   */<a name="line.1850"></a>
-<span class="sourceLineNo">1851</span>  public static byte [][] split(final byte [] a, final byte [] b, final int num) {<a name="line.1851"></a>
-<span class="sourceLineNo">1852</span>    return split(a, b, false, num);<a name="line.1852"></a>
-<span class="sourceLineNo">1853</span>  }<a name="line.1853"></a>
-<span class="sourceLineNo">1854</span><a name="line.1854"></a>
-<span class="sourceLineNo">1855</span>  /**<a name="line.1855"></a>
-<span class="sourceLineNo">1856</span>   * Split passed range.  Expensive operation relatively.  Uses BigInteger math.<a name="line.1856"></a>
-<span class="sourceLineNo">1857</span>   * Useful splitting ranges for MapReduce jobs.<a name="line.1857"></a>
-<span class="sourceLineNo">1858</span>   * @param a Beginning of range<a name="line.1858"></a>
-<span class="sourceLineNo">1859</span>   * @param b End of range<a name="line.1859"></a>
-<span class="sourceLineNo">1860</span>   * @param inclusive Whether the end of range is prefix-inclusive or is<a name="line.1860"></a>
-<span class="sourceLineNo">1861</span>   * considered an exclusive boundary.  Automatic splits are generally exclusive<a name="line.1861"></a>
-<span class="sourceLineNo">1862</span>   * and manual splits with an explicit range utilize an inclusive end of range.<a name="line.1862"></a>
-<span class="sourceLineNo">1863</span>   * @param num Number of times to split range.  Pass 1 if you want to split<a name="line.1863"></a>
-<span class="sourceLineNo">1864</span>   * the range in two; i.e. one split.<a name="line.1864"></a>
-<span class="sourceLineNo">1865</span>   * @return Array of dividing values<a name="line.1865"></a>
-<span class="sourceLineNo">1866</span>   */<a name="line.1866"></a>
-<span class="sourceLineNo">1867</span>  public static byte[][] split(final byte[] a, final byte[] b,<a name="line.1867"></a>
-<span class="sourceLineNo">1868</span>      boolean inclusive, final int num) {<a name="line.1868"></a>
-<span class="sourceLineNo">1869</span>    byte[][] ret = new byte[num + 2][];<a name="line.1869"></a>
-<span class="sourceLineNo">1870</span>    int i = 0;<a name="line.1870"></a>
-<span class="sourceLineNo">1871</span>    Iterable&lt;byte[]&gt; iter = iterateOnSplits(a, b, inclusive, num);<a name="line.1871"></a>
-<span class="sourceLineNo">1872</span>    if (iter == null)<a name="line.1872"></a>
-<span class="sourceLineNo">1873</span>      return null;<a name="line.1873"></a>
-<span class="sourceLineNo">1874</span>    for (byte[] elem : iter) {<a name="line.1874"></a>
-<span class="sourceLineNo">1875</span>      ret[i++] = elem;<a name="line.1875"></a>
-<span class="sourceLineNo">1876</span>    }<a name="line.1876"></a>
-<span class="sourceLineNo">1877</span>    return ret;<a name="line.1877"></a>
-<span class="sourceLineNo">1878</span>  }<a name="line.1878"></a>
-<span class="sourceLineNo">1879</span><a name="line.1879"></a>
-<span class="sourceLineNo">1880</span>  /**<a name="line.1880"></a>
-<span class="sourceLineNo">1881</span>   * Iterate over keys within the passed range, splitting at an [a,b) boundary.<a name="line.1881"></a>
-<span class="sourceLineNo">1882</span>   */<a name="line.1882"></a>
-<span class="sourceLineNo">1883</span>  public static Iterable&lt;byte[]&gt; iterateOnSplits(final byte[] a,<a name="line.1883"></a>
-<span class="sourceLineNo">1884</span>      final byte[] b, final int num)<a name="line.1884"></a>
-<span class="sourceLineNo">1885</span>  {<a name="line.1885"></a>
-<span class="sourceLineNo">1886</span>    return iterateOnSplits(a, b, false, num);<a name="line.1886"></a>
-<span class="sourceLineNo">1887</span>  }<a name="line.1887"></a>
-<span class="sourceLineNo">1888</span><a name="line.1888"></a>
-<span class="sourceLineNo">1889</span>  /**<a name="line.1889"></a>
-<span class="sourceLineNo">1890</span>   * Iterate over keys within the passed range.<a name="line.1890"></a>
-<span class="sourceLineNo">1891</span>   */<a name="line.1891"></a>
-<span class="sourceLineNo">1892</span>  public static Iterable&lt;byte[]&gt; iterateOnSplits(<a name="line.1892"></a>
-<span class="sourceLineNo">1893</span>      final byte[] a, final byte[]b, boolean inclusive, final int num)<a name="line.1893"></a>
-<span class="sourceLineNo">1894</span>  {<a name="line.1894"></a>
-<span class="sourceLineNo">1895</span>    byte [] aPadded;<a name="line.1895"></a>
-<span class="sourceLineNo">1896</span>    byte [] bPadded;<a name="line.1896"></a>
-<span class="sourceLineNo">1897</span>    if (a.length &lt; b.length) {<a name="line.1897"></a>
-<span class="sourceLineNo">1898</span>      aPadded = padTail(a, b.length - a.length);<a name="line.1898"></a>
-<span class="sourceLineNo">1899</span>      bPadded = b;<a name="line.1899"></a>
-<span class="sourceLineNo">1900</span>    } else if (b.length &lt; a.length) {<a name="line.1900"></a>
-<span class="sourceLineNo">1901</span>      aPadded = a;<a name="line.1901"></a>
-<span class="sourceLineNo">1902</span>      bPadded = padTail(b, a.length - b.length);<a name="line.1902"></a>
-<span class="sourceLineNo">1903</span>    } else {<a name="line.1903"></a>
-<span class="sourceLineNo">1904</span>      aPadded = a;<a name="line.1904"></a>
-<span class="sourceLineNo">1905</span>      bPadded = b;<a name="line.1905"></a>
-<span class="sourceLineNo">1906</span>    }<a name="line.1906"></a>
-<span class="sourceLineNo">1907</span>    if (compareTo(aPadded,bPadded) &gt;= 0) {<a name="line.1907"></a>
-<span class="sourceLineNo">1908</span>      throw new IllegalArgumentException("b &lt;= a");<a name="line.1908"></a>
-<span class="sourceLineNo">1909</span>    }<a name="line.1909"></a>
-<span class="sourceLineNo">1910</span>    if (num &lt;= 0) {<a name="line.1910"></a>
-<span class="sourceLineNo">1911</span>      throw new IllegalArgumentException("num cannot be &lt;= 0");<a name="line.1911"></a>
-<span class="sourceLineNo">1912</span>    }<a name="line.1912"></a>
-<span class="sourceLineNo">1913</span>    byte [] prependHeader = {1, 0};<a name="line.1913"></a>
-<span class="sourceLineNo">1914</span>    final BigInteger startBI = new BigInteger(add(prependHeader, aPadded));<a name="line.1914"></a>
-<span class="sourceLineNo">1915</span>    final BigInteger stopBI = new BigInteger(add(prependHeader, bPadded));<a name="line.1915"></a>
-<span class="sourceLineNo">1916</span>    BigInteger diffBI = stopBI.subtract(startBI);<a name="line.1916"></a>
-<span class="sourceLineNo">1917</span>    if (inclusive) {<a name="line.1917"></a>
-<span class="sourceLineNo">1918</span>      diffBI = diffBI.add(BigInteger.ONE);<a name="line.1918"></a>
-<span class="sourceLineNo">1919</span>    }<a name="line.1919"></a>
-<span class="sourceLineNo">1920</span>    final BigInteger splitsBI = BigInteger.valueOf(num + 1);<a name="line.1920"></a>
-<span class="sourceLineNo">1921</span>    //when diffBI &lt; splitBI, use an additional byte to increase diffBI<a name="line.1921"></a>
-<span class="sourceLineNo">1922</span>    if(diffBI.compareTo(splitsBI) &lt; 0) {<a name="line.1922"></a>
-<span class="sourceLineNo">1923</span>      byte[] aPaddedAdditional = new byte[aPadded.length+1];<a name="line.1923"></a>
-<span class="sourceLineNo">1924</span>      byte[] bPaddedAdditional = new byte[bPadded.length+1];<a name="line.1924"></a>
-<span class="sourceLineNo">1925</span>      for (int i = 0; i &lt; aPadded.length; i++){<a name="line.1925"></a>
-<span class="sourceLineNo">1926</span>        aPaddedAdditional[i] = aPadded[i];<a name="line.1926"></a>
-<span class="sourceLineNo">1927</span>      }<a name="line.1927"></a>
-<span class="sourceLineNo">1928</span>      for (int j = 0; j &lt; bPadded.length; j++){<a name="line.1928"></a>
-<span class="sourceLineNo">1929</span>        bPaddedAdditional[j] = bPadded[j];<a name="line.1929"></a>
-<span class="sourceLineNo">1930</span>      }<a name="line.1930"></a>
-<span class="sourceLineNo">1931</span>      aPaddedAdditional[aPadded.length] = 0;<a name="line.1931"></a>
-<span class="sourceLineNo">1932</span>      bPaddedAdditional[bPadded.length] = 0;<a name="line.1932"></a>
-<span class="sourceLineNo">1933</span>      return iterateOnSplits(aPaddedAdditional, bPaddedAdditional, inclusive,  num);<a name="line.1933"></a>
-<span class="sourceLineNo">1934</span>    }<a name="line.1934"></a>
-<span class="sourceLineNo">1935</span>    final BigInteger intervalBI;<a name="line.1935"></a>
-<span class="sourceLineNo">1936</span>    try {<a name="line.1936"></a>
-<span class="sourceLineNo">1937</span>      intervalBI = diffBI.divide(splitsBI);<a name="line.1937"></a>
-<span class="sourceLineNo">1938</span>    } catch(Exception e) {<a name="line.1938"></a>
-<span class="sourceLineNo">1939</span>      LOG.error("Exception caught during division", e);<a name="line.1939"></a>
-<span class="sourceLineNo">1940</span>      return null;<a name="line.1940"></a>
-<span class="sourceLineNo">1941</span>    }<a name="line.1941"></a>
-<span class="sourceLineNo">1942</span><a name="line.1942"></a>
-<span class="sourceLineNo">1943</span>    final Iterator&lt;byte[]&gt; iterator = new Iterator&lt;byte[]&gt;() {<a name="line.1943"></a>
-<span class="sourceLineNo">1944</span>      private int i = -1;<a name="line.1944"></a>
+<span class="sourceLineNo">1777</span>      System.arraycopy(arrays[i], 0, result, index, arrays[i].length);<a name="line.1777"></a>
+<span class="sourceLineNo">1778</span>      index += arrays[i].length;<a name="line.1778"></a>
+<span class="sourceLineNo">1779</span>    }<a name="line.1779"></a>
+<span class="sourceLineNo">1780</span>    return result;<a name="line.1780"></a>
+<span class="sourceLineNo">1781</span>  }<a name="line.1781"></a>
+<span class="sourceLineNo">1782</span><a name="line.1782"></a>
+<span class="sourceLineNo">1783</span>  /**<a name="line.1783"></a>
+<span class="sourceLineNo">1784</span>   * @param a array<a name="line.1784"></a>
+<span class="sourceLineNo">1785</span>   * @param length amount of bytes to grab<a name="line.1785"></a>
+<span class="sourceLineNo">1786</span>   * @return First &lt;code&gt;length&lt;/code&gt; bytes from &lt;code&gt;a&lt;/code&gt;<a name="line.1786"></a>
+<span class="sourceLineNo">1787</span>   */<a name="line.1787"></a>
+<span class="sourceLineNo">1788</span>  public static byte [] head(final byte [] a, final int length) {<a name="line.1788"></a>
+<span class="sourceLineNo">1789</span>    if (a.length &lt; length) {<a name="line.1789"></a>
+<span class="sourceLineNo">1790</span>      return null;<a name="line.1790"></a>
+<span class="sourceLineNo">1791</span>    }<a name="line.1791"></a>
+<span class="sourceLineNo">1792</span>    byte [] result = new byte[length];<a name="line.1792"></a>
+<span class="sourceLineNo">1793</span>    System.arraycopy(a, 0, result, 0, length);<a name="line.1793"></a>
+<span class="sourceLineNo">1794</span>    return result;<a name="line.1794"></a>
+<span class="sourceLineNo">1795</span>  }<a name="line.1795"></a>
+<span class="sourceLineNo">1796</span><a name="line.1796"></a>
+<span class="sourceLineNo">1797</span>  /**<a name="line.1797"></a>
+<span class="sourceLineNo">1798</span>   * @param a array<a name="line.1798"></a>
+<span class="sourceLineNo">1799</span>   * @param length amount of bytes to snarf<a name="line.1799"></a>
+<span class="sourceLineNo">1800</span>   * @return Last &lt;code&gt;length&lt;/code&gt; bytes from &lt;code&gt;a&lt;/code&gt;<a name="line.1800"></a>
+<span class="sourceLineNo">1801</span>   */<a name="line.1801"></a>
+<span class="sourceLineNo">1802</span>  public static byte [] tail(final byte [] a, final int length) {<a name="line.1802"></a>
+<span class="sourceLineNo">1803</span>    if (a.length &lt; length) {<a name="line.1803"></a>
+<span class="sourceLineNo">1804</span>      return null;<a name="line.1804"></a>
+<span class="sourceLineNo">1805</span>    }<a name="line.1805"></a>
+<span class="sourceLineNo">1806</span>    byte [] result = new byte[length];<a name="line.1806"></a>
+<span class="sourceLineNo">1807</span>    System.arraycopy(a, a.length - length, result, 0, length);<a name="line.1807"></a>
+<span class="sourceLineNo">1808</span>    return result;<a name="line.1808"></a>
+<span class="sourceLineNo">1809</span>  }<a name="line.1809"></a>
+<span class="sourceLineNo">1810</span><a name="line.1810"></a>
+<span class="sourceLineNo">1811</span>  /**<a name="line.1811"></a>
+<span class="sourceLineNo">1812</span>   * @param a array<a name="line.1812"></a>
+<span class="sourceLineNo">1813</span>   * @param length new array size<a name="line.1813"></a>
+<span class="sourceLineNo">1814</span>   * @return Value in &lt;code&gt;a&lt;/code&gt; plus &lt;code&gt;length&lt;/code&gt; prepended 0 bytes<a name="line.1814"></a>
+<span class="sourceLineNo">1815</span>   */<a name="line.1815"></a>
+<span class="sourceLineNo">1816</span>  public static byte [] padHead(final byte [] a, final int length) {<a name="line.1816"></a>
+<span class="sourceLineNo">1817</span>    byte [] padding = new byte[length];<a name="line.1817"></a>
+<span class="sourceLineNo">1818</span>    for (int i = 0; i &lt; length; i++) {<a name="line.1818"></a>
+<span class="sourceLineNo">1819</span>      padding[i] = 0;<a name="line.1819"></a>
+<span class="sourceLineNo">1820</span>    }<a name="line.1820"></a>
+<span class="sourceLineNo">1821</span>    return add(padding,a);<a name="line.1821"></a>
+<span class="sourceLineNo">1822</span>  }<a name="line.1822"></a>
+<span class="sourceLineNo">1823</span><a name="line.1823"></a>
+<span class="sourceLineNo">1824</span>  /**<a name="line.1824"></a>
+<span class="sourceLineNo">1825</span>   * @param a array<a name="line.1825"></a>
+<span class="sourceLineNo">1826</span>   * @param length new array size<a name="line.1826"></a>
+<span class="sourceLineNo">1827</span>   * @return Value in &lt;code&gt;a&lt;/code&gt; plus &lt;code&gt;length&lt;/code&gt; appended 0 bytes<a name="line.1827"></a>
+<span class="sourceLineNo">1828</span>   */<a name="line.1828"></a>
+<span class="sourceLineNo">1829</span>  public static byte [] padTail(final byte [] a, final int length) {<a name="line.1829"></a>
+<span class="sourceLineNo">1830</span>    byte [] padding = new byte[length];<a name="line.1830"></a>
+<span class="sourceLineNo">1831</span>    for (int i = 0; i &lt; length; i++) {<a name="line.1831"></a>
+<span class="sourceLineNo">1832</span>      padding[i] = 0;<a name="line.1832"></a>
+<span class="sourceLineNo">1833</span>    }<a name="line.1833"></a>
+<span class="sourceLineNo">1834</span>    return add(a,padding);<a name="line.1834"></a>
+<span class="sourceLineNo">1835</span>  }<a name="line.1835"></a>
+<span class="sourceLineNo">1836</span><a name="line.1836"></a>
+<span class="sourceLineNo">1837</span>  /**<a name="line.1837"></a>
+<span class="sourceLineNo">1838</span>   * Split passed range.  Expensive operation relatively.  Uses BigInteger math.<a name="line.1838"></a>
+<span class="sourceLineNo">1839</span>   * Useful splitting ranges for MapReduce jobs.<a name="line.1839"></a>
+<span class="sourceLineNo">1840</span>   * @param a Beginning of range<a name="line.1840"></a>
+<span class="sourceLineNo">1841</span>   * @param b End of range<a name="line.1841"></a>
+<span class="sourceLineNo">1842</span>   * @param num Number of times to split range.  Pass 1 if you want to split<a name="line.1842"></a>
+<span class="sourceLineNo">1843</span>   * the range in two; i.e. one split.<a name="line.1843"></a>
+<span class="sourceLineNo">1844</span>   * @return Array of dividing values<a name="line.1844"></a>
+<span class="sourceLineNo">1845</span>   */<a name="line.1845"></a>
+<span class="sourceLineNo">1846</span>  public static byte [][] split(final byte [] a, final byte [] b, final int num) {<a name="line.1846"></a>
+<span class="sourceLineNo">1847</span>    return split(a, b, false, num);<a name="line.1847"></a>
+<span class="sourceLineNo">1848</span>  }<a name="line.1848"></a>
+<span class="sourceLineNo">1849</span><a name="line.1849"></a>
+<span class="sourceLineNo">1850</span>  /**<a name="line.1850"></a>
+<span class="sourceLineNo">1851</span>   * Split passed range.  Expensive operation relatively.  Uses BigInteger math.<a name="line.1851"></a>
+<span class="sourceLineNo">1852</span>   * Useful splitting ranges for MapReduce jobs.<a name="line.1852"></a>
+<span class="sourceLineNo">1853</span>   * @param a Beginning of range<a name="line.1853"></a>
+<span class="sourceLineNo">1854</span>   * @param b End of range<a name="line.1854"></a>
+<span class="sourceLineNo">1855</span>   * @param inclusive Whether the end of range is prefix-inclusive or is<a name="line.1855"></a>
+<span class="sourceLineNo">1856</span>   * considered an exclusive boundary.  Automatic splits are generally exclusive<a name="line.1856"></a>
+<span class="sourceLineNo">1857</span>   * and manual splits with an explicit range utilize an inclusive end of range.<a name="line.1857"></a>
+<span class="sourceLineNo">1858</span>   * @param num Number of times to split range.  Pass 1 if you want to split<a name="line.1858"></a>
+<span class="sourceLineNo">1859</span>   * the range in two; i.e. one split.<a name="line.1859"></a>
+<span class="sourceLineNo">1860</span>   * @return Array of dividing values<a name="line.1860"></a>
+<span class="sourceLineNo">1861</span>   */<a name="line.1861"></a>
+<span class="sourceLineNo">1862</span>  public static byte[][] split(final byte[] a, final byte[] b,<a name="line.1862"></a>
+<span class="sourceLineNo">1863</span>      boolean inclusive, final int num) {<a name="line.1863"></a>
+<span class="sourceLineNo">1864</span>    byte[][] ret = new byte[num + 2][];<a name="line.1864"></a>
+<span class="sourceLineNo">1865</span>    int i = 0;<a name="line.1865"></a>
+<span class="sourceLineNo">1866</span>    Iterable&lt;byte[]&gt; iter = iterateOnSplits(a, b, inclusive, num);<a name="line.1866"></a>
+<span class="sourceLineNo">1867</span>    if (iter == null)<a name="line.1867"></a>
+<span class="sourceLineNo">1868</span>      return null;<a name="line.1868"></a>
+<span class="sourceLineNo">1869</span>    for (byte[] elem : iter) {<a name="line.1869"></a>
+<span class="sourceLineNo">1870</span>      ret[i++] = elem;<a name="line.1870"></a>
+<span class="sourceLineNo">1871</span>    }<a name="line.1871"></a>
+<span class="sourceLineNo">1872</span>    return ret;<a name="line.1872"></a>
+<span class="sourceLineNo">1873</span>  }<a name="line.1873"></a>
+<span class="sourceLineNo">1874</span><a name="line.1874"></a>
+<span class="sourceLineNo">1875</span>  /**<a name="line.1875"></a>
+<span class="sourceLineNo">1876</span>   * Iterate over keys within the passed range, splitting at an [a,b) boundary.<a name="line.1876"></a>
+<span class="sourceLineNo">1877</span>   */<a name="line.1877"></a>
+<span class="sourceLineNo">1878</span>  public static Iterable&lt;byte[]&gt; iterateOnSplits(final byte[] a,<a name="line.1878"></a>
+<span class="sourceLineNo">1879</span>      final byte[] b, final int num)<a name="line.1879"></a>
+<span class="sourceLineNo">1880</span>  {<a name="line.1880"></a>
+<span class="sourceLineNo">1881</span>    return iterateOnSplits(a, b, false, num);<a name="line.1881"></a>
+<span class="sourceLineNo">1882</span>  }<a name="line.1882"></a>
+<span class="sourceLineNo">1883</span><a name="line.1883"></a>
+<span class="sourceLineNo">1884</span>  /**<a name="line.1884"></a>
+<span class="sourceLineNo">1885</span>   * Iterate over keys within the passed range.<a name="line.1885"></a>
+<span class="sourceLineNo">1886</span>   */<a name="line.1886"></a>
+<span class="sourceLineNo">1887</span>  public static Iterable&lt;byte[]&gt; iterateOnSplits(<a name="line.1887"></a>
+<span class="sourceLineNo">1888</span>      final byte[] a, final byte[]b, boolean inclusive, final int num)<a name="line.1888"></a>
+<span class="sourceLineNo">1889</span>  {<a name="line.1889"></a>
+<span class="sourceLineNo">1890</span>    byte [] aPadded;<a name="line.1890"></a>
+<span class="sourceLineNo">1891</span>    byte [] bPadded;<a name="line.1891"></a>
+<span class="sourceLineNo">1892</span>    if (a.length &lt; b.length) {<a name="line.1892"></a>
+<span class="sourceLineNo">1893</span>      aPadded = padTail(a, b.length - a.length);<a name="line.1893"></a>
+<span class="sourceLineNo">1894</span>      bPadded = b;<a name="line.1894"></a>
+<span class="sourceLineNo">1895</span>    } else if (b.length &lt; a.length) {<a name="line.1895"></a>
+<span class="sourceLineNo">1896</span>      aPadded = a;<a name="line.1896"></a>
+<span class="sourceLineNo">1897</span>      bPadded = padTail(b, a.length - b.length);<a name="line.1897"></a>
+<span class="sourceLineNo">1898</span>    } else {<a name="line.1898"></a>
+<span class="sourceLineNo">1899</span>      aPadded = a;<a name="line.1899"></a>
+<span class="sourceLineNo">1900</span>      bPadded = b;<a name="line.1900"></a>
+<span class="sourceLineNo">1901</span>    }<a name="line.1901"></a>
+<span class="sourceLineNo">1902</span>    if (compareTo(aPadded,bPadded) &gt;= 0) {<a name="line.1902"></a>
+<span class="sourceLineNo">1903</span>      throw new IllegalArgumentException("b &lt;= a");<a name="line.1903"></a>
+<span class="sourceLineNo">1904</span>    }<a name="line.1904"></a>
+<span class="sourceLineNo">1905</span>    if (num &lt;= 0) {<a name="line.1905"></a>
+<span class="sourceLineNo">1906</span>      throw new IllegalArgumentException("num cannot be &lt;= 0");<a name="line.1906"></a>
+<span class="sourceLineNo">1907</span>    }<a name="line.1907"></a>
+<span class="sourceLineNo">1908</span>    byte [] prependHeader = {1, 0};<a name="line.1908"></a>
+<span class="sourceLineNo">1909</span>    final BigInteger startBI = new BigInteger(add(prependHeader, aPadded));<a name="line.1909"></a>
+<span class="sourceLineNo">1910</span>    final BigInteger stopBI = new BigInteger(add(prependHeader, bPadded));<a name="line.1910"></a>
+<span class="sourceLineNo">1911</span>    BigInteger diffBI = stopBI.subtract(startBI);<a name="line.1911"></a>
+<span class="sourceLineNo">1912</span>    if (inclusive) {<a name="line.1912"></a>
+<span class="sourceLineNo">1913</span>      diffBI = diffBI.add(BigInteger.ONE);<a name="line.1913"></a>
+<span class="sourceLineNo">1914</span>    }<a name="line.1914"></a>
+<span class="sourceLineNo">1915</span>    final BigInteger splitsBI = BigInteger.valueOf(num + 1);<a name="line.1915"></a>
+<span class="sourceLineNo">1916</span>    //when diffBI &lt; splitBI, use an additional byte to increase diffBI<a name="line.1916"></a>
+<span class="sourceLineNo">1917</span>    if(diffBI.compareTo(splitsBI) &lt; 0) {<a name="line.1917"></a>
+<span class="sourceLineNo">1918</span>      byte[] aPaddedAdditional = new byte[aPadded.length+1];<a name="line.1918"></a>
+<span class="sourceLineNo">1919</span>      byte[] bPaddedAdditional = new byte[bPadded.length+1];<a name="line.1919"></a>
+<span class="sourceLineNo">1920</span>      for (int i = 0; i &lt; aPadded.length; i++){<a name="line.1920"></a>
+<span class="sourceLineNo">1921</span>        aPaddedAdditional[i] = aPadded[i];<a name="line.1921"></a>
+<span class="sourceLineNo">1922</span>      }<a name="line.1922"></a>
+<span class="sourceLineNo">1923</span>      for (int j = 0; j &lt; bPadded.length; j++){<a name="line.1923"></a>
+<span class="sourceLineNo">1924</span>        bPaddedAdditional[j] = bPadded[j];<a name="line.1924"></a>
+<span class="sourceLineNo">1925</span>      }<a name="line.1925"></a>
+<span class="sourceLineNo">1926</span>      aPaddedAdditional[aPadded.length] = 0;<a name="line.1926"></a>
+<span class="sourceLineNo">1927</span>      bPaddedAdditional[bPadded.length] = 0;<a name="line.1927"></a>
+<span class="sourceLineNo">1928</span>      return iterateOnSplits(aPaddedAdditional, bPaddedAdditional, inclusive,  num);<a name="line.1928"></a>
+<span class="sourceLineNo">1929</span>    }<a name="line.1929"></a>
+<span class="sourceLineNo">1930</span>    final BigInteger intervalBI;<a name="line.1930"></a>
+<span class="sourceLineNo">1931</span>    try {<a name="line.1931"></a>
+<span class="sourceLineNo">1932</span>      intervalBI = diffBI.divide(splitsBI);<a name="line.1932"></a>
+<span class="sourceLineNo">1933</span>    } catch(Exception e) {<a name="line.1933"></a>
+<span class="sourceLineNo">1934</span>      LOG.error("Exception caught during division", e);<a name="line.1934"></a>
+<span class="sourceLineNo">1935</span>      return null;<a name="line.1935"></a>
+<span class="sourceLineNo">1936</span>    }<a name="line.1936"></a>
+<span class="sourceLineNo">1937</span><a name="line.1937"></a>
+<span class="sourceLineNo">1938</span>    final Iterator&lt;byte[]&gt; iterator = new Iterator&lt;byte[]&gt;() {<a name="line.1938"></a>
+<span class="sourceLineNo">1939</span>      private int i = -1;<a name="line.1939"></a>
+<span class="sourceLineNo">1940</span><a name="line.1940"></a>
+<span class="sourceLineNo">1941</span>      @Override<a name="line.1941"></a>
+<span class="sourceLineNo">1942</span>      public boolean hasNext() {<a name="line.1942"></a>
+<span class="sourceLineNo">1943</span>        return i &lt; num+1;<a name="line.1943"></a>
+<span class="sourceLineNo">1944</span>      }<a name="line.1944"></a>
 <span class="sourceLineNo">1945</span><a name="line.1945"></a>
 <span class="sourceLineNo">1946</span>      @Override<a name="line.1946"></a>
-<span class="sourceLineNo">1947</span>      public boolean hasNext() {<a name="line.1947"></a>
-<span class="sourceLineNo">1948</span>        return i &lt; num+1;<a name="line.1948"></a>
-<span class="sourceLineNo">1949</span>      }<a name="line.1949"></a>
-<span class="sourceLineNo">1950</span><a name="line.1950"></a>
-<span class="sourceLineNo">1951</span>      @Override<a name="line.1951"></a>
-<span class="sourceLineNo">1952</span>      public byte[] next() {<a name="line.1952"></a>
-<span class="sourceLineNo">1953</span>        i++;<a name="line.1953"></a>
-<span class="sourceLineNo">1954</span>        if (i == 0) return a;<a name="line.1954"></a>
-<span class="sourceLineNo">1955</span>        if (i == num + 1) return b;<a name="line.1955"></a>
-<span class="sourceLineNo">1956</span><a name="line.1956"></a>
-<span class="sourceLineNo">1957</span>        BigInteger curBI = startBI.add(intervalBI.multiply(BigInteger.valueOf(i)));<a name="line.1957"></a>
-<span class="sourceLineNo">1958</span>        byte [] padded = curBI.toByteArray();<a name="line.1958"></a>
-<span class="sourceLineNo">1959</span>        if (padded[1] == 0)<a name="line.1959"></a>
-<span class="sourceLineNo">1960</span>          padded = tail(padded, padded.length - 2);<a name="line.1960"></a>
-<span class="sourceLineNo">1961</span>        else<a name="line.1961"></a>
-<span class="sourceLineNo">1962</span>          padded = tail(padded, padded.length - 1);<a name="line.1962"></a>
-<span class="sourceLineNo">1963</span>        return padded;<a name="line.1963"></a>
+<span class="sourceLineNo">1947</span>      public byte[] next() {<a name="line.1947"></a>
+<span class="sourceLineNo">1948</span>        i++;<a name="line.1948"></a>
+<span class="sourceLineNo">1949</span>        if (i == 0) return a;<a name="line.1949"></a>
+<span class="sourceLineNo">1950</span>        if (i == num + 1) return b;<a name="line.1950"></a>
+<span class="sourceLineNo">1951</span><a name="line.1951"></a>
+<span class="sourceLineNo">1952</span>        BigInteger curBI = startBI.add(intervalBI.multiply(BigInteger.valueOf(i)));<a name="line.1952"></a>
+<span class="sourceLineNo">1953</span>        byte [] padded = curBI.toByteArray();<a name="line.1953"></a>
+<span class="sourceLineNo">1954</span>        if (padded[1] == 0)<a name="line.1954"></a>
+<span class="sourceLineNo">1955</span>          padded = tail(padded, padded.length - 2);<a name="line.1955"></a>
+<span class="sourceLineNo">1956</span>        else<a name="line.1956"></a>
+<span class="sourceLineNo">1957</span>          padded = tail(padded, padded.length - 1);<a name="line.1957"></a>
+<span class="sourceLineNo">1958</span>        return padded;<a name="line.1958"></a>
+<span class="sourceLineNo">1959</span>      }<a name="line.1959"></a>
+<span class="sourceLineNo">1960</span><a name="line.1960"></a>
+<span class="sourceLineNo">1961</span>      @Override<a name="line.1961"></a>
+<span class="sourceLineNo">1962</span>      public void remove() {<a name="line.1962"></a>
+<span class="sourceLineNo">1963</span>        throw new UnsupportedOperationException();<a name="line.1963"></a>
 <span class="sourceLineNo">1964</span>      }<a name="line.1964"></a>
 <span class="sourceLineNo">1965</span><a name="line.1965"></a>
-<span class="sourceLineNo">1966</span>      @Override<a name="line.1966"></a>
-<span class="sourceLineNo">1967</span>      public void remove() {<a name="line.1967"></a>
-<span class="sourceLineNo">1968</span>        throw new UnsupportedOperationException();<a name="line.1968"></a>
-<span class="sourceLineNo">1969</span>      }<a name="line.1969"></a>
-<span class="sourceLineNo">1970</span><a name="line.1970"></a>
-<span class="sourceLineNo">1971</span>    };<a name="line.1971"></a>
-<span class="sourceLineNo">1972</span><a name="line.1972"></a>
-<span class="sourceLineNo">1973</span>    return new Iterable&lt;byte[]&gt;() {<a name="line.1973"></a>
-<span class="sourceLineNo">1974</span>      @Override<a name="line.1974"></a>
-<span class="sourceLineNo">1975</span>      public Iterator&lt;byte[]&gt; iterator() {<a name="line.1975"></a>
-<span class="sourceLineNo">1976</span>        return iterator;<a name="line.1976"></a>
-<span class="sourceLineNo">1977</span>      }<a name="line.1977"></a>
-<span class="sourceLineNo">1978</span>    };<a name="line.1978"></a>
-<span class="sourceLineNo">1979</span>  }<a name="line.1979"></a>
-<span class="sourceLineNo">1980</span><a name="line.1980"></a>
-<span class="sourceLineNo">1981</span>  /**<a name="line.1981"></a>
-<span class="sourceLineNo">1982</span>   * @param bytes array to hash<a name="line.1982"></a>
-<span class="sourceLineNo">1983</span>   * @param offset offset to start from<a name="line.1983"></a>
-<span class="sourceLineNo">1984</span>   * @param length length to hash<a name="line.1984"></a>
-<span class="sourceLineNo">1985</span>   * */<a name="line.1985"></a>
-<span class="sourceLineNo">1986</span>  public static int hashCode(byte[] bytes, int offset, int length) {<a name="line.1986"></a>
-<span class="sourceLineNo">1987</span>    int hash = 1;<a name="line.1987"></a>
-<span class="sourceLineNo">1988</span>    for (int i = offset; i &lt; offset + length; i++)<a name="line.1988"></a>
-<span class="sourceLineNo">1989</span>      hash = (31 * hash) + (int) bytes[i];<a name="line.1989"></a>
-<span class="sourceLineNo">1990</span>    return hash;<a name="line.1990"></a>
-<span class="sourceLineNo">1991</span>  }<a name="line.1991"></a>
-<span class="sourceLineNo">1992</span><a name="line.1992"></a>
-<span class="sourceLineNo">1993</span>  /**<a name="line.1993"></a>
-<span class="sourceLineNo">1994</span>   * @param t operands<a name="line.1994"></a>
-<span class="sourceLineNo">1995</span>   * @return Array of byte arrays made from passed array of Text<a name="line.1995"></a>
-<span class="sourceLineNo">1996</span>   */<a name="line.1996"></a>
-<span class="sourceLineNo">1997</span>  public static byte [][] toByteArrays(final String [] t) {<a name="line.1997"></a>
-<span class="sourceLineNo">1998</span>    byte [][] result = new byte[t.length][];<a name="line.1998"></a>
-<span class="sourceLineNo">1999</span>    for (int i = 0; i &lt; t.length; i++) {<a name="line.1999"></a>
-<span class="sourceLineNo">2000</span>      result[i] = Bytes.toBytes(t[i]);<a name="line.2000"></a>
-<span class="sourceLineNo">2001</span>    }<a name="line.2001"></a>
-<span class="sourceLineNo">2002</span>    return result;<a name="line.2002"></a>
-<span class="sourceLineNo">2003</span>  }<a name="line.2003"></a>
-<span class="sourceLineNo">2004</span><a name="line.2004"></a>
-<span class="sourceLineNo">2005</span>  /**<a name="line.2005"></a>
-<span class="sourceLineNo">2006</span>   * @param t operands<a name="line.2006"></a>
-<span class="sourceLineNo">2007</span>   * @return Array of binary byte arrays made from passed array of binary strings<a name="line.2007"></a>
-<span class="sourceLineNo">2008</span>   */<a name="line.2008"></a>
-<span class="sourceLineNo">2009</span>  public static byte[][] toBinaryByteArrays(final String[] t) {<a name="line.2009"></a>
-<span class="sourceLineNo">2010</span>    byte[][] result = new byte[t.length][];<a name="line.2010"></a>
-<span class="sourceLineNo">2011</span>    for (int i = 0; i &lt; t.length; i++) {<a name="line.2011"></a>
-<span class="sourceLineNo">2012</span>      result[i] = Bytes.toBytesBinary(t[i]);<a name="line.2012"></a>
-<span class="sourceLineNo">2013</span>    }<a name="line.2013"></a>
-<span class="sourceLineNo">2014</span>    return result;<a name="line.2014"></a>
-<span class="sourceLineNo">2015</span>  }<a name="line.2015"></a>
-<span class="sourceLineNo">2016</span><a name="line.2016"></a>
-<span class="sourceLineNo">2017</span>  /**<a name="line.2017"></a>
-<span class="sourceLineNo">2018</span>   * @param column operand<a name="line.2018"></a>
-<span class="sourceLineNo">2019</span>   * @return A byte array of a byte array where first and only entry is<a name="line.2019"></a>
-<span class="sourceLineNo">2020</span>   * &lt;code&gt;column&lt;/code&gt;<a name="line.2020"></a>
-<span class="sourceLineNo">2021</span>   */<a name="line.2021"></a>
-<span class="sourceLineNo">2022</span>  public static byte [][] toByteArrays(final String column) {<a name="line.2022"></a>
-<span class="sourceLineNo">2023</span>    return toByteArrays(toBytes(column));<a name="line.2023"></a>
-<span class="sourceLineNo">2024</span>  }<a name="line.2024"></a>
-<span class="sourceLineNo">2025</span><a name="line.2025"></a>
-<span class="sourceLineNo">2026</span>  /**<a name="line.2026"></a>
-<span class="sourceLineNo">2027</span>   * @param column operand<a name="line.2027"></a>
-<span class="sourceLineNo">2028</span>   * @return A byte array of a byte array where first and only entry is<a name="line.2028"></a>
-<span class="sourceLineNo">2029</span>   * &lt;code&gt;column&lt;/code&gt;<a name="line.2029"></a>
-<span class="sourceLineNo">2030</span>   */<a name="line.2030"></a>
-<span class="sourceLineNo">2031</span>  public static byte [][] toByteArrays(final byte [] column) {<a name="line.2031"></a>
-<span class="sourceLineNo">2032</span>    byte [][] result = new byte[1][];<a name="line.2032"></a>
-<span class="sourceLineNo">2033</span>    result[0] = column;<a name="line.2033"></a>
-<span class="sourceLineNo">2034</span>    return result;<a name="line.2034"></a>
-<span class="sourceLineNo">2035</span>  }<a name="line.2035"></a>
-<span class="sourceLineNo">2036</span><a name="line.2036"></a>
-<span class="sourceLineNo">2037</span>  /**<a name="line.2037"></a>
-<span class="sourceLineNo">2038</span>   * Binary search for keys in indexes.<a name="line.2038"></a>
-<span class="sourceLineNo">2039</span>   *<a name="line.2039"></a>
-<span class="sourceLineNo">2040</span>   * @param arr array of byte arrays to search for<a name="line.2040"></a>
-<span class="sourceLineNo">2041</span>   * @param key the key you want to find<a name="line.2041"></a>
-<span class="sourceLineNo">2042</span>   * @param offset the offset in the key you want to find<a name="line.2042"></a>
-<span class="sourceLineNo">2043</span>   * @param length the length of the key<a name="line.2043"></a>
-<span class="sourceLineNo">2044</span>   * @param comparator a comparator to compare.<a name="line.2044"></a>
-<span class="sourceLineNo">2045</span>   * @return zero-based index of the key, if the key is present in the array.<a name="line.2045"></a>
-<span class="sourceLineNo">2046</span>   *         Otherwise, a value -(i + 1) such that the key is between arr[i -<a name="line.2046"></a>
-<span class="sourceLineNo">2047</span>   *         1] and arr[i] non-inclusively, where i is in [0, i], if we define<a name="line.2047"></a>
-<span class="sourceLineNo">2048</span>   *         arr[-1] = -Inf and arr[N] = Inf for an N-element array. The above<a name="line.2048"></a>
-<span class="sourceLineNo">2049</span>   *         means that this function can return 2N + 1 different values<a name="line.2049"></a>
-<span class="sourceLineNo">2050</span>   *         ranging from -(N + 1) to N - 1.<a name="line.2050"></a>
-<span class="sourceLineNo">2051</span>   * @deprecated {@link Bytes#binarySearch(byte[][], byte[], int, int)}<a name="line.2051"></a>
-<span class="sourceLineNo">2052</span>   */<a name="line.2052"></a>
-<span class="sourceLineNo">2053</span>  @Deprecated<a name="line.2053"></a>
-<span class="sourceLineNo">2054</span>  public static int binarySearch(byte [][]arr, byte []key, int offset,<a name="line.2054"></a>
-<span class="sourceLineNo">2055</span>      int length, RawComparator&lt;?&gt; comparator) {<a name="line.2055"></a>
-<span class="sourceLineNo">2056</span>    return binarySearch(arr, key, offset, length);<a name="line.2056"></a>
-<span class="sourceLineNo">2057</span>  }<a name="line.2057"></a>
-<span class="sourceLineNo">2058</span><a name="line.2058"></a>
-<span class="sourceLineNo">2059</span>  /**<a name="line.2059"></a>
-<span class="sourceLineNo">2060</span>   * Binary search for keys in indexes using Bytes.BYTES_RAWCOMPARATOR.<a name="line.2060"></a>
-<span class="sourceLineNo">2061</span>   *<a name="line.2061"></a>
-<span class="sourceLineNo">2062</span>   * @param arr array of byte arrays to search for<a name="line.2062"></a>
-<span class="sourceLineNo">2063</span>   * @param key the key you want to find<a name="line.2063"></a>
-<span class="sourceLineNo">2064</span>   * @param offset the offset in the key you want to find<a name="line.2064"></a>
-<span class="sourceLineNo">2065</span>   * @param length the length of the key<a name="line.2065"></a>
-<span class="sourceLineNo">2066</span>   * @return zero-based index of the key, if the key is present in the array.<a name="line.2066"></a>
-<span class="sourceLineNo">2067</span>   *         Otherwise, a value -(i + 1) such that the key is between arr[i -<a name="line.2067"></a>
-<span class="sourceLineNo">2068</span>   *         1] and arr[i] non-inclusively, where i is in [0, i], if we define<a name="line.2068"></a>
-<span class="sourceLineNo">2069</span>   *         arr[-1] = -Inf and arr[N] = Inf for an N-element array. The above<a name="line.2069"></a>
-<span class="sourceLineNo">2070</span>   *         means that this function can return 2N + 1 different values<a name="line.2070"></a>
-<span class="sourceLineNo">2071</span>   *         ranging from -(N + 1) to N - 1.<a name="line.2071"></a>
-<span class="sourceLineNo">2072</span>   */<a name="line.2072"></a>
-<span class="sourceLineNo">2073</span>  public static int binarySearch(byte[][] arr, byte[] key, int offset, int length) {<a name="line.2073"></a>
-<span class="sourceLineNo">2074</span>    int low = 0;<a name="line.2074"></a>
-<span class="sourceLineNo">2075</span>    int high = arr.length - 1;<a name="line.2075"></a>
-<span class="sourceLineNo">2076</span><a name="line.2076"></a>
-<span class="sourceLineNo">2077</span>    while (low &lt;= high) {<a name="line.2077"></a>
-<span class="sourceLineNo">2078</span>      int mid = (low + high) &gt;&gt;&gt; 1;<a name="line.2078"></a>
-<span class="sourceLineNo">2079</span>      // we have to compare in this order, because the comparator order<a name="line.2079"></a>
-<span class="sourceLineNo">2080</span>      // has special logic when the 'left side' is a special key.<a name="line.2080"></a>
-<span class="sourceLineNo">2081</span>      int cmp = Bytes.BYTES_RAWCOMPARATOR<a name="line.2081"></a>
-<span class="sourceLineNo">2082</span>          .compare(key, offset, length, arr[mid], 0, arr[mid].length);<a name="line.2082"></a>
-<span class="sourceLineNo">2083</span>      // key lives above the midpoint<a name="line.2083"></a>
-<span class="sourceLineNo">2084</span>      if (cmp &gt; 0)<a name="line.2084"></a>
-<span class="sourceLineNo">2085</span>        low = mid + 1;<a name="line.2085"></a>
-<span class="sourceLineNo">2086</span>      // key lives below the midpoint<a name="line.2086"></a>
-<span class="sourceLineNo">2087</span>      else if (cmp &lt; 0)<a name="line.2087"></a>
-<span class="sourceLineNo">2088</span>        high = mid - 1;<a name="line.2088"></a>
-<span class="sourceLineNo">2089</span>      // BAM. how often does this really happen?<a name="line.2089"></a>
-<span class="sourceLineNo">2090</span>      else<a name="line.2090"></a>
-<span class="sourceLineNo">2091</span>        return mid;<a name="line.2091"></a>
-<span class="sourceLineNo">2092</span>    }<a name="line.2092"></a>
-<span class="sourceLineNo">2093</span>    return -(low + 1);<a name="line.2093"></a>
-<span class="sourceLineNo">2094</span>  }<a name="line.2094"></a>
-<span class="sourceLineNo">2095</span><a name="line.2095"></a>
-<span class="sourceLineNo">2096</span>  /**<a name="line.2096"></a>
-<span class="sourceLineNo">2097</span>   * Binary search for keys in indexes.<a name="line.2097"></a>
-<span class="sourceLineNo">2098</span>   *<a name="line.2098"></a>
-<span class="sourceLineNo">2099</span>   * @param arr array of byte arrays to search for<a name="line.2099"></a>
-<span class="sourceLineNo">2100</span>   * @param key the key you want to find<a name="line.2100"></a>
-<span class="sourceLineNo">2101</span>   * @param comparator a comparator to compare.<a name="line.2101"></a>
-<span class="sourceLineNo">2102</span>   * @return zero-based index of the key, if the key is present in the array.<a name="line.2102"></a>
-<span class="sourceLineNo">2103</span>   *         Otherwise, a value -(i + 1) such that the key is between arr[i -<a name="line.2103"></a>
-<span class="sourceLineNo">2104</span>   *         1] and arr[i] non-inclusively, where i is in [0, i], if we define<a name="line.2104"></a>
-<span class="sourceLineNo">2105</span>   *         arr[-1] = -Inf and arr[N] = Inf for an N-element array. The above<a name="line.2105"></a>
-<span class="sourceLineNo">2106</span>   *         means that this function can return 2N + 1 different values<a name="line.2106"></a>
-<span class="sourceLineNo">2107</span>   *         ranging from -(N + 1) to N - 1.<a name="line.2107"></a>
-<span class="sourceLineNo">2108</span>   * @return the index of the block<a name="line.2108"></a>
-<span class="sourceLineNo">2109</span>   * @deprecated Use {@link Bytes#binarySearch(Cell[], Cell, CellComparator)}<a name="line.2109"></a>
-<span class="sourceLineNo">2110</span>   */<a name="line.2110"></a>
-<span class="sourceLineNo">2111</span>  @Deprecated<a name="line.2111"></a>
-<span class="sourceLineNo">2112</span>  public static int binarySearch(byte[][] arr, Cell key, RawComparator&lt;Cell&gt; comparator) {<a name="line.2112"></a>
-<span class="sourceLineNo">2113</span>    int low = 0;<a name="line.2113"></a>
-<span class="sourceLineNo">2114</span>    int high = arr.length - 1;<a name="line.2114"></a>
-<span class="sourceLineNo">2115</span>    KeyValue.KeyOnlyKeyValue r = new KeyValue.KeyOnlyKeyValue();<a name="line.2115"></a>
-<span cl

<TRUNCATED>

Mime
View raw message