Search in sources :

Example 1 with CachingExpandInto

use of org.neo4j.internal.kernel.api.helpers.CachingExpandInto in project neo4j by neo4j.

the class CachingExpandIntoTest method shouldComputeDegreeOfStartAndEndNode.

@Test
void shouldComputeDegreeOfStartAndEndNode() throws Exception {
    // Given
    CachingExpandInto expandInto = new CachingExpandInto(mock(Read.class), OUTGOING, memoryTracker);
    NodeCursor cursor = mockCursor();
    // Then
    assertEstimatesCorrectly(expandInto);
    // When
    findConnections(expandInto, cursor, 42, 43);
    // Then
    verify(cursor, times(2)).degree(any(RelationshipSelection.class));
    assertReleasesHeap(expandInto);
}
Also used : Read(org.neo4j.internal.kernel.api.Read) CachingExpandInto(org.neo4j.internal.kernel.api.helpers.CachingExpandInto) RelationshipSelection(org.neo4j.storageengine.api.RelationshipSelection) NodeCursor(org.neo4j.internal.kernel.api.NodeCursor) Test(org.junit.jupiter.api.Test)

Example 2 with CachingExpandInto

use of org.neo4j.internal.kernel.api.helpers.CachingExpandInto in project neo4j by neo4j.

the class CachingExpandIntoTest method shouldNotRecomputeAnythingIfSameNodesAndTypes.

@Test
void shouldNotRecomputeAnythingIfSameNodesAndTypes() throws Exception {
    // Given
    CachingExpandInto expandInto = new CachingExpandInto(mock(Read.class), OUTGOING, memoryTracker);
    findConnections(expandInto, mockCursor(), 42, 43, 100, 101);
    NodeCursor cursor = mockCursor();
    // When
    findConnections(expandInto, cursor, 42, 43, 100, 101);
    // Then
    verifyNoInteractions(cursor);
    assertReleasesHeap(expandInto);
}
Also used : Read(org.neo4j.internal.kernel.api.Read) CachingExpandInto(org.neo4j.internal.kernel.api.helpers.CachingExpandInto) NodeCursor(org.neo4j.internal.kernel.api.NodeCursor) Test(org.junit.jupiter.api.Test)

Example 3 with CachingExpandInto

use of org.neo4j.internal.kernel.api.helpers.CachingExpandInto in project neo4j by neo4j.

the class CachingExpandIntoTest method shouldComputeDegreeOfStartAndEndNodeEveryTimeIfCacheIsFull.

@Test
void shouldComputeDegreeOfStartAndEndNodeEveryTimeIfCacheIsFull() throws Exception {
    // Given
    CachingExpandInto expandInto = new CachingExpandInto(mock(Read.class), OUTGOING, memoryTracker, 0, true);
    NodeCursor cursor = mockCursor();
    // When
    findConnections(expandInto, cursor, 42, 43);
    findConnections(expandInto, cursor, 42, 43);
    findConnections(expandInto, cursor, 42, 43);
    findConnections(expandInto, cursor, 42, 43);
    findConnections(expandInto, cursor, 42, 43);
    // Then, only call 5 times for 42 and 5 times for 43
    verify(cursor, times(10)).degree(any(RelationshipSelection.class));
    assertReleasesHeap(expandInto);
}
Also used : Read(org.neo4j.internal.kernel.api.Read) CachingExpandInto(org.neo4j.internal.kernel.api.helpers.CachingExpandInto) RelationshipSelection(org.neo4j.storageengine.api.RelationshipSelection) NodeCursor(org.neo4j.internal.kernel.api.NodeCursor) Test(org.junit.jupiter.api.Test)

Example 4 with CachingExpandInto

use of org.neo4j.internal.kernel.api.helpers.CachingExpandInto in project neo4j by neo4j.

the class CachingExpandIntoTest method shouldComputeDegreeOnceIfStartAndEndNodeAreTheSame.

@Test
void shouldComputeDegreeOnceIfStartAndEndNodeAreTheSame() throws Exception {
    // Given
    CachingExpandInto expandInto = new CachingExpandInto(mock(Read.class), OUTGOING, memoryTracker);
    NodeCursor cursor = mockCursor();
    // When
    findConnections(expandInto, cursor, 42, 42);
    // Then
    verify(cursor).degree(any(RelationshipSelection.class));
    assertReleasesHeap(expandInto);
}
Also used : Read(org.neo4j.internal.kernel.api.Read) CachingExpandInto(org.neo4j.internal.kernel.api.helpers.CachingExpandInto) RelationshipSelection(org.neo4j.storageengine.api.RelationshipSelection) NodeCursor(org.neo4j.internal.kernel.api.NodeCursor) Test(org.junit.jupiter.api.Test)

Example 5 with CachingExpandInto

use of org.neo4j.internal.kernel.api.helpers.CachingExpandInto in project neo4j by neo4j.

the class CachingExpandIntoTest method shouldComputeDegreeOfStartAndEndNodeOnlyOnce.

@Test
void shouldComputeDegreeOfStartAndEndNodeOnlyOnce() throws Exception {
    // Given
    CachingExpandInto expandInto = new CachingExpandInto(mock(Read.class), OUTGOING, memoryTracker);
    NodeCursor cursor = mockCursor();
    // When, calling multiple times with different types
    findConnections(expandInto, cursor, 42, 43, 3);
    findConnections(expandInto, cursor, 43, 42, 4);
    findConnections(expandInto, cursor, 42, 43, 5);
    // Then, only call once for 42 and once for 43
    verify(cursor, times(2)).degree(any(RelationshipSelection.class));
    assertReleasesHeap(expandInto);
}
Also used : Read(org.neo4j.internal.kernel.api.Read) CachingExpandInto(org.neo4j.internal.kernel.api.helpers.CachingExpandInto) RelationshipSelection(org.neo4j.storageengine.api.RelationshipSelection) NodeCursor(org.neo4j.internal.kernel.api.NodeCursor) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)6 NodeCursor (org.neo4j.internal.kernel.api.NodeCursor)6 Read (org.neo4j.internal.kernel.api.Read)6 CachingExpandInto (org.neo4j.internal.kernel.api.helpers.CachingExpandInto)6 RelationshipSelection (org.neo4j.storageengine.api.RelationshipSelection)4