Search in sources :

Example 26 with SortedNumericDoubleValues

use of org.elasticsearch.index.fielddata.SortedNumericDoubleValues in project elasticsearch by elastic.

the class MultiValueModeTests method testMultiValuedDoubles.

public void testMultiValuedDoubles() throws Exception {
    final int numDocs = scaledRandomIntBetween(1, 100);
    final double[][] array = new double[numDocs][];
    for (int i = 0; i < numDocs; ++i) {
        final double[] values = new double[randomInt(4)];
        for (int j = 0; j < values.length; ++j) {
            values[j] = randomDouble();
        }
        Arrays.sort(values);
        array[i] = values;
    }
    final SortedNumericDoubleValues multiValues = new SortedNumericDoubleValues() {

        int doc;

        @Override
        public double valueAt(int index) {
            return array[doc][index];
        }

        @Override
        public void setDocument(int doc) {
            this.doc = doc;
        }

        @Override
        public int count() {
            return array[doc].length;
        }
    };
    verify(multiValues, numDocs);
    final FixedBitSet rootDocs = randomRootDocs(numDocs);
    final FixedBitSet innerDocs = randomInnerDocs(rootDocs);
    verify(multiValues, numDocs, rootDocs, innerDocs);
}
Also used : FixedBitSet(org.apache.lucene.util.FixedBitSet) SortedNumericDoubleValues(org.elasticsearch.index.fielddata.SortedNumericDoubleValues)

Example 27 with SortedNumericDoubleValues

use of org.elasticsearch.index.fielddata.SortedNumericDoubleValues in project elasticsearch by elastic.

the class MultiValueModeTests method testSingleValuedDoubles.

public void testSingleValuedDoubles() throws Exception {
    final int numDocs = scaledRandomIntBetween(1, 100);
    final double[] array = new double[numDocs];
    final FixedBitSet docsWithValue = randomBoolean() ? null : new FixedBitSet(numDocs);
    for (int i = 0; i < array.length; ++i) {
        if (randomBoolean()) {
            array[i] = randomDouble();
            if (docsWithValue != null) {
                docsWithValue.set(i);
            }
        } else if (docsWithValue != null && randomBoolean()) {
            docsWithValue.set(i);
        }
    }
    final NumericDoubleValues singleValues = new NumericDoubleValues() {

        @Override
        public double get(int docID) {
            return array[docID];
        }
    };
    final SortedNumericDoubleValues multiValues = FieldData.singleton(singleValues, docsWithValue);
    verify(multiValues, numDocs);
    final FixedBitSet rootDocs = randomRootDocs(numDocs);
    final FixedBitSet innerDocs = randomInnerDocs(rootDocs);
    verify(multiValues, numDocs, rootDocs, innerDocs);
}
Also used : FixedBitSet(org.apache.lucene.util.FixedBitSet) NumericDoubleValues(org.elasticsearch.index.fielddata.NumericDoubleValues) SortedNumericDoubleValues(org.elasticsearch.index.fielddata.SortedNumericDoubleValues) SortedNumericDoubleValues(org.elasticsearch.index.fielddata.SortedNumericDoubleValues)

Aggregations

SortedNumericDoubleValues (org.elasticsearch.index.fielddata.SortedNumericDoubleValues)27 NumericDoubleValues (org.elasticsearch.index.fielddata.NumericDoubleValues)11 LeafBucketCollectorBase (org.elasticsearch.search.aggregations.LeafBucketCollectorBase)10 BigArrays (org.elasticsearch.common.util.BigArrays)8 LeafReaderContext (org.apache.lucene.index.LeafReaderContext)4 Document (org.apache.lucene.document.Document)3 DirectoryReader (org.apache.lucene.index.DirectoryReader)3 IndexWriter (org.apache.lucene.index.IndexWriter)3 IndexWriterConfig (org.apache.lucene.index.IndexWriterConfig)3 DocIdSetIterator (org.apache.lucene.search.DocIdSetIterator)3 Directory (org.apache.lucene.store.Directory)3 BitSet (org.apache.lucene.util.BitSet)3 FixedBitSet (org.apache.lucene.util.FixedBitSet)3 AtomicNumericFieldData (org.elasticsearch.index.fielddata.AtomicNumericFieldData)3 IndexableField (org.apache.lucene.index.IndexableField)2 LeafReader (org.apache.lucene.index.LeafReader)2 DoubleDocValues (org.apache.lucene.queries.function.docvalues.DoubleDocValues)2 Scorer (org.apache.lucene.search.Scorer)2 SortField (org.apache.lucene.search.SortField)2 GeoPoint (org.elasticsearch.common.geo.GeoPoint)2