Search in sources :

Example 16 with LongSupplier

use of java.util.function.LongSupplier in project lucene-solr by apache.

the class BaseNormsFormatTestCase method testSparseAllZeros.

public void testSparseAllZeros() throws Exception {
    assumeTrue("Requires sparse norms support", codecSupportsSparsity());
    int iterations = atLeast(1);
    for (int i = 0; i < iterations; i++) {
        doTestNormsVersusDocValues(random().nextDouble(), new LongSupplier() {

            @Override
            public long getAsLong() {
                return 0;
            }
        });
    }
}
Also used : LongSupplier(java.util.function.LongSupplier)

Example 17 with LongSupplier

use of java.util.function.LongSupplier in project lucene-solr by apache.

the class BaseNormsFormatTestCase method testNCommon.

public void testNCommon() throws Exception {
    final Random r = random();
    final int N = TestUtil.nextInt(r, 2, 15);
    final long[] commonValues = new long[N];
    for (int j = 0; j < N; ++j) {
        commonValues[j] = TestUtil.nextLong(r, Byte.MIN_VALUE, Byte.MAX_VALUE);
    }
    final int numOtherValues = TestUtil.nextInt(r, 2, 256 - N);
    final long[] otherValues = new long[numOtherValues];
    for (int j = 0; j < numOtherValues; ++j) {
        otherValues[j] = TestUtil.nextLong(r, Byte.MIN_VALUE, Byte.MAX_VALUE);
    }
    doTestNormsVersusDocValues(1, new LongSupplier() {

        @Override
        public long getAsLong() {
            return r.nextInt(100) == 0 ? otherValues[r.nextInt(numOtherValues - 1)] : commonValues[r.nextInt(N - 1)];
        }
    });
}
Also used : Random(java.util.Random) LongSupplier(java.util.function.LongSupplier)

Example 18 with LongSupplier

use of java.util.function.LongSupplier in project lucene-solr by apache.

the class BaseNormsFormatTestCase method testByteRange.

public void testByteRange() throws Exception {
    int iterations = atLeast(1);
    final Random r = random();
    for (int i = 0; i < iterations; i++) {
        doTestNormsVersusDocValues(1, new LongSupplier() {

            @Override
            public long getAsLong() {
                return TestUtil.nextLong(r, Byte.MIN_VALUE, Byte.MAX_VALUE);
            }
        });
    }
}
Also used : Random(java.util.Random) LongSupplier(java.util.function.LongSupplier)

Example 19 with LongSupplier

use of java.util.function.LongSupplier in project lucene-solr by apache.

the class BaseNormsFormatTestCase method testFewValues.

public void testFewValues() throws Exception {
    int iterations = atLeast(1);
    final Random r = random();
    for (int i = 0; i < iterations; i++) {
        doTestNormsVersusDocValues(1, new LongSupplier() {

            @Override
            public long getAsLong() {
                return r.nextBoolean() ? 20 : 3;
            }
        });
    }
}
Also used : Random(java.util.Random) LongSupplier(java.util.function.LongSupplier)

Example 20 with LongSupplier

use of java.util.function.LongSupplier in project lucene-solr by apache.

the class BaseNormsFormatTestCase method testSparseShortRange.

public void testSparseShortRange() throws Exception {
    assumeTrue("Requires sparse norms support", codecSupportsSparsity());
    int iterations = atLeast(1);
    final Random r = random();
    for (int i = 0; i < iterations; i++) {
        doTestNormsVersusDocValues(random().nextDouble(), new LongSupplier() {

            @Override
            public long getAsLong() {
                return TestUtil.nextLong(r, Short.MIN_VALUE, Short.MAX_VALUE);
            }
        });
    }
}
Also used : Random(java.util.Random) LongSupplier(java.util.function.LongSupplier)

Aggregations

LongSupplier (java.util.function.LongSupplier)31 Random (java.util.Random)21 StoredField (org.apache.lucene.document.StoredField)3 MockAnalyzer (org.apache.lucene.analysis.MockAnalyzer)2 Document (org.apache.lucene.document.Document)2 Field (org.apache.lucene.document.Field)2 NumericDocValuesField (org.apache.lucene.document.NumericDocValuesField)2 SortedNumericDocValuesField (org.apache.lucene.document.SortedNumericDocValuesField)2 DirectoryReader (org.apache.lucene.index.DirectoryReader)2 IndexWriter (org.apache.lucene.index.IndexWriter)2 IndexWriterConfig (org.apache.lucene.index.IndexWriterConfig)2 IndexableField (org.apache.lucene.index.IndexableField)2 LeafReader (org.apache.lucene.index.LeafReader)2 LeafReaderContext (org.apache.lucene.index.LeafReaderContext)2 RandomIndexWriter (org.apache.lucene.index.RandomIndexWriter)2 SortedNumericDocValues (org.apache.lucene.index.SortedNumericDocValues)2 Directory (org.apache.lucene.store.Directory)2 Test (org.junit.Test)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1