예제 #1
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;
  }
예제 #2
0
  public String readString() {
    int length = (int) readVLong();
    Requires.range(length, 0, paging.getPageSize(), "length");

    char[] buffer = new char[length];
    readUtf8To(buffer, 0, length);
    return new String(buffer);
  }
예제 #3
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;
  }
예제 #4
0
  public long readPageNum() {
    PageNum pageNum = paging.getPageNum();

    ensureCanGrow(pageNum.size());

    long result = pageNum.readPageNum(address + position);
    Requires.positive(result, "result");

    position += pageNum.size();
    return result;
  }
예제 #5
0
  public int readInnerRef() {
    InnerRef innerRef = paging.getInnerRef();

    ensureCanGrow(innerRef.size());

    int result = innerRef.readInnerRef(address + position);
    Requires.range(result, 0, paging.getPageSize(), "result");

    position += innerRef.size();
    return result;
  }