Search in sources :

Example 1 with OffHeapCollectionsFactory

use of org.neo4j.kernel.impl.util.collection.OffHeapCollectionsFactory in project neo4j by neo4j.

the class GlobalModule method createCollectionsFactorySupplier.

private static CollectionsFactorySupplier createCollectionsFactorySupplier(Config config, LifeSupport life) {
    final TransactionStateMemoryAllocation allocation = config.get(tx_state_memory_allocation);
    switch(allocation) {
        case ON_HEAP:
            return CollectionsFactorySupplier.ON_HEAP;
        case OFF_HEAP:
            final CachingOffHeapBlockAllocator allocator = new CachingOffHeapBlockAllocator(config.get(tx_state_off_heap_max_cacheable_block_size), config.get(tx_state_off_heap_block_cache_size));
            final OffHeapBlockAllocator sharedBlockAllocator;
            final long maxMemory = config.get(tx_state_max_off_heap_memory);
            if (maxMemory > 0) {
                sharedBlockAllocator = new CapacityLimitingBlockAllocatorDecorator(allocator, maxMemory);
            } else {
                sharedBlockAllocator = allocator;
            }
            life.add(onShutdown(sharedBlockAllocator::release));
            return () -> new OffHeapCollectionsFactory(sharedBlockAllocator);
        default:
            throw new IllegalArgumentException("Unknown transaction state memory allocation value: " + allocation);
    }
}
Also used : CapacityLimitingBlockAllocatorDecorator(org.neo4j.kernel.impl.util.collection.CapacityLimitingBlockAllocatorDecorator) CachingOffHeapBlockAllocator(org.neo4j.kernel.impl.util.collection.CachingOffHeapBlockAllocator) OffHeapBlockAllocator(org.neo4j.kernel.impl.util.collection.OffHeapBlockAllocator) CachingOffHeapBlockAllocator(org.neo4j.kernel.impl.util.collection.CachingOffHeapBlockAllocator) TransactionStateMemoryAllocation(org.neo4j.configuration.GraphDatabaseSettings.TransactionStateMemoryAllocation) OffHeapCollectionsFactory(org.neo4j.kernel.impl.util.collection.OffHeapCollectionsFactory)

Aggregations

TransactionStateMemoryAllocation (org.neo4j.configuration.GraphDatabaseSettings.TransactionStateMemoryAllocation)1 CachingOffHeapBlockAllocator (org.neo4j.kernel.impl.util.collection.CachingOffHeapBlockAllocator)1 CapacityLimitingBlockAllocatorDecorator (org.neo4j.kernel.impl.util.collection.CapacityLimitingBlockAllocatorDecorator)1 OffHeapBlockAllocator (org.neo4j.kernel.impl.util.collection.OffHeapBlockAllocator)1 OffHeapCollectionsFactory (org.neo4j.kernel.impl.util.collection.OffHeapCollectionsFactory)1