@Override
  public BytesInput getBytes() {
    // The Page Header should include: blockSizeInValues, numberOfMiniBlocks, totalValueCount
    if (deltaValuesToFlush != 0) {
      flushBlockBuffer();
    }
    return BytesInput.concat(
        config.toBytesInput(),
        BytesInput.fromUnsignedVarInt(totalValueCount),
        BytesInput.fromZigZagVarLong(firstValue),
        BytesInput.from(baos));
  }
@Test
  public void shouldReturnCorrectOffsetAfterInitialization() throws IOException {
    long[] data = new long[2 * blockSize + 3];
    for (int i = 0; i < data.length; i++) {
      data[i] = i * 32;
    }
    writeData(data);

    reader = new DeltaBinaryPackingValuesReader();
    BytesInput bytes = writer.getBytes();
    byte[] valueContent = bytes.toByteArray();
    byte[] pageContent = new byte[valueContent.length * 10];
    int contentOffsetInPage = 33;
    System.arraycopy(valueContent, 0, pageContent, contentOffsetInPage, valueContent.length);

    // offset should be correct
    ByteBufferInputStream stream = ByteBufferInputStream.wrap(ByteBuffer.wrap(pageContent));
    stream.skipFully(contentOffsetInPage);
    reader.initFromPage(100, stream);
    long offset = stream.position();
    assertEquals(valueContent.length + contentOffsetInPage, offset);

    // should be able to read data correctly
    for (long i : data) {
      assertEquals(i, reader.readLong());
    }

    // Testing the deprecated behavior of using byte arrays directly
    reader = new DeltaBinaryPackingValuesReader();
    reader.initFromPage(100, pageContent, contentOffsetInPage);
    assertEquals(valueContent.length + contentOffsetInPage, reader.getNextOffset());
    for (long i : data) {
      assertEquals(i, reader.readLong());
    }
  }