Example usage for org.apache.lucene.index OrdinalMap getGlobalOrds

List of usage examples for org.apache.lucene.index OrdinalMap getGlobalOrds

Introduction

In this page you can find the example usage for org.apache.lucene.index OrdinalMap getGlobalOrds.

Prototype

public LongValues getGlobalOrds(int segmentIndex) 

Source Link

Document

Given a segment number, return a LongValues instance that maps segment ordinals to global ordinals.

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. ja va2s . c  o  m*/
    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;//ww  w .j  a  v  a  2 s.c  o  m
    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.join.BlockJoinFieldFacetAccumulator.java

License:Apache License

/** folds counts in segment ordinal space (segCounts) into global ordinal space (counts) 
 * copy paste-from {@link DocValuesFacets#migrateGlobal(int[], int[], int, OrdinalMap)}*/
void migrateGlobal(int counts[], long segCounts[], int subIndex, OrdinalMap map) {

    final LongValues ordMap = map.getGlobalOrds(subIndex);
    // missing count
    counts[0] += (int) (segCounts[0] >> 32);

    // migrate actual ordinals
    for (int ord = 1; ord <= segmentSSDV.getValueCount(); ord++) {
        int count = (int) (segCounts[ord] >> 32);
        if (count != 0) {
            counts[1 + (int) ordMap.get(ord - 1)] += count;
        }/*www. j av a2s.  c  o m*/
    }
}

From source file:org.elasticsearch.index.fielddata.ordinals.GlobalOrdinalMapping.java

License:Apache License

GlobalOrdinalMapping(OrdinalMap ordinalMap, RandomAccessOrds[] bytesValues, int segmentIndex) {
    super();/*from  w  ww  .j av a 2s  .co m*/
    this.values = bytesValues[segmentIndex];
    this.bytesValues = bytesValues;
    this.ordinalMap = ordinalMap;
    this.mapping = ordinalMap.getGlobalOrds(segmentIndex);
}