presto-main/src/main/java/io/prestosql/operator/aggregation/GenericAccumulatorFactory.java/GenericAccumulatorFactory/filter
class GenericAccumulatorFactory:    private static Page filter(Page page, Block mask)
    {
        int[] ids = new int[mask.getPositionCount()];
        int next = 0;
        for (int i = 0; i < page.getPositionCount(); ++i) {
            if (BOOLEAN.getBoolean(mask, i)) {
                ids[next++] = i;
            }
        }

        return page.getPositions(ids, 0, next);
    }