}
FacetResultNode rootNode = new FacetResultNode(-1, dimCount);
rootNode.label = new CategoryPath(new String[] {dim});
rootNode.subResults = nodes;
results.add(new FacetResult(request, rootNode, nodes.size()));
continue;
}
TopCountPQ q = new TopCountPQ(request.numResults);
int bottomCount = 0;
//System.out.println("collect");
int dimCount = 0;
int childCount = 0;
FacetResultNode reuse = null;
for(int ord=ordRange.start; ord<=ordRange.end; ord++) {
//System.out.println(" ord=" + ord + " count= "+ counts[ord] + " bottomCount=" + bottomCount);
if (counts[ord] > 0) {
childCount++;
if (counts[ord] > bottomCount) {
dimCount += counts[ord];
//System.out.println(" keep");
if (reuse == null) {
reuse = new FacetResultNode(ord, counts[ord]);
} else {
reuse.ordinal = ord;
reuse.value = counts[ord];
}
reuse = q.insertWithOverflow(reuse);
if (q.size() == request.numResults) {
bottomCount = (int) q.top().value;
//System.out.println(" new bottom=" + bottomCount);
}
}
}
}
CategoryListParams.OrdinalPolicy op = searchParams.indexingParams.getCategoryListParams(request.categoryPath).getOrdinalPolicy(dim);
if (op == CategoryListParams.OrdinalPolicy.ALL_BUT_DIMENSION) {
dimCount = 0;
}
FacetResultNode rootNode = new FacetResultNode(-1, dimCount);
rootNode.label = new CategoryPath(new String[] {dim});
FacetResultNode[] childNodes = new FacetResultNode[q.size()];
for(int i=childNodes.length-1;i>=0;i--) {
childNodes[i] = q.pop();
dv.lookupOrd(childNodes[i].ordinal, scratch);
childNodes[i].label = new CategoryPath(scratch.utf8ToString().split(state.separatorRegex, 2));
}
rootNode.subResults = Arrays.asList(childNodes);
results.add(new FacetResult(request, rootNode, childCount));
}
return results;
}