public static long convertByteArrayToLong(byte[] numberAsByteArray) {
    if (numberAsByteArray == null) {
      throw new IllegalArgumentException("convertByteArrayToLong called with a null array");
    }

    int i = 0;
    long result = 0;
    boolean isNegative = false;

    if (numberAsByteArray[i] == ParseConstants.MINUS_SIGN) {
      i++;
      isNegative = true;
    }

    while (i != numberAsByteArray.length) {
      if (
        numberAsByteArray[i] < ParseConstants.ZERO || numberAsByteArray[i] > ParseConstants.NINE
      ) {
        throw new IllegalArgumentException("Byte Array should only contain digits");
      }
      result = result * 10 + (numberAsByteArray[i] - ParseConstants.ZERO);
      if (result < 0) {
        throw new IllegalArgumentException("Long Argument too large");
      }
      i++;
    }

    if (isNegative) {
      return -result;
    } else {
      return result;
    }
  }
Converts a long expressed in a byte array to an actual long
<p>
This doesn't use Bytes.toLong because that assumes that there will be {@link Bytes#SIZEOF_INT}
bytes available.
<p>
@param numberAsByteArray the long value expressed as a byte array
@return the long value
hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ParseFilter.java