public BlockLease flatten(Block block)
    {
        requireNonNull(block, "block is null");
        if (block instanceof DictionaryBlock) {
            return flattenDictionaryBlock((DictionaryBlock) block);
        }
        if (block instanceof RunLengthEncodedBlock) {
            return flattenRunLengthEncodedBlock((RunLengthEncodedBlock) block);
        }
        return newLease(block);
    }
@Test
    public void testNestedRLEs()
    {
        Block block = createTestRleBlock(createTestRleBlock(createTestRleBlock(createLongArrayBlock(5), 1), 1), 4);
        assertEquals(block.getPositionCount(), 4);
        try (BlockLease blockLease = flattener.flatten(block)) {
            Block flattenedBlock = blockLease.get();
            assertEquals(flattenedBlock.getClass(), RunLengthEncodedBlock.class);
            assertEquals(flattenedBlock.getPositionCount(), block.getPositionCount());
            assertEquals(flattenedBlock.getClass(), RunLengthEncodedBlock.class);
            assertEquals(((RunLengthEncodedBlock) flattenedBlock).getValue().getClass(), LongArrayBlock.class);

            Block innerBlock = ((RunLengthEncodedBlock) flattenedBlock).getValue();
            assertEquals(innerBlock.getPositionCount(), 1);
        }
    }