Java 类org.apache.lucene.index.RandomAccessOrds 实例源码

项目:elasticsearch_my    文件:IndexIndexFieldData.java   
@Override
public RandomAccessOrds getOrdinalsValues() {
    final BytesRef term = new BytesRef(index);
    final SortedDocValues sortedValues = new SortedDocValues() {

        @Override
        public BytesRef lookupOrd(int ord) {
            return term;
        }

        @Override
        public int getValueCount() {
            return 1;
        }

        @Override
        public int getOrd(int docID) {
            return 0;
        }
    };
    return (RandomAccessOrds) DocValues.singleton(sortedValues);
}
项目:elasticsearch_my    文件:AbstractAtomicOrdinalsFieldData.java   
public static AtomicOrdinalsFieldData empty() {
    return new AbstractAtomicOrdinalsFieldData(DEFAULT_SCRIPT_FUNCTION) {

        @Override
        public long ramBytesUsed() {
            return 0;
        }

        @Override
        public Collection<Accountable> getChildResources() {
            return Collections.emptyList();
        }

        @Override
        public void close() {
        }

        @Override
        public RandomAccessOrds getOrdinalsValues() {
            return DocValues.emptySortedSet();
        }
    };
}
项目:elasticsearch_my    文件:MultiValueModeTests.java   
private void verify(RandomAccessOrds values, int maxDoc) {
    for (MultiValueMode mode : new MultiValueMode[] {MultiValueMode.MIN, MultiValueMode.MAX}) {
        final SortedDocValues selected = mode.select(values);
        for (int i = 0; i < maxDoc; ++i) {
            final long actual = selected.getOrd(i);
            int expected = -1;
            values.setDocument(i);
            for (int j = 0; j < values.cardinality(); ++j) {
                if (expected == -1) {
                    expected = (int) values.ordAt(j);
                } else {
                    if (mode == MultiValueMode.MIN) {
                        expected = Math.min(expected, (int)values.ordAt(j));
                    } else if (mode == MultiValueMode.MAX) {
                        expected = Math.max(expected, (int)values.ordAt(j));
                    }
                }
            }

            assertEquals(mode.toString() + " docId=" + i, expected, actual);
        }
    }
}
项目:elasticsearch_my    文件:MultiOrdinalsTests.java   
private void assertEquals(RandomAccessOrds docs, long[][] ordinalPlan) {
    long maxOrd = 0;
    for (int doc = 0; doc < ordinalPlan.length; ++doc) {
        if (ordinalPlan[doc].length > 0) {
            maxOrd = Math.max(maxOrd, 1 + ordinalPlan[doc][ordinalPlan[doc].length - 1]);
        }
    }
    assertThat(docs.getValueCount(), equalTo(maxOrd));
    assertThat(FieldData.isMultiValued(docs), equalTo(true));
    for (int doc = 0; doc < ordinalPlan.length; ++doc) {
        long[] ords = ordinalPlan[doc];
        docs.setDocument(doc);
        assertThat(docs.cardinality(), equalTo(ords.length));
        for (int i = 0; i < ords.length; ++i) {
            assertThat(docs.ordAt(i), equalTo(ords[i]));
        }
    }
}
项目:elasticsearch_my    文件:SingleOrdinalsTests.java   
public void testSvValues() throws IOException {
    int numDocs = 1000000;
    int numOrdinals = numDocs / 4;
    Map<Integer, Long> controlDocToOrdinal = new HashMap<>();
    OrdinalsBuilder builder = new OrdinalsBuilder(numDocs);
    long ordinal = builder.currentOrdinal();
    for (int doc = 0; doc < numDocs; doc++) {
        if (doc % numOrdinals == 0) {
            ordinal = builder.nextOrdinal();
        }
        controlDocToOrdinal.put(doc, ordinal);
        builder.addDoc(doc);
    }

    Ordinals ords = builder.build();
    assertThat(ords, instanceOf(SinglePackedOrdinals.class));
    RandomAccessOrds docs = ords.ordinals();
    final SortedDocValues singleOrds = DocValues.unwrapSingleton(docs);
    assertNotNull(singleOrds);

    for (Map.Entry<Integer, Long> entry : controlDocToOrdinal.entrySet()) {
        assertThat(entry.getValue(), equalTo((long) singleOrds.getOrd(entry.getKey())));
    }
}
项目:Elasticsearch    文件:AbstractAtomicOrdinalsFieldData.java   
public static AtomicOrdinalsFieldData empty() {
    return new AbstractAtomicOrdinalsFieldData() {

        @Override
        public long ramBytesUsed() {
            return 0;
        }

        @Override
        public Collection<Accountable> getChildResources() {
            return Collections.emptyList();
        }

        @Override
        public void close() {
        }

        @Override
        public RandomAccessOrds getOrdinalsValues() {
            return DocValues.emptySortedSet();
        }
    };
}
项目:elasticsearch_my    文件:CardinalityAggregator.java   
OrdinalsCollector(HyperLogLogPlusPlus counts, RandomAccessOrds values, BigArrays bigArrays) {
    if (values.getValueCount() > Integer.MAX_VALUE) {
        throw new IllegalArgumentException();
    }
    maxOrd = (int) values.getValueCount();
    this.bigArrays = bigArrays;
    this.counts = counts;
    this.values = values;
    visitedOrds = bigArrays.newObjectArray(1);
}
项目:elasticsearch_my    文件:ValuesSource.java   
@Override
public Bits docsWithValue(LeafReaderContext context) {
    final RandomAccessOrds ordinals = ordinalsValues(context);
    if (DocValues.unwrapSingleton(ordinals) != null) {
        return DocValues.docsWithValue(DocValues.unwrapSingleton(ordinals), context.reader().maxDoc());
    } else {
        return DocValues.docsWithValue(ordinals, context.reader().maxDoc());
    }
}
项目:elasticsearch_my    文件:ValuesSource.java   
public long globalMaxOrd(IndexSearcher indexSearcher) {
    IndexReader indexReader = indexSearcher.getIndexReader();
    if (indexReader.leaves().isEmpty()) {
        return 0;
    } else {
        LeafReaderContext atomicReaderContext = indexReader.leaves().get(0);
        RandomAccessOrds values = globalOrdinalsValues(atomicReaderContext);
        return values.getValueCount();
    }
}
项目:elasticsearch_my    文件:GlobalOrdinalsStringTermsAggregator.java   
protected LeafBucketCollector newCollector(final RandomAccessOrds ords, final LeafBucketCollector sub) {
    grow(ords.getValueCount());
    final SortedDocValues singleValues = DocValues.unwrapSingleton(ords);
    if (singleValues != null) {
        return new LeafBucketCollectorBase(sub, ords) {
            @Override
            public void collect(int doc, long bucket) throws IOException {
                assert bucket == 0;
                final int ord = singleValues.getOrd(doc);
                if (ord >= 0) {
                    collectExistingBucket(sub, doc, ord);
                }
            }
        };
    } else {
        return new LeafBucketCollectorBase(sub, ords) {
            @Override
            public void collect(int doc, long bucket) throws IOException {
                assert bucket == 0;
                ords.setDocument(doc);
                final int numOrds = ords.cardinality();
                for (int i = 0; i < numOrds; i++) {
                    final long globalOrd = ords.ordAt(i);
                    collectExistingBucket(sub, doc, globalOrd);
                }
            }
        };
    }
}
项目:elasticsearch_my    文件:GlobalOrdinalsStringTermsAggregator.java   
@Override
protected LeafBucketCollector newCollector(final RandomAccessOrds ords, LeafBucketCollector sub) {
    segmentDocCounts = context.bigArrays().grow(segmentDocCounts, 1 + ords.getValueCount());
    assert sub == LeafBucketCollector.NO_OP_COLLECTOR;
    final SortedDocValues singleValues = DocValues.unwrapSingleton(ords);
    if (singleValues != null) {
        return new LeafBucketCollectorBase(sub, ords) {
            @Override
            public void collect(int doc, long bucket) throws IOException {
                assert bucket == 0;
                final int ord = singleValues.getOrd(doc);
                segmentDocCounts.increment(ord + 1, 1);
            }
        };
    } else {
        return new LeafBucketCollectorBase(sub, ords) {
            @Override
            public void collect(int doc, long bucket) throws IOException {
                assert bucket == 0;
                ords.setDocument(doc);
                final int numOrds = ords.cardinality();
                for (int i = 0; i < numOrds; i++) {
                    final long segmentOrd = ords.ordAt(i);
                    segmentDocCounts.increment(segmentOrd + 1, 1);
                }
            }
        };
    }
}
项目:elasticsearch_my    文件:InternalGlobalOrdinalsIndexFieldData.java   
InternalGlobalOrdinalsIndexFieldData(IndexSettings indexSettings, String fieldName, AtomicOrdinalsFieldData[] segmentAfd,
        OrdinalMap ordinalMap, long memorySizeInBytes, Function<RandomAccessOrds, ScriptDocValues<?>> scriptFunction) {
    super(indexSettings, fieldName, memorySizeInBytes);
    this.atomicReaders = new Atomic[segmentAfd.length];
    for (int i = 0; i < segmentAfd.length; i++) {
        atomicReaders[i] = new Atomic(segmentAfd[i], ordinalMap, i);
    }
    this.scriptFunction = scriptFunction;
}
项目:elasticsearch_my    文件:InternalGlobalOrdinalsIndexFieldData.java   
@Override
public RandomAccessOrds getOrdinalsValues() {
    final RandomAccessOrds values = afd.getOrdinalsValues();
    if (values.getValueCount() == ordinalMap.getValueCount()) {
        // segment ordinals match global ordinals
        return values;
    }
    final RandomAccessOrds[] bytesValues = new RandomAccessOrds[atomicReaders.length];
    for (int i = 0; i < bytesValues.length; i++) {
        bytesValues[i] = atomicReaders[i].afd.getOrdinalsValues();
    }
    return new GlobalOrdinalMapping(ordinalMap, bytesValues, segmentIndex);
}
项目:elasticsearch_my    文件:GlobalOrdinalMapping.java   
GlobalOrdinalMapping(OrdinalMap ordinalMap, RandomAccessOrds[] bytesValues, int segmentIndex) {
    super();
    this.values = bytesValues[segmentIndex];
    this.bytesValues = bytesValues;
    this.ordinalMap = ordinalMap;
    this.mapping = ordinalMap.getGlobalOrds(segmentIndex);
}
项目:elasticsearch_my    文件:MultiOrdinals.java   
@Override
public RandomAccessOrds ordinals(ValuesHolder values) {
    if (multiValued) {
        return new MultiDocs(this, values);
    } else {
        return (RandomAccessOrds) DocValues.singleton(new SingleDocs(this, values));
    }
}
项目:elasticsearch_my    文件:SortedSetDVBytesAtomicFieldData.java   
@Override
public RandomAccessOrds getOrdinalsValues() {
    try {
        return FieldData.maybeSlowRandomAccessOrds(DocValues.getSortedSet(reader, field));
    } catch (IOException e) {
        throw new IllegalStateException("cannot load docvalues", e);
    }
}
项目:elasticsearch_my    文件:SortedSetDVOrdinalsIndexFieldData.java   
public SortedSetDVOrdinalsIndexFieldData(IndexSettings indexSettings, IndexFieldDataCache cache, String fieldName,
        CircuitBreakerService breakerService, Function<RandomAccessOrds, ScriptDocValues<?>> scriptFunction) {
    super(indexSettings.getIndex(), fieldName);
    this.indexSettings = indexSettings;
    this.cache = cache;
    this.breakerService = breakerService;
    this.scriptFunction = scriptFunction;
}
项目:elasticsearch_my    文件:MultiValueModeTests.java   
public void testSingleValuedOrds() throws Exception  {
    final int numDocs = scaledRandomIntBetween(1, 100);
    final int[] array = new int[numDocs];
    for (int i = 0; i < array.length; ++i) {
        if (randomBoolean()) {
            array[i] = randomInt(1000);
        } else {
            array[i] = -1;
        }
    }
    final SortedDocValues singleValues = new SortedDocValues() {
        @Override
        public int getOrd(int docID) {
            return array[docID];
        }

        @Override
        public BytesRef lookupOrd(int ord) {
            throw new UnsupportedOperationException();
        }

        @Override
        public int getValueCount() {
            return 1 << 20;
        }
    };
    final RandomAccessOrds multiValues = (RandomAccessOrds) DocValues.singleton(singleValues);
    verify(multiValues, numDocs);
    final FixedBitSet rootDocs = randomRootDocs(numDocs);
    final FixedBitSet innerDocs = randomInnerDocs(rootDocs);
    verify(multiValues, numDocs, rootDocs, innerDocs);
}
项目:elasticsearch_my    文件:MultiValueModeTests.java   
private void verify(RandomAccessOrds values, int maxDoc, FixedBitSet rootDocs, FixedBitSet innerDocs) throws IOException {
    for (MultiValueMode mode : new MultiValueMode[] {MultiValueMode.MIN, MultiValueMode.MAX}) {
        final SortedDocValues selected = mode.select(values, rootDocs, new BitSetIterator(innerDocs, 0L));
        int prevRoot = -1;
        for (int root = rootDocs.nextSetBit(0); root != -1; root = root + 1 < maxDoc ? rootDocs.nextSetBit(root + 1) : -1) {
            final int actual = selected.getOrd(root);
            int expected = -1;
            for (int child = innerDocs.nextSetBit(prevRoot + 1); child != -1 && child < root; child = innerDocs.nextSetBit(child + 1)) {
                values.setDocument(child);
                for (int j = 0; j < values.cardinality(); ++j) {
                    if (expected == -1) {
                        expected = (int) values.ordAt(j);
                    } else {
                        if (mode == MultiValueMode.MIN) {
                            expected = Math.min(expected, (int)values.ordAt(j));
                        } else if (mode == MultiValueMode.MAX) {
                            expected = Math.max(expected, (int)values.ordAt(j));
                        }
                    }
                }
            }

            assertEquals(mode.toString() + " docId=" + root, expected, actual);

            prevRoot = root;
        }
    }
}
项目:elasticsearch_my    文件:AbstractStringFieldDataTestCase.java   
private void assertIteratorConsistentWithRandomAccess(RandomAccessOrds ords, int maxDoc) {
    for (int doc = 0; doc < maxDoc; ++doc) {
        ords.setDocument(doc);
        final int cardinality = ords.cardinality();
        for (int i = 0; i < cardinality; ++i) {
            assertEquals(ords.nextOrd(), ords.ordAt(i));
        }
        for (int i = 0; i < 3; ++i) {
            assertEquals(ords.nextOrd(), -1);
        }
    }
}
项目:elasticsearch_my    文件:MultiOrdinalsTests.java   
public void testOrdinals() throws Exception {
    int maxDoc = 7;
    long maxOrds = 32;
    OrdinalsBuilder builder = new OrdinalsBuilder(maxDoc);
    builder.nextOrdinal(); // 0
    builder.addDoc(1).addDoc(4).addDoc(5).addDoc(6);
    builder.nextOrdinal(); // 1
    builder.addDoc(0).addDoc(5).addDoc(6);
    builder.nextOrdinal(); // 3
    builder.addDoc(2).addDoc(4).addDoc(5).addDoc(6);
    builder.nextOrdinal(); // 3
    builder.addDoc(0).addDoc(4).addDoc(5).addDoc(6);
    builder.nextOrdinal(); // 4
    builder.addDoc(4).addDoc(5).addDoc(6);
    builder.nextOrdinal(); // 5
    builder.addDoc(4).addDoc(5).addDoc(6);
    while (builder.getValueCount() < maxOrds) {
        builder.nextOrdinal();
        builder.addDoc(5).addDoc(6);
    }

    long[][] ordinalPlan = new long[][]{
            {1, 3},
            {0},
            {2},
            {},
            {0, 2, 3, 4, 5},
            {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31},
            {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}
    };

    Ordinals ordinals = creationMultiOrdinals(builder);
    RandomAccessOrds docs = ordinals.ordinals();
    assertEquals(docs, ordinalPlan);
}
项目:elasticsearch_my    文件:MultiOrdinalsTests.java   
protected static void assertIter(RandomAccessOrds docs, int docId, long... expectedOrdinals) {
    docs.setDocument(docId);
    assertThat(docs.cardinality(), equalTo(expectedOrdinals.length));
    for (long expectedOrdinal : expectedOrdinals) {
        assertThat(docs.nextOrd(), equalTo(expectedOrdinal));
    }
}
项目:Elasticsearch    文件:CardinalityAggregator.java   
OrdinalsCollector(HyperLogLogPlusPlus counts, RandomAccessOrds values, BigArrays bigArrays) {
    Preconditions.checkArgument(values.getValueCount() <= Integer.MAX_VALUE);
    maxOrd = (int) values.getValueCount();
    this.bigArrays = bigArrays;
    this.counts = counts;
    this.values = values;
    visitedOrds = bigArrays.newObjectArray(1);
}
项目:Elasticsearch    文件:GlobalOrdinalsStringTermsAggregator.java   
protected LeafBucketCollector newCollector(final RandomAccessOrds ords, final LeafBucketCollector sub) {
    grow(ords.getValueCount());
    final SortedDocValues singleValues = DocValues.unwrapSingleton(ords);
    if (singleValues != null) {
        return new LeafBucketCollectorBase(sub, ords) {
            @Override
            public void collect(int doc, long bucket) throws IOException {
                assert bucket == 0;
                final int ord = singleValues.getOrd(doc);
                if (ord >= 0) {
                    collectExistingBucket(sub, doc, ord);
                }
            }
        };
    } else {
        return new LeafBucketCollectorBase(sub, ords) {
            @Override
            public void collect(int doc, long bucket) throws IOException {
                assert bucket == 0;
                ords.setDocument(doc);
                final int numOrds = ords.cardinality();
                for (int i = 0; i < numOrds; i++) {
                    final long globalOrd = ords.ordAt(i);
                    collectExistingBucket(sub, doc, globalOrd);
                }
            }
        };
    }
}
项目:Elasticsearch    文件:GlobalOrdinalsStringTermsAggregator.java   
@Override
protected LeafBucketCollector newCollector(final RandomAccessOrds ords, LeafBucketCollector sub) {
    segmentDocCounts = context.bigArrays().grow(segmentDocCounts, 1 + ords.getValueCount());
    assert sub == LeafBucketCollector.NO_OP_COLLECTOR;
    final SortedDocValues singleValues = DocValues.unwrapSingleton(ords);
    if (singleValues != null) {
        return new LeafBucketCollectorBase(sub, ords) {
            @Override
            public void collect(int doc, long bucket) throws IOException {
                assert bucket == 0;
                final int ord = singleValues.getOrd(doc);
                segmentDocCounts.increment(ord + 1, 1);
            }
        };
    } else {
        return new LeafBucketCollectorBase(sub, ords) {
            @Override
            public void collect(int doc, long bucket) throws IOException {
                assert bucket == 0;
                ords.setDocument(doc);
                final int numOrds = ords.cardinality();
                for (int i = 0; i < numOrds; i++) {
                    final long segmentOrd = ords.ordAt(i);
                    segmentDocCounts.increment(segmentOrd + 1, 1);
                }
            }
        };
    }
}
项目:Elasticsearch    文件:InternalGlobalOrdinalsIndexFieldData.java   
@Override
public RandomAccessOrds getOrdinalsValues() {
    final RandomAccessOrds values = afd.getOrdinalsValues();
    if (values.getValueCount() == ordinalMap.getValueCount()) {
        // segment ordinals match global ordinals
        return values;
    }
    final RandomAccessOrds[] bytesValues = new RandomAccessOrds[atomicReaders.length];
    for (int i = 0; i < bytesValues.length; i++) {
        bytesValues[i] = atomicReaders[i].afd.getOrdinalsValues();
    }
    return new GlobalOrdinalMapping(ordinalMap, bytesValues, segmentIndex);
}
项目:Elasticsearch    文件:GlobalOrdinalMapping.java   
GlobalOrdinalMapping(OrdinalMap ordinalMap, RandomAccessOrds[] bytesValues, int segmentIndex) {
    super();
    this.values = bytesValues[segmentIndex];
    this.bytesValues = bytesValues;
    this.ordinalMap = ordinalMap;
    this.mapping = ordinalMap.getGlobalOrds(segmentIndex);
}
项目:Elasticsearch    文件:MultiOrdinals.java   
@Override
public RandomAccessOrds ordinals(ValuesHolder values) {
    if (multiValued) {
        return new MultiDocs(this, values);
    } else {
        return (RandomAccessOrds) DocValues.singleton(new SingleDocs(this, values));
    }
}
项目:Elasticsearch    文件:GeoPointArrayAtomicFieldData.java   
@Override
public MultiGeoPointValues getGeoPointValues() {
    final RandomAccessOrds ords = ordinals.ordinals();
    final SortedDocValues singleOrds = DocValues.unwrapSingleton(ords);
    final GeoPoint point = new GeoPoint(Double.NaN, Double.NaN);
    if (singleOrds != null) {
        final GeoPointValues values = new GeoPointValues() {
            @Override
            public GeoPoint get(int docID) {
                final int ord = singleOrds.getOrd(docID);
                if (ord >= 0) {
                    return point.resetFromIndexHash(indexedPoints.get(ord));
                }
                return point.reset(Double.NaN, Double.NaN);
            }
        };
        return FieldData.singleton(values, DocValues.docsWithValue(singleOrds, maxDoc));
    }
    return new MultiGeoPointValues() {
        @Override
        public GeoPoint valueAt(int index) {
            return point.resetFromIndexHash(indexedPoints.get(ords.ordAt(index)));
        }

        @Override
        public void setDocument(int docId) {
            ords.setDocument(docId);
        }

        @Override
        public int count() {
            return ords.cardinality();
        }
    };
}
项目:Elasticsearch    文件:SortedSetDVBytesAtomicFieldData.java   
@Override
public RandomAccessOrds getOrdinalsValues() {
    try {
        return FieldData.maybeSlowRandomAccessOrds(DocValues.getSortedSet(reader, field));
    } catch (IOException e) {
        throw new IllegalStateException("cannot load docvalues", e);
    }
}
项目:search    文件:SortedSetSortField.java   
@Override
public FieldComparator<?> getComparator(int numHits, int sortPos) throws IOException {
  return new FieldComparator.TermOrdValComparator(numHits, getField(), missingValue == STRING_LAST) {
    @Override
    protected SortedDocValues getSortedDocValues(AtomicReaderContext context, String field) throws IOException {
      SortedSetDocValues sortedSet = FieldCache.DEFAULT.getDocTermOrds(context.reader(), field);

      if (sortedSet.getValueCount() >= Integer.MAX_VALUE) {
        throw new UnsupportedOperationException("fields containing more than " + (Integer.MAX_VALUE-1) + " unique terms are unsupported");
      }

      SortedDocValues singleton = DocValues.unwrapSingleton(sortedSet);
      if (singleton != null) {
        // it's actually single-valued in practice, but indexed as multi-valued,
        // so just sort on the underlying single-valued dv directly.
        // regardless of selector type, this optimization is safe!
        return singleton;
      } else if (selector == Selector.MIN) {
        return new MinValue(sortedSet);
      } else {
        if (sortedSet instanceof RandomAccessOrds == false) {
          throw new UnsupportedOperationException("codec does not support random access ordinals, cannot use selector: " + selector);
        }
        RandomAccessOrds randomOrds = (RandomAccessOrds) sortedSet;
        switch(selector) {
          case MAX: return new MaxValue(randomOrds);
          case MIDDLE_MIN: return new MiddleMinValue(randomOrds);
          case MIDDLE_MAX: return new MiddleMaxValue(randomOrds);
          case MIN: 
          default: 
            throw new AssertionError();
        }
      }
    }
  };
}
项目:read-open-source-code    文件:SortedSetSortField.java   
@Override
public FieldComparator<?> getComparator(int numHits, int sortPos) throws IOException {
  return new FieldComparator.TermOrdValComparator(numHits, getField(), missingValue == STRING_LAST) {
    @Override
    protected SortedDocValues getSortedDocValues(AtomicReaderContext context, String field) throws IOException {
      SortedSetDocValues sortedSet = FieldCache.DEFAULT.getDocTermOrds(context.reader(), field);

      if (sortedSet.getValueCount() >= Integer.MAX_VALUE) {
        throw new UnsupportedOperationException("fields containing more than " + (Integer.MAX_VALUE-1) + " unique terms are unsupported");
      }

      SortedDocValues singleton = DocValues.unwrapSingleton(sortedSet);
      if (singleton != null) {
        // it's actually single-valued in practice, but indexed as multi-valued,
        // so just sort on the underlying single-valued dv directly.
        // regardless of selector type, this optimization is safe!
        return singleton;
      } else if (selector == Selector.MIN) {
        return new MinValue(sortedSet);
      } else {
        if (sortedSet instanceof RandomAccessOrds == false) {
          throw new UnsupportedOperationException("codec does not support random access ordinals, cannot use selector: " + selector);
        }
        RandomAccessOrds randomOrds = (RandomAccessOrds) sortedSet;
        switch(selector) {
          case MAX: return new MaxValue(randomOrds);
          case MIDDLE_MIN: return new MiddleMinValue(randomOrds);
          case MIDDLE_MAX: return new MiddleMaxValue(randomOrds);
          case MIN: 
          default: 
            throw new AssertionError();
        }
      }
    }
  };
}
项目:elasticsearch_my    文件:ValuesSource.java   
@Override
public RandomAccessOrds ordinalsValues(LeafReaderContext context) {
    return DocValues.emptySortedSet();
}
项目:elasticsearch_my    文件:ValuesSource.java   
@Override
public RandomAccessOrds globalOrdinalsValues(LeafReaderContext context) {
    return DocValues.emptySortedSet();
}
项目:elasticsearch_my    文件:ValuesSource.java   
@Override
public RandomAccessOrds ordinalsValues(LeafReaderContext context) {
    final AtomicOrdinalsFieldData atomicFieldData = indexFieldData.load(context);
    return atomicFieldData.getOrdinalsValues();
}
项目:elasticsearch_my    文件:ValuesSource.java   
@Override
public RandomAccessOrds globalOrdinalsValues(LeafReaderContext context) {
    final IndexOrdinalsFieldData global = indexFieldData.loadGlobal((DirectoryReader)context.parent.reader());
    final AtomicOrdinalsFieldData atomicFieldData = global.load(context);
    return atomicFieldData.getOrdinalsValues();
}
项目:elasticsearch_my    文件:GlobalOrdinalsStringTermsAggregator.java   
private FilteredOrdinals(RandomAccessOrds inner, LongBitSet accepted) {
    this.inner = inner;
    this.accepted = accepted;
}
项目:elasticsearch_my    文件:Ordinals.java   
public final RandomAccessOrds ordinals() {
    return ordinals(NO_VALUES);
}
项目:elasticsearch_my    文件:SinglePackedOrdinals.java   
@Override
public RandomAccessOrds ordinals(ValuesHolder values) {
    return (RandomAccessOrds) DocValues.singleton(new Docs(this, values));
}
项目:elasticsearch_my    文件:PagedBytesAtomicFieldData.java   
@Override
public RandomAccessOrds getOrdinalsValues() {
    return ordinals.ordinals(new ValuesHolder(bytes, termOrdToBytesOffset));
}