コード例 #1
0
  public byte[] readBytes() {
    int len = (int) readVLong();
    Requires.range(len, 0, paging.getPageSize(), "len");

    ensureCanGrow(len);
    byte[] blob = new byte[len];
    Unsafe.INSTANCE.copyMemory(null, address + position, blob, Unsafe.BYTEARRAY_BASEOFFSET, len);
    position += len;
    return blob;
  }
コード例 #2
0
  public void readBytesTo(byte[] buffer, int offset, int length) {
    Requires.nonNull(buffer, "buffer");
    Requires.positive(offset, "offset");
    Requires.positive(length, "length");

    ensureCanGrow(length);
    Unsafe.INSTANCE.copyMemory(
        null,
        address + position,
        buffer,
        Unsafe.BYTEARRAY_BASEOFFSET + offset * Unsafe.BYTEARRAY_INDEXSCALE,
        length);
    position += length;
  }
コード例 #3
0
 public double readDouble() {
   ensureCanGrow(8);
   double value = Unsafe.INSTANCE.getDouble(address + position);
   position += 8;
   return BigEndian.ioDouble(value);
 }
コード例 #4
0
 public float readFloat() {
   ensureCanGrow(4);
   float value = Unsafe.INSTANCE.getFloat(address + position);
   position += 4;
   return BigEndian.ioFloat(value);
 }
コード例 #5
0
 public long readLong() {
   ensureCanGrow(8);
   long value = Unsafe.INSTANCE.getLong(address + position);
   position += 8;
   return BigEndian.ioLong(value);
 }
コード例 #6
0
 public int readInt() {
   ensureCanGrow(4);
   int value = Unsafe.INSTANCE.getInt(address + position);
   position += 4;
   return BigEndian.ioInt(value);
 }
コード例 #7
0
 public short readShort() {
   ensureCanGrow(2);
   short value = Unsafe.INSTANCE.getShort(address + position);
   position += 2;
   return BigEndian.ioShort(value);
 }
コード例 #8
0
 public char readChar() {
   ensureCanGrow(2);
   char value = Unsafe.INSTANCE.getChar(address + position);
   position += 2;
   return BigEndian.ioChar(value);
 }
コード例 #9
0
 public byte readByte() {
   ensureCanGrow(1);
   byte value = Unsafe.INSTANCE.getByte(address + position);
   position++;
   return value;
 }