@VisibleForTesting
    static DwrfProto.Stream toStream(Stream stream)
    {
        DwrfProto.Stream.Builder streamBuilder = DwrfProto.Stream.newBuilder()
                .setColumn(stream.getColumn())
                .setSequence(stream.getSequence())
                .setKind(toStreamKind(stream.getStreamKind()))
                .setLength(stream.getLength())
                .setUseVInts(stream.isUseVInts());
        stream.getOffset().ifPresent(streamBuilder::setOffset);

        return streamBuilder.build();
    }
@Test
    public void testToStream()
    {
        int expectedSequence = 10;
        int expectedLength = 15;
        long expectedOffset = 25;
        boolean expectedUseVints = true;

        Stream stream = new Stream(COLUMN_ID, expectedSequence, DATA, expectedLength, expectedUseVints);
        DwrfProto.Stream actual = toStream(stream);
        assertEquals(actual.getColumn(), COLUMN_ID);
        assertEquals(actual.getSequence(), expectedSequence);
        assertEquals(actual.getKind(), DwrfProto.Stream.Kind.DATA);
        assertEquals(actual.getLength(), expectedLength);
        assertTrue(actual.getUseVInts());
        assertFalse(actual.hasOffset());

        stream = new Stream(COLUMN_ID, DATA, expectedLength, expectedUseVints, expectedSequence, Optional.of(expectedOffset));
        actual = toStream(stream);
        assertEquals(actual.getColumn(), COLUMN_ID);
        assertEquals(actual.getSequence(), expectedSequence);
        assertEquals(actual.getKind(), DwrfProto.Stream.Kind.DATA);
        assertEquals(actual.getLength(), expectedLength);
        assertTrue(actual.getUseVInts());
        assertEquals(actual.getOffset(), expectedOffset);
    }