Decode long.

@param in  the in
@param max the max
@return the long
@throws IOException the io exception
326820
public long decode(final BitInputStream in, final long max)
    throws IOException {
    if (0 == max) {
      return 0;
    }
    int bits = (int) (Math.round(log2(2 * this.stdDev)) - 1);
    if (0 > bits) {
      bits = 0;
    }
    final long centralWindow = 1l << bits;
    if (centralWindow >= (max + 1) / 2.) {
      return in.readBoundedLong(max + 1);
    }
    long stdDevWindowStart = (long) (this.mean - centralWindow / 2);
    long stdDevWindowEnd = stdDevWindowStart + centralWindow;
    if (stdDevWindowStart < 0) {
      stdDevWindowEnd += -stdDevWindowStart;
      stdDevWindowStart += -stdDevWindowStart;
    }
    else {
      final long delta = stdDevWindowEnd - (max + 1);
      if (delta > 0) {
        stdDevWindowStart -= delta;
        stdDevWindowEnd -= delta;
      }
    }
    if (in.readBool()) {
      return in.readBoundedLong(centralWindow) + stdDevWindowStart;
    }
    else {
      boolean side;
      if (stdDevWindowStart <= 0) {
        side = true;
      }
      else if (stdDevWindowEnd > max) {
        side = false;
      }
      else {
        side = in.readBool();
      }
      if (side) {
        return stdDevWindowEnd + in.readBoundedLong(1 + max - stdDevWindowEnd);
      }
      else {
        return in.readBoundedLong(stdDevWindowStart);
      }
    }
  }
1161754
public Buffer readFrom(InputStream in) throws IOException {
    readFrom(in, Long.MAX_VALUE, true);
    return this;
  }
1115818
private static int readLen(InputStream in) throws IOException {
        int c = in.read();
        if (c > 0) {
            if ((c & 0x80) == 0) {
            } else if ((c & 0xC0) == 0x80) {
                c = c & ~0xC0;
                c = (c << 8) | in.read();
            } else if ((c & 0xE0) == 0xC0) {
                c = c & ~0xE0;
                c = (c << 8) | in.read();
                c = (c << 8) | in.read();
            } else if ((c & 0xF0) == 0xE0) {
                c = c & ~0xF0;
                c = (c << 8) | in.read();
                c = (c << 8) | in.read();
                c = (c << 8) | in.read();
            } else if ((c & 0xF8) == 0xF0) {
                c = in.read();
                c = (c << 8) | in.read();
                c = (c << 8) | in.read();
                c = (c << 8) | in.read();
                c = (c << 8) | in.read();
            }
        }
        return c;
    }
874243
public long readBoundedLong(final long max) throws IOException {
    final int bits = 0 >= max ? 0 : (int) (Math.floor(Math.log(max) / Math.log(2)) + 1);
    return 0 < bits ? this.read(bits).toLong() : 0;
  }
1297808
public T decodeContent(InputStream in, Charset charset) throws IOException {
        // 如果有内容
        if (getContentLength() > 0) {
            byte[] bytes = new byte[(int) getContentLength()];
            int contentSize = in.read(bytes);
            // 获取数据
            if (contentSize != getContentLength()) {
                throw new IOException("读取到的数据长度与协议长度不符");
            }
            return FdfsParamMapper.map(bytes, genericType, charset);
        }
        return null;
    }
1020367
public long getLong(final long min, final long max) {
		return min(min, max) + getLong(abs(max - min));
	}
1367136
public static int decodeTo(final byte[] output, int outOffset,
            final byte[] input, int inOffset, final int inLen)
    {
        if (inLen == 0)
            return 0;

        if (inLen % 4 != 0)
            throw new IllegalArgumentException("Input block size is not 4");

        int withoutPaddingLen = inLen, limit = inOffset + inLen;
        while (input[--limit] == pad)
            withoutPaddingLen--;

        // Create result array of exact required size.
        final int outLen = ((withoutPaddingLen) * 3) / 4;
        assert (output.length - outOffset) >= outLen;

        decode(input, inOffset, inLen, output, outOffset, outLen);

        return outLen;
    }
27743
public long expectLong() throws IOException {
        int b1 = in.read();
        if (b1 < 0) {
            throw new IOException("Missing byte 1 to expected long");
        }
        int b2 = in.read();
        if (b2 < 0) {
            throw new IOException("Missing byte 2 to expected long");
        }
        int b3 = in.read();
        if (b3 < 0) {
            throw new IOException("Missing byte 3 to expected long");
        }
        long b4 = in.read();
        if (b4 < 0) {
            throw new IOException("Missing byte 4 to expected long");
        }
        long b5 = in.read();
        if (b5 < 0) {
            throw new IOException("Missing byte 5 to expected long");
        }
        long b6 = in.read();
        if (b6 < 0) {
            throw new IOException("Missing byte 6 to expected long");
        }
        long b7 = in.read();
        if (b7 < 0) {
            throw new IOException("Missing byte 7 to expected long");
        }
        long b8 = in.read();
        if (b8 < 0) {
            throw new IOException("Missing byte 8 to expected long");
        }

        return unshift8bytes(b1, b2, b3, b4, b5, b6, b7, b8);
    }
