presto-main/src/main/java/io/prestosql/operator/scalar/ArrayReverseFunction.java/ArrayReverseFunction/reverse
class ArrayReverseFunction:    @TypeParameter("E")
    @SqlType("array(E)")
    public Block reverse(
            @TypeParameter("E") Type type,
            @SqlType("array(E)") Block block)
    {
        int arrayLength = block.getPositionCount();

        if (arrayLength < 2) {
            return block;
        }

        if (pageBuilder.isFull()) {
            pageBuilder.reset();
        }

        BlockBuilder blockBuilder = pageBuilder.getBlockBuilder(0);
        for (int i = arrayLength - 1; i >= 0; i--) {
            type.appendTo(block, i, blockBuilder);
        }
        pageBuilder.declarePositions(arrayLength);

        return blockBuilder.getRegion(blockBuilder.getPositionCount() - arrayLength, arrayLength);
    }