public long readNByteLong(int bytes, Position readPos) {
    long v = 0;
    if (isAllInOneReadBuffer(bytes, readPos)) {
      for (int i = 0; i < bytes; ++i) {
        v = (v << 8) + (readPos.buffer[readPos.offset + i] & 0xff);
      }
      readPos.offset += bytes;
    } else {
      for (int i = 0; i < bytes; ++i) {
        v = (v << 8) + (readNextByte(readPos) & 0xff);
      }
    }
    return v;
  }
THIS METHOD IS NOT THREAD-SAFE. Use only at load time (or be mindful of thread safety).
serde/src/java/org/apache/hadoop/hive/serde2/WriteBuffers.java