private static List<Query> batchSubqueries(Subqueries subqueries, int subqueryBatchFactor) {
        Iterator<Integer> iterator = subqueries.subqueries.iterator();
        List<Query> result = new ArrayList<>();
        while (iterator.hasNext()) {
            // Aggregate the subqueries that contains a given value.
            Map<Feature, Long> subqueriesForValue = new TreeMap<>();
            Map<Feature, Long> subqueriesForRange = new TreeMap<>();
            // Batch single to single subquery for batch factor 0.
            for (int i = 0; i < Math.max(1, subqueryBatchFactor) && iterator.hasNext(); ++i) {
                Integer subquery = iterator.next();
                registerSubqueryValues(i, subqueries.valuesForSubquery.get(subquery), subqueriesForValue);
                registerSubqueryValues(i, subqueries.rangesForSubquery.get(subquery), subqueriesForRange);
            }

            // Aggregate the values that are contained in a given set of subqueries.
            Query query = new Query(subqueryBatchFactor == 0);
            simplifyAndFillQueryValues(query.valuesForSubqueries, subqueriesForValue);
            simplifyAndFillQueryValues(query.rangesForSubqueries, subqueriesForRange);
            result.add(query);
        }
        return result;
    }
Converts a targeting query (the format provided by targeting team) into a file of Vespa queries formatted as URLs.

The format is the following:
- Each line represents one bulk query (upto 64 subqueries)
- Each bulk query has a set of subqueries separated by ";"
- Each subquery is of the format: attrName\tattrValue\tsubqueryIndex\tisRangeTerm;
- Some attributes have no value.
- Value may contain ";"

@author bjorncs
predicate-search/src/main/java/com/yahoo/search/predicate/utils/TargetingQueryFileConverter.java