Search in sources :

Example 1 with LongSupplier

use of java.util.function.LongSupplier in project neo4j by neo4j.

the class OnDiskLastTxIdGetterTest method lastTransactionIdIsBaseTxIdWhileNeoStoresAreStopped.

@Test
public void lastTransactionIdIsBaseTxIdWhileNeoStoresAreStopped() {
    final StoreFactory storeFactory = new StoreFactory(new File("store"), pageCacheRule.getPageCache(fs.get()), fs.get(), NullLogProvider.getInstance());
    final NeoStores neoStores = storeFactory.openAllNeoStores(true);
    neoStores.close();
    LongSupplier supplier = () -> neoStores.getMetaDataStore().getLastCommittedTransactionId();
    OnDiskLastTxIdGetter diskLastTxIdGetter = new OnDiskLastTxIdGetter(supplier);
    assertEquals(TransactionIdStore.BASE_TX_ID, diskLastTxIdGetter.getLastTxId());
}
Also used : OnDiskLastTxIdGetter(org.neo4j.kernel.ha.transaction.OnDiskLastTxIdGetter) NeoStores(org.neo4j.kernel.impl.store.NeoStores) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory) LongSupplier(java.util.function.LongSupplier) File(java.io.File) Test(org.junit.Test)

Example 2 with LongSupplier

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

the class BaseDocValuesFormatTestCase method testZeroOrMin.

public void testZeroOrMin() throws Exception {
    // try to make GCD compression fail if the format did not anticipate that
    // the GCD of 0 and MIN_VALUE is negative
    int numIterations = atLeast(1);
    for (int i = 0; i < numIterations; i++) {
        final LongSupplier longs = () -> {
            return random().nextBoolean() ? 0 : Long.MIN_VALUE;
        };
        doTestNumericsVsStoredFields(1, longs);
    }
}
Also used : LongSupplier(java.util.function.LongSupplier)

Example 3 with LongSupplier

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

the class BaseNormsFormatTestCase method testLongRange.

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

Example 4 with LongSupplier

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

the class BaseNormsFormatTestCase method testSparseNCommon.

public void testSparseNCommon() throws Exception {
    assumeTrue("Requires sparse norms support", codecSupportsSparsity());
    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(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 5 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)

Aggregations

LongSupplier (java.util.function.LongSupplier)56 Random (java.util.Random)21 Test (org.junit.Test)8 IOException (java.io.IOException)7 Path (java.nio.file.Path)7 ArrayList (java.util.ArrayList)7 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)7 AtomicLong (java.util.concurrent.atomic.AtomicLong)5 CircuitBreaker (org.elasticsearch.common.breaker.CircuitBreaker)5 BytesArray (org.elasticsearch.common.bytes.BytesArray)5 Tuple (io.crate.common.collections.Tuple)4 Streams (io.crate.common.io.Streams)4 TimeValue (io.crate.common.unit.TimeValue)4 List (java.util.List)4 Predicate (java.util.function.Predicate)4 Supplier (java.util.function.Supplier)4 StoredField (org.apache.lucene.document.StoredField)4 Version (org.elasticsearch.Version)4 NoopCircuitBreaker (org.elasticsearch.common.breaker.NoopCircuitBreaker)4 BytesReference (org.elasticsearch.common.bytes.BytesReference)4