private static final int[] computeSinglevalued( FieldCacheIndex stringIndex, DocIdInterface collector) throws IOException { int[] countArray = new int[stringIndex.lookup.length]; int[] order = stringIndex.order; int i = collector.getSize(); for (int id : collector.getIds()) { if (i == 0) break; countArray[order[id]]++; i--; } return countArray; }
private static final Map<String, FacetItem> computeMultivaluedTFV( ReaderAbstract reader, String fieldName, DocIdInterface docIdInterface) throws IOException, SearchLibException { Map<String, FacetItem> termMap = new HashMap<String, FacetItem>(); if (docIdInterface.getSize() == 0) return termMap; for (int docId : docIdInterface.getIds()) { TermFreqVector tfv = reader.getTermFreqVector(docId, fieldName); if (tfv == null) continue; String[] terms = tfv.getTerms(); int[] freqs = tfv.getTermFrequencies(); if (terms == null || freqs == null) continue; int i = 0; for (String term : terms) { if (freqs[i++] > 0) { FacetItem facetItem = termMap.get(term); if (facetItem == null) termMap.put(term, new FacetItem(term, 1)); else facetItem.count++; } } } return termMap; }