Beispiel #1
0
 private static final int[] computeMultivaluedTD(
     ReaderAbstract reader,
     String fieldName,
     FieldCacheIndex stringIndex,
     DocIdInterface docIdInterface)
     throws IOException, SearchLibException {
   int[] countIndex = new int[stringIndex.lookup.length];
   int indexPos = 0;
   if (docIdInterface.getSize() == 0) return countIndex;
   int[] docs = new int[100];
   int[] freqs = new int[100];
   BitSetInterface bitset = docIdInterface.getBitSet();
   Term oTerm = new Term(fieldName);
   for (String term : stringIndex.lookup) {
     if (term != null) {
       Term t = oTerm.createTerm(term);
       TermDocs termDocs = reader.getTermDocs(t);
       int l;
       while ((l = termDocs.read(docs, freqs)) > 0)
         for (int i = 0; i < l; i++)
           if (freqs[i] > 0) if (bitset.get(docs[i])) countIndex[indexPos]++;
       termDocs.close();
     }
     indexPos++;
   }
   return countIndex;
 }
Beispiel #2
0
 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;
 }
Beispiel #3
0
 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;
 }