public final void collect(int docid) {
   int idx = 0;
   int i = 0;
   int segsize = _countlength;
   for (DefaultFacetCountCollector subcollector : _subcollectors) {
     segsize = segsize / _lens[i++];
     idx += (subcollector._dataCache.orderArray.get(docid) * segsize);
   }
   _count.add(idx, _count.get(idx) + 1);
 }
    public BrowseFacet getFacet(String value) {
      String[] vals = value.split(_sep);
      if (vals.length == 0) return null;
      StringBuffer buf = new StringBuffer();
      int startIdx = 0;
      int segLen = _countlength;

      for (int i = 0; i < vals.length; ++i) {
        if (i > 0) {
          buf.append(_sep);
        }
        int index = _subcollectors[i]._dataCache.valArray.indexOf(vals[i]);
        String facetName = _subcollectors[i]._dataCache.valArray.get(index);
        buf.append(facetName);

        segLen /= _subcollectors[i]._countlength;
        startIdx += index * segLen;
      }

      int count = 0;
      for (int i = startIdx; i < startIdx + segLen; ++i) {
        count += _count.get(i);
      }

      BrowseFacet f = new BrowseFacet(buf.toString(), count);
      return f;
    }
    public int getFacetHitsCount(Object value) {
      String[] vals = ((String) value).split(_sep);
      if (vals.length == 0) return 0;
      int startIdx = 0;
      int segLen = _countlength;

      for (int i = 0; i < vals.length; ++i) {
        int index = _subcollectors[i]._dataCache.valArray.indexOf(vals[i]);
        segLen /= _subcollectors[i]._countlength;
        startIdx += index * segLen;
      }

      int count = 0;
      for (int i = startIdx; i < startIdx + segLen; ++i) count += _count.get(i);

      return count;
    }
    public List<BrowseFacet> getFacets() {
      if (_fspec != null) {
        int minCount = _fspec.getMinHitCount();
        int max = _fspec.getMaxCount();
        if (max <= 0) max = _countlength;

        FacetSortSpec sortspec = _fspec.getOrderBy();
        List<BrowseFacet> facetColl;
        if (sortspec == FacetSortSpec.OrderValueAsc) {
          facetColl = new ArrayList<BrowseFacet>(max);
          for (int i = 1; i < _countlength; ++i) // exclude zero
          {
            int hits = _count.get(i);
            if (hits >= minCount) {
              BrowseFacet facet = new BrowseFacet(getFacetString(i), hits);
              facetColl.add(facet);
            }
            if (facetColl.size() >= max) break;
          }
        } else {
          ComparatorFactory comparatorFactory;
          if (sortspec == FacetSortSpec.OrderHitsDesc) {
            comparatorFactory = new FacetHitcountComparatorFactory();
          } else {
            comparatorFactory = _fspec.getCustomComparatorFactory();
          }

          if (comparatorFactory == null) {
            throw new IllegalArgumentException("facet comparator factory not specified");
          }

          IntComparator comparator =
              comparatorFactory.newComparator(
                  new FieldValueAccessor() {

                    public String getFormatedValue(int index) {
                      return getFacetString(index);
                    }

                    public Object getRawValue(int index) {
                      return getRawFaceValue(index);
                    }
                  },
                  _count);
          facetColl = new LinkedList<BrowseFacet>();
          final int forbidden = -1;
          IntBoundedPriorityQueue pq = new IntBoundedPriorityQueue(comparator, max, forbidden);

          for (int i = 1; i < _countlength; ++i) // exclude zero
          {
            int hits = _count.get(i);
            if (hits >= minCount) {
              if (!pq.offer(i)) {
                // pq is full. we can safely ignore any facet with <=hits.
                minCount = hits + 1;
              }
            }
          }

          int val;
          while ((val = pq.pollInt()) != forbidden) {
            BrowseFacet facet = new BrowseFacet(getFacetString(val), _count.get(val));
            ((LinkedList<BrowseFacet>) facetColl).addFirst(facet);
          }
        }
        return facetColl;
      } else {
        return FacetCountCollector.EMPTY_FACET_LIST;
      }
    }
 public final void collect(int docid) {
   _count[_array.get(docid)]++;
 }