@VisibleForTesting
    static RowGroup createRowGroup(int groupId, long rowsInStripe, long rowsInRowGroup, Map<StreamId, List<RowGroupIndex>> columnIndexes, Map<StreamId, ValueInputStream<?>> valueStreams, Map<StreamId, StreamCheckpoint> checkpoints)
    {
        long totalRowGroupBytes = columnIndexes
                .values()
                .stream()
                .mapToLong(e -> e.get(groupId)
                        .getColumnStatistics()
                        .getTotalValueSizeInBytes())
                .sum();

        long rowOffset = multiplyExact(groupId, rowsInRowGroup);
        int rowCount = toIntExact(Math.min(rowsInStripe - rowOffset, rowsInRowGroup));
        ImmutableMap.Builder<StreamId, InputStreamSource<?>> builder = ImmutableMap.builder();
        for (Entry<StreamId, StreamCheckpoint> entry : checkpoints.entrySet()) {
            StreamId streamId = entry.getKey();
            StreamCheckpoint checkpoint = entry.getValue();

            // skip streams without data
            ValueInputStream<?> valueStream = valueStreams.get(streamId);
            if (valueStream == null) {
                continue;
            }

            builder.put(streamId, createCheckpointStreamSource(valueStream, checkpoint));
        }
        InputStreamSources rowGroupStreams = new InputStreamSources(builder.build());
        return new RowGroup(groupId, rowOffset, rowCount, totalRowGroupBytes, rowGroupStreams);
    }
@Test
    public void testCreateRowGroup()
    {
        long numRowsInStripe = TEN_BILLION + MILLION;
        long rowsInRowGroup = BILLION;

        for (int groupId = 0; groupId < 11; groupId++) {
            RowGroup rowGroup = StripeReader.createRowGroup(groupId, numRowsInStripe, rowsInRowGroup, ImmutableMap.of(), ImmutableMap.of(), ImmutableMap.of());
            assertEquals(rowGroup.getGroupId(), groupId);
            assertEquals(rowGroup.getRowOffset(), groupId * (long) rowsInRowGroup);
            long expectedRows = groupId < 10 ? BILLION : MILLION;
            assertEquals(rowGroup.getRowCount(), expectedRows);
        }
    }