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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations