Search in sources :

Example 1 with NO_MONITOR

use of org.neo4j.internal.batchimport.cache.NumberArrayFactories.NO_MONITOR in project neo4j by neo4j.

the class NumberArrayTest method arrays.

public static Collection<NumberArrayTestData> arrays() {
    PageCache pageCache = fixture.pageCache;
    Path dir = fixture.directory;
    NullLog log = NullLog.getInstance();
    Collection<NumberArrayTestData> list = new ArrayList<>();
    Map<String, NumberArrayFactory> factories = new HashMap<>();
    factories.put("HEAP", NumberArrayFactories.HEAP);
    factories.put("OFF_HEAP", NumberArrayFactories.OFF_HEAP);
    factories.put("AUTO_WITHOUT_PAGECACHE", NumberArrayFactories.AUTO_WITHOUT_PAGECACHE);
    factories.put("CHUNKED_FIXED_SIZE", NumberArrayFactories.CHUNKED_FIXED_SIZE);
    factories.put("autoWithPageCacheFallback", NumberArrayFactories.auto(pageCache, NULL, dir, true, NO_MONITOR, log, DEFAULT_DATABASE_NAME));
    factories.put("PageCachedNumberArrayFactory", new PageCachedNumberArrayFactory(pageCache, NULL, dir, log, DEFAULT_DATABASE_NAME));
    for (Map.Entry<String, NumberArrayFactory> entry : factories.entrySet()) {
        String name = entry.getKey() + " => ";
        NumberArrayFactory factory = entry.getValue();
        list.add(arrayData(name + "IntArray", factory.newIntArray(INDEXES, -1, INSTANCE), random -> random.nextInt(1_000_000_000), (array, index, value) -> array.set(index, (Integer) value), IntArray::get));
        list.add(arrayData(name + "DynamicIntArray", factory.newDynamicIntArray(CHUNK_SIZE, -1, INSTANCE), random -> random.nextInt(1_000_000_000), (array, index, value) -> array.set(index, (Integer) value), IntArray::get));
        list.add(arrayData(name + "LongArray", factory.newLongArray(INDEXES, -1, INSTANCE), random -> random.nextLong(1_000_000_000), (array, index, value) -> array.set(index, (Long) value), LongArray::get));
        list.add(arrayData(name + "DynamicLongArray", factory.newDynamicLongArray(CHUNK_SIZE, -1, INSTANCE), random -> random.nextLong(1_000_000_000), (array, index, value) -> array.set(index, (Long) value), LongArray::get));
        list.add(arrayData(name + "ByteArray5", factory.newByteArray(INDEXES, defaultByteArray(5), INSTANCE), random -> random.nextInt(1_000_000_000), (array, index, value) -> array.setInt(index, 1, (Integer) value), (array, index) -> array.getInt(index, 1)));
        list.add(arrayData(name + "DynamicByteArray5", factory.newDynamicByteArray(CHUNK_SIZE, defaultByteArray(5), INSTANCE), random -> random.nextInt(1_000_000_000), (array, index, value) -> array.setInt(index, 1, (Integer) value), (array, index) -> array.getInt(index, 1)));
        Function<RandomRule, Object> valueGenerator = random -> new long[] { random.nextLong(), random.nextInt(), (short) random.nextInt(), (byte) random.nextInt() };
        Writer<ByteArray> writer = (array, index, value) -> {
            long[] values = (long[]) value;
            array.setLong(index, 0, values[0]);
            array.setInt(index, 8, (int) values[1]);
            array.setShort(index, 12, (short) values[2]);
            array.setByte(index, 14, (byte) values[3]);
        };
        Reader<ByteArray> reader = (array, index) -> new long[] { array.getLong(index, 0), array.getInt(index, 8), array.getShort(index, 12), array.getByte(index, 14) };
        list.add(arrayData(name + "ByteArray15", factory.newByteArray(INDEXES, defaultByteArray(15), INSTANCE), valueGenerator, writer, reader));
        list.add(arrayData(name + "DynamicByteArray15", factory.newDynamicByteArray(CHUNK_SIZE, defaultByteArray(15), INSTANCE), valueGenerator, writer, reader));
    }
    return list;
}
Also used : Path(java.nio.file.Path) PageCache(org.neo4j.io.pagecache.PageCache) Arrays(java.util.Arrays) TestFactory(org.junit.jupiter.api.TestFactory) Collection(java.util.Collection) IOException(java.io.IOException) HashMap(java.util.HashMap) NULL(org.neo4j.io.pagecache.tracing.PageCacheTracer.NULL) Function(java.util.function.Function) NO_MONITOR(org.neo4j.internal.batchimport.cache.NumberArrayFactories.NO_MONITOR) ArrayList(java.util.ArrayList) AfterAll(org.junit.jupiter.api.AfterAll) Assertions.assertArrayEquals(org.junit.jupiter.api.Assertions.assertArrayEquals) Integer.max(java.lang.Integer.max) DEFAULT_DATABASE_NAME(org.neo4j.configuration.GraphDatabaseSettings.DEFAULT_DATABASE_NAME) INSTANCE(org.neo4j.memory.EmptyMemoryTracker.INSTANCE) Stream(java.util.stream.Stream) BeforeAll(org.junit.jupiter.api.BeforeAll) RandomRule(org.neo4j.test.rule.RandomRule) Map(java.util.Map) DynamicTest(org.junit.jupiter.api.DynamicTest) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) NullLog(org.neo4j.logging.NullLog) Path(java.nio.file.Path) ThrowingConsumer(org.junit.jupiter.api.function.ThrowingConsumer) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RandomRule(org.neo4j.test.rule.RandomRule) NullLog(org.neo4j.logging.NullLog) HashMap(java.util.HashMap) Map(java.util.Map) PageCache(org.neo4j.io.pagecache.PageCache)

Aggregations

IOException (java.io.IOException)1 Integer.max (java.lang.Integer.max)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Function (java.util.function.Function)1 Stream (java.util.stream.Stream)1 AfterAll (org.junit.jupiter.api.AfterAll)1 Assertions.assertArrayEquals (org.junit.jupiter.api.Assertions.assertArrayEquals)1 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)1 BeforeAll (org.junit.jupiter.api.BeforeAll)1 DynamicTest (org.junit.jupiter.api.DynamicTest)1 TestFactory (org.junit.jupiter.api.TestFactory)1 ThrowingConsumer (org.junit.jupiter.api.function.ThrowingConsumer)1 DEFAULT_DATABASE_NAME (org.neo4j.configuration.GraphDatabaseSettings.DEFAULT_DATABASE_NAME)1 NO_MONITOR (org.neo4j.internal.batchimport.cache.NumberArrayFactories.NO_MONITOR)1 PageCache (org.neo4j.io.pagecache.PageCache)1