Search in sources :

Example 91 with FixedBitSet

use of org.apache.lucene.util.FixedBitSet 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 92 with FixedBitSet

use of org.apache.lucene.util.FixedBitSet in project elasticsearch by elastic.

the class MultiValueModeTests method testSingleValuedLongs.

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

        @Override
        public long get(int docID) {
            return array[docID];
        }
    };
    final SortedNumericDocValues multiValues = DocValues.singleton(singleValues, docsWithValue);
    verify(multiValues, numDocs);
    final FixedBitSet rootDocs = randomRootDocs(numDocs);
    final FixedBitSet innerDocs = randomInnerDocs(rootDocs);
    verify(multiValues, numDocs, rootDocs, innerDocs);
}
Also used : NumericDocValues(org.apache.lucene.index.NumericDocValues) SortedNumericDocValues(org.apache.lucene.index.SortedNumericDocValues) SortedNumericDocValues(org.apache.lucene.index.SortedNumericDocValues) FixedBitSet(org.apache.lucene.util.FixedBitSet)

Example 93 with FixedBitSet

use of org.apache.lucene.util.FixedBitSet in project elasticsearch by elastic.

the class MultiValueModeTests method testSingleValuedOrds.

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);
}
Also used : RandomAccessOrds(org.apache.lucene.index.RandomAccessOrds) FixedBitSet(org.apache.lucene.util.FixedBitSet) SortedDocValues(org.apache.lucene.index.SortedDocValues)

Example 94 with FixedBitSet

use of org.apache.lucene.util.FixedBitSet 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)

Example 95 with FixedBitSet

use of org.apache.lucene.util.FixedBitSet in project elasticsearch by elastic.

the class MultiValueModeTests method testMultiValuedStrings.

public void testMultiValuedStrings() throws Exception {
    final int numDocs = scaledRandomIntBetween(1, 100);
    final BytesRef[][] array = new BytesRef[numDocs][];
    for (int i = 0; i < numDocs; ++i) {
        final BytesRef[] values = new BytesRef[randomInt(4)];
        for (int j = 0; j < values.length; ++j) {
            values[j] = new BytesRef(RandomStrings.randomAsciiOfLength(random(), 8));
        }
        Arrays.sort(values);
        array[i] = values;
    }
    final SortedBinaryDocValues multiValues = new SortedBinaryDocValues() {

        int doc;

        @Override
        public BytesRef valueAt(int index) {
            return BytesRef.deepCopyOf(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) BytesRef(org.apache.lucene.util.BytesRef) SortedBinaryDocValues(org.elasticsearch.index.fielddata.SortedBinaryDocValues)

Aggregations

FixedBitSet (org.apache.lucene.util.FixedBitSet)162 Term (org.apache.lucene.index.Term)27 LeafReaderContext (org.apache.lucene.index.LeafReaderContext)26 Directory (org.apache.lucene.store.Directory)25 BytesRef (org.apache.lucene.util.BytesRef)22 IOException (java.io.IOException)19 Document (org.apache.lucene.document.Document)17 ArrayList (java.util.ArrayList)15 Query (org.apache.lucene.search.Query)15 NumericDocValues (org.apache.lucene.index.NumericDocValues)14 BitDocIdSet (org.apache.lucene.util.BitDocIdSet)13 Bits (org.apache.lucene.util.Bits)13 LeafReader (org.apache.lucene.index.LeafReader)12 IndexSearcher (org.apache.lucene.search.IndexSearcher)12 TermQuery (org.apache.lucene.search.TermQuery)12 IndexReader (org.apache.lucene.index.IndexReader)11 HashSet (java.util.HashSet)10 NumericDocValuesField (org.apache.lucene.document.NumericDocValuesField)10 DocIterator (org.apache.solr.search.DocIterator)10 MockAnalyzer (org.apache.lucene.analysis.MockAnalyzer)9