Search in sources :

Example 31 with MemoryTracker

use of org.neo4j.memory.MemoryTracker in project neo4j by neo4j.

the class HeapTrackingLongEnumerationList method create.

public static <V> HeapTrackingLongEnumerationList<V> create(MemoryTracker memoryTracker, int chunkSize) {
    Preconditions.requirePowerOfTwo(chunkSize);
    MemoryTracker scopedMemoryTracker = memoryTracker.getScopedMemoryTracker();
    scopedMemoryTracker.allocateHeap(SHALLOW_SIZE + SCOPED_MEMORY_TRACKER_SHALLOW_SIZE);
    return new HeapTrackingLongEnumerationList<>(scopedMemoryTracker, chunkSize);
}
Also used : MemoryTracker(org.neo4j.memory.MemoryTracker)

Example 32 with MemoryTracker

use of org.neo4j.memory.MemoryTracker in project neo4j by neo4j.

the class EagerBuffer method createEagerBuffer.

public static <T extends Measurable> EagerBuffer<T> createEagerBuffer(MemoryTracker memoryTracker, int initialChunkSize, int maxChunkSize, IntUnaryOperator growthStrategy) {
    MemoryTracker scopedMemoryTracker = memoryTracker.getScopedMemoryTracker();
    scopedMemoryTracker.allocateHeap(SHALLOW_SIZE + SCOPED_MEMORY_TRACKER_SHALLOW_SIZE + shallowSizeOfInstance(IntUnaryOperator.class));
    return new EagerBuffer<T>(scopedMemoryTracker, initialChunkSize, maxChunkSize, growthStrategy);
}
Also used : MemoryTracker(org.neo4j.memory.MemoryTracker)

Example 33 with MemoryTracker

use of org.neo4j.memory.MemoryTracker in project neo4j by neo4j.

the class HeapTrackingOrderedAppendMap method getIfAbsentPutWithMemoryTracker.

/**
 * Get and return the value in the Map at the specified key. Alternatively, if there is no value in the map for that key
 * return the result of evaluating the specified Function given the internal scoped memory tracker, and put that value in the
 * map at the specified key.
 *
 * @param key The key to look up or insert a new value for
 * @param function A function that takes a memory tracker and returns a value.
 * @return The value for the given key
 */
public V getIfAbsentPutWithMemoryTracker(K key, Function<MemoryTracker, ? extends V> function) {
    return map.getIfAbsentPutWith(key, p -> {
        MemoryTracker memoryTracker = scopedMemoryTracker;
        V value = p.valueOf(memoryTracker);
        addToBuffer(key, value);
        return value;
    }, function);
}
Also used : MemoryTracker(org.neo4j.memory.MemoryTracker)

Example 34 with MemoryTracker

use of org.neo4j.memory.MemoryTracker in project neo4j by neo4j.

the class HeapTrackingOrderedAppendMap method createOrderedMap.

public static <K, V> HeapTrackingOrderedAppendMap<K, V> createOrderedMap(MemoryTracker memoryTracker) {
    MemoryTracker scopedMemoryTracker = memoryTracker.getScopedMemoryTracker();
    scopedMemoryTracker.allocateHeap(SHALLOW_SIZE + SCOPED_MEMORY_TRACKER_SHALLOW_SIZE);
    return new HeapTrackingOrderedAppendMap<>(scopedMemoryTracker);
}
Also used : MemoryTracker(org.neo4j.memory.MemoryTracker)

Example 35 with MemoryTracker

use of org.neo4j.memory.MemoryTracker in project neo4j by neo4j.

the class LongProbeTable method createLongProbeTable.

public static <V extends Measurable> LongProbeTable<V> createLongProbeTable(MemoryTracker memoryTracker) {
    MemoryTracker scopedMemoryTracker = memoryTracker.getScopedMemoryTracker();
    scopedMemoryTracker.allocateHeap(SHALLOW_SIZE + SCOPED_MEMORY_TRACKER_SHALLOW_SIZE);
    return new LongProbeTable<>(scopedMemoryTracker);
}
Also used : ScopedMemoryTracker(org.neo4j.memory.ScopedMemoryTracker) MemoryTracker(org.neo4j.memory.MemoryTracker)

Aggregations

MemoryTracker (org.neo4j.memory.MemoryTracker)44 Test (org.junit.jupiter.api.Test)22 LocalMemoryTracker (org.neo4j.memory.LocalMemoryTracker)10 CursorContext (org.neo4j.io.pagecache.context.CursorContext)9 Value (org.neo4j.values.storable.Value)6 Transaction (org.neo4j.graphdb.Transaction)5 InternalTransaction (org.neo4j.kernel.impl.coreapi.InternalTransaction)5 Map (java.util.Map)4 Optional (java.util.Optional)4 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)4 SchemaDescriptor (org.neo4j.internal.schema.SchemaDescriptor)4 Log (org.neo4j.logging.Log)4 ValueTuple (org.neo4j.values.storable.ValueTuple)4 URI (java.net.URI)3 ArrayList (java.util.ArrayList)3 Collections.emptyMap (java.util.Collections.emptyMap)3 Objects.requireNonNullElse (java.util.Objects.requireNonNullElse)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 IOException (java.io.IOException)2 Arrays (java.util.Arrays)2