Search in sources :

Example 6 with LongSupplier

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

the class BaseNormsFormatTestCase method testFullLongRange.

public void testFullLongRange() 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() {
                int thingToDo = r.nextInt(3);
                switch(thingToDo) {
                    case 0:
                        return Long.MIN_VALUE;
                    case 1:
                        return Long.MAX_VALUE;
                    default:
                        return TestUtil.nextLong(r, Long.MIN_VALUE, Long.MAX_VALUE);
                }
            }
        });
    }
}
Also used : Random(java.util.Random) LongSupplier(java.util.function.LongSupplier)

Example 7 with LongSupplier

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

the class BaseNormsFormatTestCase method testMostZeros.

public void testMostZeros() 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.nextInt(100) == 0 ? TestUtil.nextLong(r, Byte.MIN_VALUE, Byte.MAX_VALUE) : 0;
            }
        });
    }
}
Also used : Random(java.util.Random) LongSupplier(java.util.function.LongSupplier)

Example 8 with LongSupplier

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

the class BaseNormsFormatTestCase method testFewSparseValues.

public void testFewSparseValues() 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() ? 20 : 3;
            }
        });
    }
}
Also used : Random(java.util.Random) LongSupplier(java.util.function.LongSupplier)

Example 9 with LongSupplier

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

the class BaseNormsFormatTestCase method testSparseByteRange.

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

Example 10 with LongSupplier

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

the class BaseNormsFormatTestCase method testFewLargeValues.

public void testFewLargeValues() 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() ? 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