@Override
  public int read(byte @NotNull [] buffer, int offset, int length) throws IOException {
    if (length == 0) {
      return 0;
    }
    int bytesRemains = available();
    assert bytesRemains >= 0 : "position(=" + position + ") > limit(=" + limit + ")";
    if (bytesRemains == 0) {
      return -1;
    }

    //only allow a read of the amount remains.
    if (length > bytesRemains) {
      length = bytesRemains;
    }
    pagedStorage.get(position, buffer, offset, length);
    position += length;

    return length;
  }
@Override
  public int read(byte @NotNull [] buffer, int offset, int length)