facetColl = new ArrayList<BrowseFacet>(maxNumOfFacets);
for (int k=0;k<_predefinedRangeIndexes.length;++k)
{
if(rangeCount.get(k) >= minCount)
{
BrowseFacet choice=new BrowseFacet(_predefinedRanges.get(k), rangeCount.get(k));
facetColl.add(choice);
}
if(facetColl.size() >= maxNumOfFacets) break;
}
}
else //if (sortspec == FacetSortSpec.OrderHitsDesc)
{
ComparatorFactory comparatorFactory;
if (sortspec == FacetSortSpec.OrderHitsDesc)
{
comparatorFactory = new FacetHitcountComparatorFactory();
}
else
{
comparatorFactory = _ospec.getCustomComparatorFactory();
}
if (comparatorFactory == null){
throw new IllegalArgumentException("facet comparator factory not specified");
}
final IntComparator comparator = comparatorFactory.newComparator(new FieldValueAccessor(){
public String getFormatedValue(int index)
{
return _predefinedRanges.get(index);
}
public Object getRawValue(int index) {
return _predefinedRanges.getRawValue(index);
}
}, rangeCount);
final int forbidden = -1;
IntBoundedPriorityQueue pq=new IntBoundedPriorityQueue(comparator, maxNumOfFacets, forbidden);
for (int i=0; i<_predefinedRangeIndexes.length; ++i)
{
if (rangeCount.get(i)>=minCount) pq.offer(i);
}
int val;
facetColl=new LinkedList<BrowseFacet>();
while((val = pq.pollInt()) != forbidden)
{
BrowseFacet facet=new BrowseFacet(_predefinedRanges.get(val),rangeCount.get(val));
((LinkedList<BrowseFacet>)facetColl).addFirst(facet);
}
}
return facetColl;
}