保证缓冲区大小
@param addBytes 增加的字节数组长度

@return 返回当前buff
14859
protected BytesBuff ensureCapacity(int addBytes) {
		if (addBytes < 0) {
			throw new IllegalArgumentException(String.format("addBytes: %d (expected: >= 0)", addBytes));
		}
		ensureCapacityUnsafe(addBytes);
		return this;
	}
135024
public static long buff2long(byte[] bs, int offset) {
        return (((long) (bs[offset] >= 0 ? bs[offset] : 256 + bs[offset])) << 56)
                | (((long) (bs[offset + 1] >= 0 ? bs[offset + 1] : 256 + bs[offset + 1])) << 48)
                | (((long) (bs[offset + 2] >= 0 ? bs[offset + 2] : 256 + bs[offset + 2])) << 40)
                | (((long) (bs[offset + 3] >= 0 ? bs[offset + 3] : 256 + bs[offset + 3])) << 32)
                | (((long) (bs[offset + 4] >= 0 ? bs[offset + 4] : 256 + bs[offset + 4])) << 24)
                | (((long) (bs[offset + 5] >= 0 ? bs[offset + 5] : 256 + bs[offset + 5])) << 16)
                | (((long) (bs[offset + 6] >= 0 ? bs[offset + 6] : 256 + bs[offset + 6])) << 8)
                | (bs[offset + 7] >= 0 ? bs[offset + 7] : 256 + bs[offset + 7]);
    }
1037503
private void append(byte[] data) {
    if (storage.position() + data.length >= storage.capacity()) {
      ByteBuffer tmp = ByteBuffer.allocate(storage.limit() + data.length * 2);
      byte[] tmpData = new byte[storage.position()];
      storage.flip();
      storage.get(tmpData);
      tmp.put(tmpData);
      storage = tmp;
      logger.warn("Increase storage size. Current size is {}", storage.array().length);
    }

    try {
      storage.put(data);
    }
    catch (BufferOverflowException boe) {
      logger.error("Buffer overflow occured", boe);
    }
    boolean messageReceived;
    do {
      messageReceived = seekMessage();
    } while (messageReceived);
  }
735647
public void append(byte data) {
        // 当数组长度等于当前数据大小时进行扩展
        if (0 >= (this.datas.length - size)) {
            // 如果扩展后的数组大于当前数组，那么先把当前数组长度增加，一次扩展256
            byte[] newData = new byte[256 + size];
            System.arraycopy(this.datas, 0, newData, 0, size);
            this.datas = newData;
        }
        this.datas[size] = data;
        this.size += 1;
        modCount++;
    }
510006
public static int putBigDecimal(byte[] bytes, int offset, BigDecimal val) {
    if (bytes == null) {
      return offset;
    }

    byte[] valueBytes = val.unscaledValue().toByteArray();
    byte[] result = new byte[valueBytes.length + SIZEOF_INT];
    offset = putInt(result, offset, val.scale());
    return putBytes(result, offset, valueBytes, 0, valueBytes.length);
  }
682328
public static byte[] getBytes(ByteBuffer buf) {
    int savedPos = buf.position();
    byte [] newBytes = new byte[buf.remaining()];
    buf.get(newBytes);
    buf.position(savedPos);
    return newBytes;
  }
898474
public static byte[] ensureCapacity(byte array[], int capacity){
        if(capacity<=0 || capacity-array.length<=0)
            return array;

        int newCapacity = array.length*2;
        if(newCapacity-capacity< 0)
            newCapacity = capacity;
        if(newCapacity<0){
            if(capacity<0) // overflow
                throw new OutOfMemoryError();
            newCapacity = Integer.MAX_VALUE;
        }
        return Arrays.copyOf(array, newCapacity);
    }
1285762
public synchronized int put(byte[] src, int off, int len) {
        if (available == capacity) {
            return 0;
        }

        // limit is last index to put + 1
        int limit = idxPut < idxGet ? idxGet : capacity;
        int count = Math.min(limit - idxPut, len);
        System.arraycopy(src, off, buffer, idxPut, count);
        idxPut += count;

        if (idxPut == capacity) {
            // Array end reached, check if we have more
            int count2 = Math.min(len - count, idxGet);
            if (count2 > 0) {
                System.arraycopy(src, off + count, buffer, 0, count2);
                idxPut = count2;
                count += count2;
            } else {
                idxPut = 0;
            }
        }
        available += count;
        return count;
    }
410747
public static String encode(byte[] bytes)
    {
        StringBuilder sb = new StringBuilder(bytes.length << 1);
        for (byte aByte : bytes)
        {
            sb.append(convertDigit(aByte >> 4));
            sb.append(convertDigit(aByte & 0x0f));
        }
        return sb.toString();
    }
1080919
public static String bytes2Bits(final byte[] bytes) {
        StringBuilder sb = new StringBuilder();
        for (byte aByte : bytes) {
            for (int j = 7; j >= 0; --j) {
                sb.append(((aByte >> j) & 0x01) == 0 ? '0' : '1');
            }
        }
        return sb.toString();
    }
1317506
public void append(final int b) {
        final int newlen = this.len + 1;
        if (newlen > this.array.length) {
            expand(newlen);
        }
        this.array[this.len] = (byte)b;
        this.len = newlen;
    }
313723
public static HeapBuffer wrap(byte[] bytes) {
    return new HeapBuffer(HeapBytes.wrap(bytes), 0, bytes.length, bytes.length);
  }
501178
public com.google.protobuf.ByteString
      getSaveTensorNameBytes() {
    java.lang.Object ref = saveTensorName_;
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b = 
          com.google.protobuf.ByteString.copyFromUtf8(
              (java.lang.String) ref);
      saveTensorName_ = b;
      return b;
    } else {
      return (com.google.protobuf.ByteString) ref;
    }
  }
184140
@Override
    public void asBytes(ByteBuffer buf) {
        buf.putInt(VERBOSE_ENCODING);
        buf.putDouble(min);
        buf.putDouble(max);
        buf.putDouble((float) compression());
        buf.putInt(summary.size());
        for (Centroid centroid : summary) {
            buf.putDouble(centroid.mean());
        }

        for (Centroid centroid : summary) {
            buf.putInt(centroid.count());
        }
    }
188010
public Guid append(byte[]... byteArrays) throws IOException {
    if (byteArrays == null || byteArrays.length == 0) {
      return this;
    }
    return fromByteArrays(ArrayUtils.add(byteArrays, this.sha));
  }
344234
public static final byte[] asByteArray(WsByteBuffer buff) {
        if (null == buff)
            return null;
        int size = buff.limit();
        if (0 == size) {
            return null;
        }
        byte[] output = new byte[size];
        int position = buff.position();
        buff.position(0);
        buff.get(output);
        buff.position(position);
        return output;
    }
1184946
public static int bitLength (byte[] bytes) {
        Objects.requireNonNull(bytes, Required.BYTES.toString());
        int byteLength = bytes.length;
        
        int length = 0;
        if (byteLength <= MAX_BYTE_LENGTH && byteLength > 0) {
            length = byteLength * BYTES;
        }
        
        return length;
    }