public static long byteArrayToLong(byte[] b, int offset) {
    long value = 0;
    for (int i = 0; i < 8; i++) {
      int shift = (8 - 1 - i) * 8;
      value += ((long) (b[i + offset] & 0x00000000000000FF)) << shift;
    }
    return value;
  }
Convert the byte array to a long starting from the given offset.

@param b
         the byte array
@param offset
         the array offset
@return the long
serde/src/java/org/apache/hadoop/hive/serde2/lazybinary/LazyBinaryUtils.java