presto-thrift-api/src/main/java/io/prestosql/plugin/thrift/api/datatypes/PrestoThriftTypeUtils.java/PrestoThriftTypeUtils/fromIntBasedBlock
class PrestoThriftTypeUtils:    public static PrestoThriftBlock fromIntBasedBlock(Block block, Type type, BiFunction<boolean[], int[], PrestoThriftBlock> result)
    {
        int positions = block.getPositionCount();
        if (positions == 0) {
            return result.apply(null, null);
        }
        boolean[] nulls = null;
        int[] ints = null;
        for (int position = 0; position < positions; position++) {
            if (block.isNull(position)) {
                if (nulls == null) {
                    nulls = new boolean[positions];
                }
                nulls[position] = true;
            }
            else {
                if (ints == null) {
                    ints = new int[positions];
                }
                ints[position] = (int) type.getLong(block, position);
            }
        }
        return result.apply(nulls, ints);
    }