public ByteBuffer[] getPages() {
    int numPages = _pages.size();

    boolean lastPageIsEmpty = _written == (numPages - 1) * (long) _pageSize;
    if (lastPageIsEmpty) {
      numPages--;
    }
    if (numPages == 0) {
      return new ByteBuffer[0];
    }
    ByteBuffer[] result = new ByteBuffer[numPages];

    for (int i = 0; i < numPages; i++) {
      ByteBuffer byteBuffer = _pages.get(i);
      ByteBuffer page = byteBuffer.asReadOnlyBuffer();
      page.clear();
      result[i] = page;
    }

    if (!lastPageIsEmpty) {
      long startOffset = getCurrentOffset();
      seek(_written);
      result[numPages - 1].limit(_offsetInPage);
      seek(startOffset);
    }

    return result;
  }
@Test
  void testGetPagesEmpty() {
    ByteBuffer[] pages = _pagedPinotOutputStream.getPages();
    assertEquals(pages.length, 0);
  }