Search in sources :

Example 11 with LongSupplier

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

the class BaseNormsFormatTestCase method testShortRange.

public void testShortRange() 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, Short.MIN_VALUE, Short.MAX_VALUE);
            }
        });
    }
}
Also used : Random(java.util.Random) LongSupplier(java.util.function.LongSupplier)

Example 12 with LongSupplier

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

the class BaseNormsFormatTestCase method testSparseOutliers.

public void testSparseOutliers() throws Exception {
    assumeTrue("Requires sparse norms support", codecSupportsSparsity());
    int iterations = atLeast(1);
    final Random r = random();
    for (int i = 0; i < iterations; i++) {
        final long commonValue = TestUtil.nextLong(r, Byte.MIN_VALUE, Byte.MAX_VALUE);
        doTestNormsVersusDocValues(random().nextDouble(), new LongSupplier() {

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

Example 13 with LongSupplier

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

the class BaseNormsFormatTestCase method testOutliers.

public void testOutliers() throws Exception {
    int iterations = atLeast(1);
    final Random r = random();
    for (int i = 0; i < iterations; i++) {
        final long commonValue = TestUtil.nextLong(r, Byte.MIN_VALUE, Byte.MAX_VALUE);
        doTestNormsVersusDocValues(1, new LongSupplier() {

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

Example 14 with LongSupplier

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

the class BaseNormsFormatTestCase method testSparseNCommonBig.

/**
   * a more thorough n-common that tests all low bpv and sparse docs
   */
@Nightly
public void testSparseNCommonBig() throws Exception {
    assumeTrue("Requires sparse norms support", codecSupportsSparsity());
    final int iterations = atLeast(1);
    final Random r = random();
    for (int i = 0; i < iterations; ++i) {
        // 16 is 4 bpv, the max before we jump to 8bpv
        for (int n = 2; n < 16; ++n) {
            final int N = n;
            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(random().nextDouble(), 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 15 with LongSupplier

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

the class BaseNormsFormatTestCase method testFewSparseLargeValues.

public void testFewSparseLargeValues() 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 r.nextBoolean() ? 1000000L : -5000;
            }
        });
    }
}
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