635476
static public long unpackRecid(DataInput2 in) throws IOException {
        long val = in.readPackedLong();
        val = DataIO.parity1Get(val);
        return val >>> 1;
    }
787921
public static String readString(DataInput in) throws IOException {
        int length = WritableUtils.readVInt(in);
        byte[] bytes = new byte[length];
        in.readFully(bytes, 0, length);
        return decode(bytes);
    }
1013761
public long
getLong() throws IOException {
	String next = _getIdentifier("an integer");
	if (!Character.isDigit(next.charAt(0)))
		throw exception("expected an integer");
	try {
		return Long.parseLong(next);
	} catch (NumberFormatException e) {
		throw exception("expected an integer");
	}
}
799864
public static long readLong(byte[] source, int position) {
        return (long) (source[position] & 0xFF) << 56
                | (long) (source[position + 1] & 0xFF) << 48
                | (long) (source[position + 2] & 0xFF) << 40
                | (long) (source[position + 3] & 0xFF) << 32
                | (long) (source[position + 4] & 0xFF) << 24
                | (source[position + 5] & 0xFF) << 16
                | (source[position + 6] & 0xFF) << 8
                | (source[position + 7] & 0xFF);
    }
991671
public static long readLongBigEndian(InputStream io) throws IOException {
		long value = io.read();
		if (value < 0) throw new EOFException();
		value <<= 56;
		int i = io.read();
		if (i < 0) throw new EOFException();
		value |= ((long)i) << 48;
		i = io.read();
		if (i < 0) throw new EOFException();
		value |= ((long)i) << 40;
		i = io.read();
		if (i < 0) throw new EOFException();
		value |= ((long)i) << 32;
		i = io.read();
		if (i < 0) throw new EOFException();
		value |= ((long)i) << 24;
		i = io.read();
		if (i < 0) throw new EOFException();
		value |= i << 16;
		i = io.read();
		if (i < 0) throw new EOFException();
		value |= i << 8;
		i = io.read();
		if (i < 0) throw new EOFException();
		value |= i;
		return value;
	}
155678
public void read(ByteCodeParser in)
    throws IOException
  {
    int length = in.readInt();
    
    _maxStack = in.readShort();
    _maxLocals = in.readShort();

    int codeLength = in.readInt();

    _code = new byte[codeLength];
    in.read(_code, 0, codeLength);

    int exnCount = in.readShort();

    for (int i = 0; i < exnCount; i++) {
      ExceptionItem exn = new ExceptionItem();

      exn.setStart(in.readShort() & 0xffff);
      exn.setEnd(in.readShort() & 0xffff);
      exn.setHandler(in.readShort() & 0xffff);
      exn.setType(in.readShort() & 0xffff);

      _exceptions.add(exn);
    }

    int attrCount = in.readShort();

    for (int i = 0; i < attrCount; i++) {
      Attribute attr = in.parseAttribute();

      _attributes.add(attr);
    }
  }
432365
public static byte[] readStream(InputStream in) {
        if(in == null){
            return null;
        }
        ByteArrayOutputStream out = null;
        try {
            out = new ByteArrayOutputStream();
            byte[] buf = new byte[1024 * 8];
            int length = 0;
            while((length = in.read(buf)) != -1){
                out.write(buf, 0, length);
            }
            return out.toByteArray();

        } catch (IOException e) {
            throw new IORuntimeException(e);

        } finally {
            closeQuietly(in);
            closeQuietly(out);
        }
    }
242081
private static long readVLong(DataInput stream) throws IOException {
    byte firstByte = stream.readByte();
    int len = decodeVIntSize(firstByte);
    if (len == 1) {
      return firstByte;
    }
    long i = 0;
    for (int idx = 0; idx < len-1; idx++) {
      byte b = stream.readByte();
      i = i << 8;
      i = i | (b & 0xFF);
    }
    return (isNegativeVInt(firstByte) ? (i ^ -1L) : i);
  }
340956
public long readLong () throws KryoException {
		require(8);
		byte[] buffer = this.buffer;
		int p = position;
		position = p + 8;
		return buffer[p] & 0xFF //
			| (buffer[p + 1] & 0xFF) << 8 //
			| (buffer[p + 2] & 0xFF) << 16 //
			| (long)(buffer[p + 3] & 0xFF) << 24 //
			| (long)(buffer[p + 4] & 0xFF) << 32 //
			| (long)(buffer[p + 5] & 0xFF) << 40 //
			| (long)(buffer[p + 6] & 0xFF) << 48 //
			| (long)buffer[p + 7] << 56;
	}