Example usage for org.apache.lucene.util LongValues get

List of usage examples for org.apache.lucene.util LongValues get

Introduction

In this page you can find the example usage for org.apache.lucene.util LongValues get.

Prototype

public abstract long get(long index);

Source Link

Document

Get value at index.

Usage

From source file:org.apache.solr.request.DocValuesStats.java

License:Apache License

/** accumulates per-segment single-valued stats */
static int accumSingle(int counts[], int docBase, FieldFacetStats[] facetStats, SortedDocValues si,
        DocIdSetIterator disi, int subIndex, OrdinalMap map) throws IOException {
    final LongValues ordMap = map == null ? null : map.getGlobalOrds(subIndex);
    int missingDocCount = 0;
    int doc;//from   w  w w.  j a  va 2  s .c om
    while ((doc = disi.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
        int term = si.getOrd(doc);
        if (term >= 0) {
            if (map != null) {
                term = (int) ordMap.get(term);
            }
            counts[term]++;
            for (FieldFacetStats f : facetStats) {
                f.facetTermNum(docBase + doc, term);
            }
        } else {
            for (FieldFacetStats f : facetStats) {
                f.facetMissingNum(docBase + doc);
            }

            missingDocCount++;
        }
    }
    return missingDocCount;
}

From source file:org.apache.solr.request.DocValuesStats.java

License:Apache License

/** accumulates per-segment multi-valued stats */

static int accumMulti(int counts[], int docBase, FieldFacetStats[] facetStats, SortedSetDocValues si,
        DocIdSetIterator disi, int subIndex, OrdinalMap map) throws IOException {
    final LongValues ordMap = map == null ? null : map.getGlobalOrds(subIndex);
    int missingDocCount = 0;
    int doc;// www  .  j a va  2 s  .  c  om
    while ((doc = disi.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
        si.setDocument(doc);
        long ord;
        boolean emptyTerm = true;
        while ((ord = si.nextOrd()) != SortedSetDocValues.NO_MORE_ORDS) {
            emptyTerm = false;
            int term = (int) ord;
            if (map != null) {
                term = (int) ordMap.get(term);
            }
            counts[term]++;
            for (FieldFacetStats f : facetStats) {
                f.facetTermNum(docBase + doc, term);
            }
        }
        if (emptyTerm) {
            for (FieldFacetStats f : facetStats) {
                f.facetMissingNum(docBase + doc);
            }

            missingDocCount++;
        }
    }

    return missingDocCount;
}

From source file:org.apache.solr.search.facet.FacetFieldProcessorByArrayDV.java

License:Apache License

private void collectPerSeg(SortedDocValues singleDv, DocIdSetIterator disi, LongValues toGlobal)
        throws IOException {
    int segMax = singleDv.getValueCount() + 1;
    final int[] counts = getCountArr(segMax);

    /** alternate trial implementations
     // ord/*w w  w. ja  v a 2s.c  o  m*/
     // FieldUtil.visitOrds(singleDv, disi,  (doc,ord)->{counts[ord+1]++;} );
            
    FieldUtil.OrdValues ordValues = FieldUtil.getOrdValues(singleDv, disi);
    while (ordValues.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
      counts[ ordValues.getOrd() + 1]++;
    }
     **/

    // calculate segment-local counts
    int doc;
    if (singleDv instanceof FieldCacheImpl.SortedDocValuesImpl.Iter) {
        FieldCacheImpl.SortedDocValuesImpl.Iter fc = (FieldCacheImpl.SortedDocValuesImpl.Iter) singleDv;
        while ((doc = disi.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
            counts[fc.getOrd(doc) + 1]++;
        }
    } else {
        while ((doc = disi.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
            if (singleDv.advanceExact(doc)) {
                counts[singleDv.ordValue() + 1]++;
            }
        }
    }

    // convert segment-local counts to global counts
    for (int i = 1; i < segMax; i++) {
        int segCount = counts[i];
        if (segCount > 0) {
            int slot = toGlobal == null ? (i - 1) : (int) toGlobal.get(i - 1);
            countAcc.incrementCount(slot, segCount);
        }
    }
}

From source file:org.apache.solr.search.facet.FacetFieldProcessorByArrayDV.java

License:Apache License

private void collectPerSeg(SortedSetDocValues multiDv, DocIdSetIterator disi, LongValues toGlobal)
        throws IOException {
    int segMax = (int) multiDv.getValueCount();
    final int[] counts = getCountArr(segMax);

    int doc;/*from  w  w  w . ja va  2 s  .com*/
    while ((doc = disi.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
        if (multiDv.advanceExact(doc)) {
            for (;;) {
                int segOrd = (int) multiDv.nextOrd();
                if (segOrd < 0)
                    break;
                counts[segOrd]++;
            }
        }
    }

    for (int i = 0; i < segMax; i++) {
        int segCount = counts[i];
        if (segCount > 0) {
            int slot = toGlobal == null ? (i) : (int) toGlobal.get(i);
            countAcc.incrementCount(slot, segCount);
        }
    }
}

From source file:org.apache.solr.search.facet.FacetFieldProcessorByArrayDV.java

License:Apache License

private void collectCounts(SortedDocValues singleDv, DocIdSetIterator disi, LongValues toGlobal)
        throws IOException {
    int doc;/*from   ww w  .  j a va  2 s.  co m*/
    if (singleDv instanceof FieldCacheImpl.SortedDocValuesImpl.Iter) {

        FieldCacheImpl.SortedDocValuesImpl.Iter fc = (FieldCacheImpl.SortedDocValuesImpl.Iter) singleDv;
        while ((doc = disi.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
            int segOrd = fc.getOrd(doc);
            if (segOrd < 0)
                continue;
            int ord = (int) toGlobal.get(segOrd);
            countAcc.incrementCount(ord, 1);
        }

    } else {

        while ((doc = disi.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
            if (singleDv.advanceExact(doc)) {
                int segOrd = singleDv.ordValue();
                int ord = (int) toGlobal.get(segOrd);
                countAcc.incrementCount(ord, 1);
            }
        }

    }
}

From source file:org.apache.solr.search.facet.FacetFieldProcessorByArrayDV.java

License:Apache License

private void collectCounts(SortedSetDocValues multiDv, DocIdSetIterator disi, LongValues toGlobal)
        throws IOException {
    int doc;//  www. java2 s . c o m
    while ((doc = disi.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
        if (multiDv.advanceExact(doc)) {
            for (;;) {
                int segOrd = (int) multiDv.nextOrd();
                if (segOrd < 0)
                    break;
                int ord = (int) toGlobal.get(segOrd);
                countAcc.incrementCount(ord, 1);
            }
        }
    }
}

From source file:org.apache.solr.search.facet.FacetFieldProcessorByArrayDV.java

License:Apache License

private void collect(int doc, int segOrd, LongValues toGlobal) throws IOException {
    int ord = (toGlobal != null && segOrd >= 0) ? (int) toGlobal.get(segOrd) : segOrd;

    int arrIdx = ord - startTermIndex;
    if (arrIdx >= 0 && arrIdx < nTerms) {
        countAcc.incrementCount(arrIdx, 1);
        if (collectAcc != null) {
            collectAcc.collect(doc, arrIdx);
        }//from  w  w w.  j a  v a  2 s  .  co m
        if (allBucketsAcc != null) {
            allBucketsAcc.collect(doc, arrIdx);
        }
    }
}

From source file:org.apache.solr.search.facet.FacetFieldProcessorDV.java

License:Apache License

private void collectPerSeg(SortedDocValues singleDv, DocIdSetIterator disi, LongValues toGlobal)
        throws IOException {
    int segMax = singleDv.getValueCount() + 1;
    final int[] counts = getCountArr(segMax);

    int doc;//w  w w. j a va 2s.  com
    while ((doc = disi.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
        counts[singleDv.getOrd(doc) + 1]++;
    }

    for (int i = 1; i < segMax; i++) {
        int segCount = counts[i];
        if (segCount > 0) {
            int slot = toGlobal == null ? (i - 1) : (int) toGlobal.get(i - 1);
            countAcc.incrementCount(slot, segCount);
        }
    }
}

From source file:org.apache.solr.search.facet.FacetFieldProcessorDV.java

License:Apache License

private void collectPerSeg(SortedSetDocValues multiDv, DocIdSetIterator disi, LongValues toGlobal)
        throws IOException {
    int segMax = (int) multiDv.getValueCount();
    final int[] counts = getCountArr(segMax);

    int doc;//ww w  . j a v  a 2s .  c  o  m
    while ((doc = disi.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
        multiDv.setDocument(doc);
        for (;;) {
            int segOrd = (int) multiDv.nextOrd();
            if (segOrd < 0)
                break;
            counts[segOrd]++;
        }
    }

    for (int i = 0; i < segMax; i++) {
        int segCount = counts[i];
        if (segCount > 0) {
            int slot = toGlobal == null ? (i) : (int) toGlobal.get(i);
            countAcc.incrementCount(slot, segCount);
        }
    }
}

From source file:org.apache.solr.search.facet.FacetFieldProcessorDV.java

License:Apache License

private void collectCounts(SortedDocValues singleDv, DocIdSetIterator disi, LongValues toGlobal)
        throws IOException {
    int doc;/*from   w  ww.  j  a v  a 2  s. c  o  m*/
    while ((doc = disi.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
        int segOrd = singleDv.getOrd(doc);
        if (segOrd < 0)
            continue;
        int ord = (int) toGlobal.get(segOrd);
        countAcc.incrementCount(ord, 1);
    }
}