Search in sources :

Example 1 with MultiSortedDocValues

use of org.apache.lucene.index.MultiDocValues.MultiSortedDocValues in project lucene-solr by apache.

the class SlowCompositeReaderWrapper method getSortedDocValues.

@Override
public SortedDocValues getSortedDocValues(String field) throws IOException {
    ensureOpen();
    OrdinalMap map = null;
    synchronized (cachedOrdMaps) {
        map = cachedOrdMaps.get(field);
        if (map == null) {
            // uncached, or not a multi dv
            SortedDocValues dv = MultiDocValues.getSortedValues(in, field);
            if (dv instanceof MultiSortedDocValues) {
                map = ((MultiSortedDocValues) dv).mapping;
                IndexReader.CacheHelper cacheHelper = getReaderCacheHelper();
                if (cacheHelper != null && map.owner == cacheHelper.getKey()) {
                    cachedOrdMaps.put(field, map);
                }
            }
            return dv;
        }
    }
    int size = in.leaves().size();
    final SortedDocValues[] values = new SortedDocValues[size];
    final int[] starts = new int[size + 1];
    long totalCost = 0;
    for (int i = 0; i < size; i++) {
        LeafReaderContext context = in.leaves().get(i);
        final LeafReader reader = context.reader();
        final FieldInfo fieldInfo = reader.getFieldInfos().fieldInfo(field);
        if (fieldInfo != null && fieldInfo.getDocValuesType() != DocValuesType.SORTED) {
            return null;
        }
        SortedDocValues v = reader.getSortedDocValues(field);
        if (v == null) {
            v = DocValues.emptySorted();
        }
        totalCost += v.cost();
        values[i] = v;
        starts[i] = context.docBase;
    }
    starts[size] = maxDoc();
    return new MultiSortedDocValues(values, starts, map, totalCost);
}
Also used : MultiSortedDocValues(org.apache.lucene.index.MultiDocValues.MultiSortedDocValues) OrdinalMap(org.apache.lucene.index.MultiDocValues.OrdinalMap) MultiSortedDocValues(org.apache.lucene.index.MultiDocValues.MultiSortedDocValues)

Aggregations

MultiSortedDocValues (org.apache.lucene.index.MultiDocValues.MultiSortedDocValues)1 OrdinalMap (org.apache.lucene.index.MultiDocValues.OrdinalMap)1